Charset override implementation.

This commit is contained in:
cata%netscape.com 2000-05-17 06:56:34 +00:00
Родитель c22fd60f54
Коммит 3e48d964fc
2 изменённых файлов: 48 добавлений и 2 удалений

Просмотреть файл

@ -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,6 +674,13 @@ 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;

Просмотреть файл

@ -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,6 +674,13 @@ 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;