Move nsIDocumentCharsetInfo out of intl/chardet into nsIDocShell, Bug 713825, r=bz, mbrubeck

This commit is contained in:
Simon Montagu
2012-01-24 11:52:05 +02:00
parent 22832cf881
commit 5c995efcb2
20 changed files with 114 additions and 312 deletions

View File

@@ -6029,7 +6029,7 @@ function BrowserSetForcedCharacterSet(aCharset)
function BrowserSetForcedDetector(doReload)
{
gBrowser.documentCharsetInfo.forcedDetector = true;
gBrowser.docShell.forcedDetector = true;
if (doReload)
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
}

View File

@@ -2375,10 +2375,6 @@
onget="return this.mCurrentBrowser.contentViewerFile;"
readonly="true"/>
<property name="documentCharsetInfo"
onget="return this.mCurrentBrowser.documentCharsetInfo;"
readonly="true"/>
<property name="contentDocument"
onget="return this.mCurrentBrowser.contentDocument;"
readonly="true"/>

View File

@@ -49,7 +49,6 @@
#include "nsIMarkupDocumentViewer.h"
#include "nsIDocShell.h"
#include "nsIParser.h" // kCharsetFrom* macro definition
#include "nsIDocumentCharsetInfo.h"
#include "nsNodeInfoManager.h"
#include "nsContentUtils.h"
@@ -185,7 +184,7 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
// the charset of the referring document. On the other hand, if the
// document is opened in a new window, it is |defaultCharacterSet| of |muCV|
// where the charset of our interest is stored. In case of openining
// in a new tab, we get the charset from |documentCharsetInfo|. Note that we
// in a new tab, we get the charset from the docShell. Note that we
// exclude UTF-8 as 'invalid' because UTF-8 is likely to be the charset
// of a chrome document that has nothing to do with the actual content
// whose charset we want to know. Even if "the actual content" is indeed
@@ -197,17 +196,13 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
// not being able to set the charset is not critical.
NS_ENSURE_TRUE(docShell, NS_OK);
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
nsCAutoString charset;
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
if (dcInfo) {
nsCOMPtr<nsIAtom> csAtom;
dcInfo->GetParentCharset(getter_AddRefs(csAtom));
docShell->GetParentCharset(getter_AddRefs(csAtom));
if (csAtom) { // opening in a new tab
csAtom->ToUTF8String(charset);
}
}
if (charset.IsEmpty() || charset.Equals("UTF-8")) {
nsCOMPtr<nsIContentViewer> cv;

View File

@@ -105,7 +105,6 @@
#include "nsICharsetAlias.h"
#include "nsContentUtils.h"
#include "nsJSUtils.h"
#include "nsIDocumentCharsetInfo.h"
#include "nsIDocumentEncoder.h" //for outputting selection
#include "nsICachingChannel.h"
#include "nsIJSContextStack.h"
@@ -383,7 +382,7 @@ nsHTMLDocument::TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
bool
nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
nsIDocumentCharsetInfo* aDocInfo,
nsIDocShell* aDocShell,
PRInt32& aCharsetSource,
nsACString& aCharset)
{
@@ -401,13 +400,13 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
aCharset = forceCharsetFromDocShell;
//TODO: we should define appropriate constant for force charset
aCharsetSource = kCharsetFromUserForced;
} else if (aDocInfo) {
} else if (aDocShell) {
nsCOMPtr<nsIAtom> csAtom;
aDocInfo->GetForcedCharset(getter_AddRefs(csAtom));
aDocShell->GetForcedCharset(getter_AddRefs(csAtom));
if (csAtom) {
csAtom->ToUTF8String(aCharset);
aCharsetSource = kCharsetFromUserForced;
aDocInfo->SetForcedCharset(nsnull);
aDocShell->SetForcedCharset(nsnull);
return true;
}
}
@@ -453,16 +452,16 @@ CheckSameOrigin(nsINode* aNode1, nsINode* aNode2)
}
bool
nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
nsIDocument* aParentDocument,
PRInt32& aCharsetSource,
nsACString& aCharset)
{
if (aDocInfo) {
if (aDocShell) {
PRInt32 source;
nsCOMPtr<nsIAtom> csAtom;
PRInt32 parentSource;
aDocInfo->GetParentCharsetSource(&parentSource);
aDocShell->GetParentCharsetSource(&parentSource);
if (kCharsetFromParentForced <= parentSource)
source = kCharsetFromParentForced;
else if (kCharsetFromHintPrevDoc == parentSource) {
@@ -489,7 +488,7 @@ nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
if (source < aCharsetSource)
return true;
aDocInfo->GetParentCharset(getter_AddRefs(csAtom));
aDocShell->GetParentCharset(getter_AddRefs(csAtom));
if (csAtom) {
csAtom->ToUTF8String(aCharset);
aCharsetSource = source;
@@ -745,9 +744,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
} else {
NS_ASSERTION(docShell && docShellAsItem, "Unexpected null value");
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
charsetSource = kCharsetUninitialized;
wyciwygChannel = do_QueryInterface(aChannel);
@@ -757,9 +753,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// describes. Some try call might change charset source to
// multiple values, like TryHintCharset and TryParentCharset. It
// should be always safe to try more sources.
if (!TryUserForcedCharset(muCV, dcInfo, charsetSource, charset)) {
if (!TryUserForcedCharset(muCV, docShell, charsetSource, charset)) {
TryHintCharset(muCV, charsetSource, charset);
TryParentCharset(dcInfo, parentDocument, charsetSource, charset);
TryParentCharset(docShell, parentDocument, charsetSource, charset);
// Don't actually get the charset from the channel if this is a
// wyciwyg channel; it'll always be UTF-16

View File

@@ -63,7 +63,7 @@ class nsIEditorDocShell;
class nsIParser;
class nsIURI;
class nsIMarkupDocumentViewer;
class nsIDocumentCharsetInfo;
class nsIDocShell;
class nsICachingChannel;
class nsHTMLDocument : public nsDocument,
@@ -253,14 +253,14 @@ protected:
PRInt32& aCharsetSource,
nsACString& aCharset);
static bool TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
nsIDocumentCharsetInfo* aDocInfo,
nsIDocShell* aDocShell,
PRInt32& aCharsetSource,
nsACString& aCharset);
static bool TryCacheCharset(nsICachingChannel* aCachingChannel,
PRInt32& aCharsetSource,
nsACString& aCharset);
// aParentDocument could be null.
bool TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
bool TryParentCharset(nsIDocShell* aDocShell,
nsIDocument* aParentDocument,
PRInt32& charsetSource, nsACString& aCharset);
static bool UseWeakDocTypeDefault(PRInt32& aCharsetSource,

View File

@@ -90,7 +90,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsIJSContextStack.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsDocumentCharsetInfoCID.h"
#include "nsIScrollableFrame.h"
#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
#include "nsICategoryManager.h"
@@ -756,10 +755,11 @@ nsDocShell::nsDocShell():
mIsBeingDestroyed(false),
mIsExecutingOnLoadHandler(false),
mIsPrintingOrPP(false),
mSavingOldViewer(false)
mSavingOldViewer(false),
#ifdef DEBUG
, mInEnsureScriptEnv(false)
mInEnsureScriptEnv(false),
#endif
mParentCharsetSource(0)
{
mHistoryID = ++gDocshellIDCounter;
if (gDocShellCount++ == 0) {
@@ -1877,40 +1877,59 @@ nsDocShell::SetCharset(const char* aCharset)
}
// set the charset override
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
if (dcInfo) {
nsCOMPtr<nsIAtom> csAtom;
csAtom = do_GetAtom(aCharset);
dcInfo->SetForcedCharset(csAtom);
}
nsCOMPtr<nsIAtom> csAtom = do_GetAtom(aCharset);
SetForcedCharset(csAtom);
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetDocumentCharsetInfo(nsIDocumentCharsetInfo **
aDocumentCharsetInfo)
NS_IMETHODIMP nsDocShell::SetForcedCharset(nsIAtom * aCharset)
{
NS_ENSURE_ARG_POINTER(aDocumentCharsetInfo);
// if the mDocumentCharsetInfo does not exist already, we create it now
if (!mDocumentCharsetInfo) {
mDocumentCharsetInfo = do_CreateInstance(NS_DOCUMENTCHARSETINFO_CONTRACTID);
if (!mDocumentCharsetInfo)
return NS_ERROR_FAILURE;
}
*aDocumentCharsetInfo = mDocumentCharsetInfo;
NS_IF_ADDREF(*aDocumentCharsetInfo);
mForcedCharset = aCharset;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetDocumentCharsetInfo(nsIDocumentCharsetInfo *
aDocumentCharsetInfo)
NS_IMETHODIMP nsDocShell::GetForcedCharset(nsIAtom ** aResult)
{
mDocumentCharsetInfo = aDocumentCharsetInfo;
*aResult = mForcedCharset;
if (mForcedCharset) NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetForcedDetector(bool aForced)
{
// XXX write me
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetForcedDetector(bool * aResult)
{
// XXX write me
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetParentCharset(nsIAtom * aCharset)
{
mParentCharset = aCharset;
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetParentCharset(nsIAtom ** aResult)
{
*aResult = mParentCharset;
if (mParentCharset) NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetParentCharsetSource(PRInt32 aCharsetSource)
{
mParentCharsetSource = aCharsetSource;
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetParentCharsetSource(PRInt32 * aParentCharsetSource)
{
*aParentCharsetSource = mParentCharsetSource;
return NS_OK;
}
@@ -3184,9 +3203,9 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
// charset, style-disabling, and zoom will be inherited in SetupNewViewer()
// Now take this document's charset and set the parentCharset field of the
// child's DocumentCharsetInfo to it. We'll later use that field, in the
// loading process, for the charset choosing algorithm.
// Now take this document's charset and set the child's parentCharset field
// to it. We'll later use that field, in the loading process, for the
// charset choosing algorithm.
// If we fail, at any point, we just return NS_OK.
// This code has some performance impact. But this will be reduced when
// the current charset will finally be stored as an Atom, avoiding the
@@ -3196,12 +3215,6 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
if (mItemType == nsIDocShellTreeItem::typeChrome)
return NS_OK;
// get the child's docCSInfo object
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo = NULL;
res = childAsDocShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
if (NS_FAILED(res) || (!dcInfo))
return NS_OK;
// get the parent's current charset
if (!mContentViewer)
return NS_OK;
@@ -3225,14 +3238,14 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
// set the child's parentCharset
nsCOMPtr<nsIAtom> parentCSAtom(do_GetAtom(parentCS));
res = dcInfo->SetParentCharset(parentCSAtom);
res = childAsDocShell->SetParentCharset(parentCSAtom);
if (NS_FAILED(res))
return NS_OK;
PRInt32 charsetSource = doc->GetDocumentCharacterSetSource();
// set the child's parentCharset
res = dcInfo->SetParentCharsetSource(charsetSource);
res = childAsDocShell->SetParentCharsetSource(charsetSource);
if (NS_FAILED(res))
return NS_OK;
}

View File

@@ -78,7 +78,6 @@
#define REFRESH_REDIRECT_TIMER 15000
// Interfaces Needed
#include "nsIDocumentCharsetInfo.h"
#include "nsIDocCharset.h"
#include "nsIGlobalHistory2.h"
#include "nsIInterfaceRequestor.h"
@@ -710,7 +709,6 @@ protected:
nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
nsRefPtr<nsDSURIContentListener> mContentListener;
nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
nsCOMPtr<nsIWidget> mParentWidget;
// mCurrentURI should be marked immutable on set if possible.
@@ -841,8 +839,12 @@ protected:
nsRefPtr<nsDOMNavigationTiming> mTiming;
#ifdef DEBUG
private:
nsCOMPtr<nsIAtom> mForcedCharset;
nsCOMPtr<nsIAtom> mParentCharset;
PRInt32 mParentCharsetSource;
#ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks
static unsigned long gNumberOfDocShells;
#endif /* DEBUG */

View File

@@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIAtom.idl"
%{ C++
class nsPresContext;
@@ -59,7 +60,6 @@ interface nsIContentViewer;
interface nsIURIContentListener;
interface nsIDOMEventTarget;
interface nsIDocShellLoadInfo;
interface nsIDocumentCharsetInfo;
interface nsIWebNavigation;
interface nsISimpleEnumerator;
interface nsIInputStream;
@@ -236,12 +236,6 @@ interface nsIDocShell : nsISupports
*/
attribute nsIDOMEventTarget chromeEventHandler;
/**
* The document charset info. This is used by a load to determine priorities
* for charset detection etc.
*/
attribute nsIDocumentCharsetInfo documentCharsetInfo;
/**
* Whether to allow plugin execution
*/
@@ -589,4 +583,25 @@ interface nsIDocShell : nsISupports
* A force also sets the fallback encoding for this frame.
*/
attribute string charset;
/**
* The charset forced by the user. When the charset attribute is set this
* attribute is set to the same value.
*
* XXX Could this be replaced by a boolean?
*/
attribute nsIAtom forcedCharset;
attribute boolean forcedDetector;
/**
* In a child docshell, this is the charset of the parent docshell
*/
attribute nsIAtom parentCharset;
/*
* In a child docshell, this is the source of parentCharset
* @see nsIParser
*/
attribute PRInt32 parentCharsetSource;
};

View File

@@ -44,13 +44,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = chardet
XPIDLSRCS = \
nsIDocumentCharsetInfo.idl \
$(NULL)
EXPORTS = \
nsDetectionConfident.h \
nsDocumentCharsetInfoCID.h \
nsICharsetDetectionObserver.h \
nsICharsetDetector.h \
nsIStringCharsetDetector.h \

View File

@@ -1,13 +0,0 @@
#ifndef nsDocumentCharsetInfoCID_h__
#define nsDocumentCharsetInfoCID_h__
#include "nscore.h"
#define NS_DOCUMENTCHARSETINFO_CONTRACTID "@mozilla.org/document-charset-info;1"
// {D25E0511-2BAE-11d4-9D10-0050040007B2}
#define NS_DOCUMENTCHARSETINFO_CID \
{0xd25e0511, 0x2bae, 0x11d4, {0x9d, 0x10, 0x0, 0x50, 0x4, 0x0, 0x7, 0xb2}}
#endif // nsDocumentCharsetInfoCID_h__

View File

@@ -1,17 +0,0 @@
#include "nsISupports.idl"
#include "nsIAtom.idl"
// XXX doc me
// XXX mark the right params "const"
[scriptable, uuid(2d40b291-01e1-11d4-9d0e-0050040007b2)]
interface nsIDocumentCharsetInfo : nsISupports
{
attribute nsIAtom forcedCharset;
attribute boolean forcedDetector;
attribute nsIAtom parentCharset;
attribute PRInt32 parentCharsetSource;
};

View File

@@ -55,7 +55,6 @@ CPPSRCS = \
nsObserverBase.cpp \
nsDebugDetector.cpp \
nsCyrillicDetector.cpp \
nsDocumentCharsetInfo.cpp \
nsChardetModule.cpp \
$(NULL)

View File

@@ -48,14 +48,11 @@
#include "nsISupports.h"
#include "nsICharsetDetector.h"
#include "nsICharsetAlias.h"
#include "nsDocumentCharsetInfo.h"
#include "nsICharsetDetectionObserver.h"
#include "nsIStringCharsetDetector.h"
#include "nsCyrillicDetector.h"
#include "nsDocumentCharsetInfoCID.h"
#include "nsXMLEncodingCID.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocumentCharsetInfo)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUProbDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKProbDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUStringProbDetector)

View File

@@ -42,7 +42,6 @@
#include "nsCharDetConstructors.h"
NS_DEFINE_NAMED_CID(NS_DOCUMENTCHARSETINFO_CID);
NS_DEFINE_NAMED_CID(NS_RU_PROBDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_UK_PROBDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_RU_STRING_PROBDETECTOR_CID);
@@ -54,7 +53,6 @@ NS_DEFINE_NAMED_CID(NS_LASTBLKDBG_DETECTOR_CID);
#endif /* INCLUDE_DBGDETECTOR */
static const mozilla::Module::CIDEntry kChardetCIDs[] = {
{ &kNS_DOCUMENTCHARSETINFO_CID, false, NULL, nsDocumentCharsetInfoConstructor },
{ &kNS_RU_PROBDETECTOR_CID, false, NULL, nsRUProbDetectorConstructor },
{ &kNS_UK_PROBDETECTOR_CID, false, NULL, nsUKProbDetectorConstructor },
{ &kNS_RU_STRING_PROBDETECTOR_CID, false, NULL, nsRUStringProbDetectorConstructor },
@@ -68,7 +66,6 @@ static const mozilla::Module::CIDEntry kChardetCIDs[] = {
};
static const mozilla::Module::ContractIDEntry kChardetContracts[] = {
{ NS_DOCUMENTCHARSETINFO_CONTRACTID, &kNS_DOCUMENTCHARSETINFO_CID },
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_PROBDETECTOR_CID },
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob", &kNS_UK_PROBDETECTOR_CID },
{ NS_STRCDETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_STRING_PROBDETECTOR_CID },

View File

@@ -1,106 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCharDetDll.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsDocumentCharsetInfo.h"
#include "nsCOMPtr.h"
// XXX doc me
NS_IMPL_THREADSAFE_ISUPPORTS1(nsDocumentCharsetInfo, nsIDocumentCharsetInfo)
nsDocumentCharsetInfo::nsDocumentCharsetInfo()
{
mParentCharsetSource = 0;
}
nsDocumentCharsetInfo::~nsDocumentCharsetInfo()
{
}
NS_IMETHODIMP nsDocumentCharsetInfo::SetForcedCharset(nsIAtom * aCharset)
{
mForcedCharset = aCharset;
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::GetForcedCharset(nsIAtom ** aResult)
{
*aResult = mForcedCharset;
if (mForcedCharset) NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::SetForcedDetector(bool aForced)
{
// XXX write me
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::GetForcedDetector(bool * aResult)
{
// XXX write me
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::SetParentCharset(nsIAtom * aCharset)
{
mParentCharset = aCharset;
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::GetParentCharset(nsIAtom ** aResult)
{
*aResult = mParentCharset;
if (mParentCharset) NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::SetParentCharsetSource(PRInt32 aCharsetSource)
{
mParentCharsetSource = aCharsetSource;
return NS_OK;
}
NS_IMETHODIMP nsDocumentCharsetInfo::GetParentCharsetSource(PRInt32 * aParentCharsetSource)
{
*aParentCharsetSource = mParentCharsetSource;
return NS_OK;
}

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDocumentCharsetInfo_h__
#define nsDocumentCharsetInfo_h__
#include "nsIFactory.h"
#include "nsIDocumentCharsetInfo.h"
class nsDocumentCharsetInfo : public nsIDocumentCharsetInfo
{
public:
nsDocumentCharsetInfo ();
virtual ~nsDocumentCharsetInfo ();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCUMENTCHARSETINFO
private:
nsCOMPtr<nsIAtom> mForcedCharset;
nsCOMPtr<nsIAtom> mParentCharset;
PRInt32 mParentCharsetSource;
};
#endif // nsDocumentCharsetInfo_h__

View File

@@ -52,7 +52,7 @@ var CharsetMenu = {
updatePageAction: function(aNode) {
let pref = Services.prefs.getComplexValue("browser.menu.showCharacterEncoding", Ci.nsIPrefLocalizedString).data;
if (pref == "true") {
let charset = getBrowser().documentCharsetInfo.forcedCharset;
let charset = getBrowser().docShell.forcedCharset;
if (charset) {
charset = charset.toString();
charset = charset.trim().toLowerCase();
@@ -95,7 +95,7 @@ var CharsetMenu = {
this._charsets = Services.prefs.getComplexValue("intl.charsetmenu.browser.static", Ci.nsIPrefLocalizedString).data.split(",");
}
let charsets = this._charsets;
let currentCharset = getBrowser().documentCharsetInfo.forcedCharset;
let currentCharset = getBrowser().docShell.forcedCharset;
if (currentCharset) {
currentCharset = currentCharset.toString();

View File

@@ -650,8 +650,16 @@
</property>
<property name="docShell"
onget="return null"
readonly="true"/>
readonly="true">
<getter><![CDATA[
return {
forcedCharset : this._charset,
forcedDetector : false,
parentCharset : "",
parentCharsetSource : 0
}
]]></getter>
</property>
<field name="_contentTitle">null</field>
@@ -683,18 +691,6 @@
onget="return null"
readonly="true"/>
<property name="documentCharsetInfo"
readonly="true">
<getter><![CDATA[
return {
forcedCharset : this._charset,
forcedDetector : false,
parentCharset : "",
parentCharsetSource : 0
}
]]></getter>
</property>
<field name="_charset"></field>
<constructor>

View File

@@ -731,7 +731,7 @@ function BrowserSetForcedCharacterSet(aCharset)
// instead of BrowserReloadWithFlags()
function BrowserSetForcedDetector(doReload)
{
gBrowser.documentCharsetInfo.forcedDetector = true;
gBrowser.docShell.forcedDetector = true;
if (doReload)
{
if (isHistoryEnabled()) {

View File

@@ -180,7 +180,7 @@
if (aCharset) {
try {
this.documentCharsetInfo.parentCharset = this.mAtomService.getAtom(aCharset);
this.docShell.parentCharset = this.mAtomService.getAtom(aCharset);
}
catch (e) {
}
@@ -438,10 +438,6 @@
onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
readonly="true"/>
<property name="documentCharsetInfo"
onget="return this.docShell.documentCharsetInfo;"
readonly="true"/>
<property name="contentDocument"
onget="return this.webNavigation.document;"
readonly="true"/>