change S/GetDocumentCharacterSet method for nsIDocument interface.

git-svn-id: svn://10.0.0.236/trunk@29531 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ftang%netscape.com
1999-04-27 21:49:25 +00:00
parent 250864cc95
commit 93bada68b4
12 changed files with 93 additions and 69 deletions

View File

@@ -289,7 +289,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
if (NS_OK == rv) {
nsIHTMLContentSink* sink;
nsAutoString defaultHTMLCharset = "ISO-8859-1"; // fallback value in case webShell return error
nsAutoString charset = "ISO-8859-1"; // fallback value in case webShell return error
nsCharsetSource charsetSource = kCharsetFromDocTypeDefault;
@@ -299,15 +299,28 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
NS_PRECONDITION(nsnull != aContainer, "No content viewer container");
aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
rv = NS_NewHTMLContentSink(&sink, this, aURL, webShell);
if (NS_OK == rv) {
const PRUnichar* defaultFromWebShell = NULL;
rv = webShell->GetDefaultCharacterSet(&defaultFromWebShell);
defaultHTMLCharset = defaultFromWebShell;
charsetSource = kCharsetFromUserDefault;
if (NS_SUCCEEDED(rv)) {
const PRUnichar* defaultCharsetFromWebShell = NULL;
rv = webShell->GetDefaultCharacterSet(&defaultCharsetFromWebShell);
if(NS_SUCCEEDED(rv)) {
charset = defaultCharsetFromWebShell;
charsetSource = kCharsetFromUserDefault;
}
}
NS_IF_RELEASE(webShell);
#endif
// 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);
}
if (NS_OK == rv) {
// Set the parser as the stream listener for the document loader...
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
@@ -323,7 +336,7 @@ nsHTMLDocument::StartDocumentLoad(nsIURL *aURL,
// nsIDTD* theDTD=0;
// NS_NewNavHTMLDTD(&theDTD);
// mParser->RegisterDTD(theDTD);
mParser->SetDocumentCharset( defaultHTMLCharset, charsetSource);
mParser->SetDocumentCharset( charset, charsetSource);
mParser->SetCommand(aCommand);
mParser->SetContentSink(sink);
mParser->Parse(aURL);