From f274743ebbdfdb443594832044377a379f6feda3 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Wed, 10 Nov 1999 05:50:10 +0000 Subject: [PATCH] fix 16808. change hard coded utf-8'to UTF-8', get charset hint from webshell. r=nhotta git-svn-id: svn://10.0.0.236/trunk@53070 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xml/document/src/nsXMLDocument.cpp | 23 +++++++++++++++---- .../layout/xml/document/src/nsXMLDocument.cpp | 23 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 12b73a017fd..58c71a3dacb 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -206,7 +206,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, } nsIWebShell* webShell; - nsAutoString charset("utf-8"); + nsAutoString charset("UTF-8"); nsCharsetSource charsetSource = kCharsetFromDocTypeDefault; nsCOMPtr aUrl; @@ -261,9 +261,24 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, if (NS_OK == rv) { nsIXMLContentSink* sink; - aContainer->QueryInterface(kIWebShellIID, (void**)&webShell); - rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell); - NS_IF_RELEASE(webShell); + rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell); + + if(NS_SUCCEEDED(rv) && (nsnull != webShell)) { + if(0 == nsCRT::strcmp("view-source", aCommand)) { // only do this for view-source + const PRUnichar* hintCharset = nsnull; + nsCharsetSource hintSource = kCharsetUninitialized; + rv = webShell->GetCharacterSetHint(&hintCharset, &hintSource); + if(NS_SUCCEEDED(rv)) { + if(hintSource > charsetSource) { + charset = hintCharset; + charsetSource = hintSource; + } + } + } + if(NS_SUCCEEDED(rv)) + rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell); + NS_IF_RELEASE(webShell); + } if (NS_OK == rv) { // Set the parser as the stream listener for the document loader... diff --git a/mozilla/layout/xml/document/src/nsXMLDocument.cpp b/mozilla/layout/xml/document/src/nsXMLDocument.cpp index 12b73a017fd..58c71a3dacb 100644 --- a/mozilla/layout/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/layout/xml/document/src/nsXMLDocument.cpp @@ -206,7 +206,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, } nsIWebShell* webShell; - nsAutoString charset("utf-8"); + nsAutoString charset("UTF-8"); nsCharsetSource charsetSource = kCharsetFromDocTypeDefault; nsCOMPtr aUrl; @@ -261,9 +261,24 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, if (NS_OK == rv) { nsIXMLContentSink* sink; - aContainer->QueryInterface(kIWebShellIID, (void**)&webShell); - rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell); - NS_IF_RELEASE(webShell); + rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell); + + if(NS_SUCCEEDED(rv) && (nsnull != webShell)) { + if(0 == nsCRT::strcmp("view-source", aCommand)) { // only do this for view-source + const PRUnichar* hintCharset = nsnull; + nsCharsetSource hintSource = kCharsetUninitialized; + rv = webShell->GetCharacterSetHint(&hintCharset, &hintSource); + if(NS_SUCCEEDED(rv)) { + if(hintSource > charsetSource) { + charset = hintCharset; + charsetSource = hintSource; + } + } + } + if(NS_SUCCEEDED(rv)) + rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell); + NS_IF_RELEASE(webShell); + } if (NS_OK == rv) { // Set the parser as the stream listener for the document loader...