Charset override implementation.

This commit is contained in:
cata@netscape.com
2000-05-17 06:56:34 +00:00
parent 4981105964
commit 9f3a9f4675
2 changed files with 48 additions and 2 deletions

View File

@@ -100,6 +100,8 @@
#include "nsIPref.h"
#include "nsLayoutUtils.h"
#include "nsIDocumentCharsetInfo.h"
#include "nsIDocumentEncoder.h" //for outputting selection
@@ -570,6 +572,20 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
}
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
PRBool override = PR_FALSE;
nsCOMPtr<nsIPref> prf(do_GetService(NS_PREF_PROGID));
if (prf) {
char * toOverride = nsnull;
if(NS_SUCCEEDED(prf->CopyCharPref("intl.charset.override", &toOverride)))
{
if (toOverride[0] != 0) override = PR_TRUE;
PR_FREEIF(toOverride);
}
}
//
// The following logic is mirrored in nsWebShell::Embed!
//
@@ -658,7 +674,14 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
Recycle(forceCharsetFromWebShell);
//TODO: we should define appropriate constant for force charset
charsetSource = kCharsetFromPreviousLoading;
}
} else if ((dcInfo != NULL) && (override)) {
nsCOMPtr<nsIAtom> csAtom;
dcInfo->GetForcedCharset(getter_AddRefs(csAtom));
if (csAtom != NULL) {
csAtom->ToString(charset);
charsetSource = kCharsetFromPreviousLoading;
}
}
}
nsresult rv_detect = NS_OK;
if(! gInitDetector)