From 7d0cd1a7e115e0741b7dbd74133228196f0658dc Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Wed, 19 May 1999 00:24:41 +0000 Subject: [PATCH] get charset information from nsIWebShell to implement META charset reload git-svn-id: svn://10.0.0.236/trunk@32189 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/document/src/nsHTMLDocument.cpp | 11 +++++++++-- mozilla/layout/html/document/src/nsHTMLDocument.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 04c7948713d..d999899f538 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -308,6 +308,9 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, nsAutoString charset = "ISO-8859-1"; // fallback value in case webShell return error nsCharsetSource charsetSource = kCharsetFromDocTypeDefault; + const PRUnichar* requestCharset = nsnull; + nsCharsetSource requestCharsetSource = kCharsetUninitialized; + #ifdef rickgdebug nsString outString; // added out. Redirect to stdout if desired -- gpk 04/01/99 @@ -324,6 +327,12 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, charset = defaultCharsetFromWebShell; charsetSource = kCharsetFromUserDefault; } + // for html, we need to find out the Meta tag from the hint. + rv = webShell->GetCharacterSetHint(&requestCharset, &requestCharsetSource); + if(NS_SUCCEEDED(rv)) { + if(requestCharsetSource > charsetSource) + charset = requestCharset; + } } NS_IF_RELEASE(webShell); #endif @@ -331,8 +340,6 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, // XXXX // We should take care two more cases here // 1. The charset attribute from HTTP header - // 2. The charset parameter from the META Tag - - // which explicit pass to nsWebShell from nsCharsetObserver if (NS_SUCCEEDED(rv)) { rv = this->SetDocumentCharacterSet(charset); diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 04c7948713d..d999899f538 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -308,6 +308,9 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, nsAutoString charset = "ISO-8859-1"; // fallback value in case webShell return error nsCharsetSource charsetSource = kCharsetFromDocTypeDefault; + const PRUnichar* requestCharset = nsnull; + nsCharsetSource requestCharsetSource = kCharsetUninitialized; + #ifdef rickgdebug nsString outString; // added out. Redirect to stdout if desired -- gpk 04/01/99 @@ -324,6 +327,12 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, charset = defaultCharsetFromWebShell; charsetSource = kCharsetFromUserDefault; } + // for html, we need to find out the Meta tag from the hint. + rv = webShell->GetCharacterSetHint(&requestCharset, &requestCharsetSource); + if(NS_SUCCEEDED(rv)) { + if(requestCharsetSource > charsetSource) + charset = requestCharset; + } } NS_IF_RELEASE(webShell); #endif @@ -331,8 +340,6 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL, // XXXX // We should take care two more cases here // 1. The charset attribute from HTTP header - // 2. The charset parameter from the META Tag - - // which explicit pass to nsWebShell from nsCharsetObserver if (NS_SUCCEEDED(rv)) { rv = this->SetDocumentCharacterSet(charset);