Move nsIDocumentCharsetInfo out of intl/chardet into nsIDocShell, Bug 713825, r=bz, mbrubeck
authorSimon Montagu <smontagu@smontagu.org>
Tue, 24 Jan 2012 11:52:05 +0200
changeset 86413 57f0b07c2dc5108e3c1fb477dc4e134e3161158b
parent 86412 1cbdfc84d7e30a602e3d30ae31744f9e796a19f6
child 86414 9aab7ae07561a3004625ca7c80d98f06c6daf9af
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, mbrubeck
bugs713825
milestone12.0a1
Move nsIDocumentCharsetInfo out of intl/chardet into nsIDocShell, Bug 713825, r=bz, mbrubeck
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
content/html/document/src/MediaDocument.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocShell.idl
intl/chardet/public/Makefile.in
intl/chardet/public/nsDocumentCharsetInfoCID.h
intl/chardet/public/nsIDocumentCharsetInfo.idl
intl/chardet/src/Makefile.in
intl/chardet/src/nsCharDetConstructors.h
intl/chardet/src/nsChardetModule.cpp
intl/chardet/src/nsDocumentCharsetInfo.cpp
intl/chardet/src/nsDocumentCharsetInfo.h
mobile/xul/chrome/content/CharsetMenu.js
mobile/xul/chrome/content/bindings/browser.xml
toolkit/components/viewsource/content/viewSource.js
toolkit/content/widgets/browser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6024,17 +6024,17 @@ function BrowserSetForcedCharacterSet(aC
   gBrowser.docShell.charset = aCharset;
   // Save the forced character-set
   PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, aCharset);
   BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
 }
 
 function BrowserSetForcedDetector(doReload)
 {
-  gBrowser.documentCharsetInfo.forcedDetector = true;
+  gBrowser.docShell.forcedDetector = true;
   if (doReload)
     BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
 }
 
 function charsetMenuGetElement(parent, id) {
   return parent.getElementsByAttribute("id", id)[0];
 }
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2370,20 +2370,16 @@
       <property name="contentViewerEdit"
                 onget="return this.mCurrentBrowser.contentViewerEdit;"
                 readonly="true"/>
 
       <property name="contentViewerFile"
                 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"/>
 
       <property name="contentTitle"
                 onget="return this.mCurrentBrowser.contentTitle;"
                 readonly="true"/>
 
--- a/content/html/document/src/MediaDocument.cpp
+++ b/content/html/document/src/MediaDocument.cpp
@@ -44,17 +44,16 @@
 #include "nsIScrollable.h"
 #include "nsIViewManager.h"
 #include "nsITextToSubURI.h"
 #include "nsIURL.h"
 #include "nsIContentViewer.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDocShell.h"
 #include "nsIParser.h" // kCharsetFrom* macro definition
-#include "nsIDocumentCharsetInfo.h" 
 #include "nsNodeInfoManager.h"
 #include "nsContentUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 MediaDocumentStreamListener::MediaDocumentStreamListener(MediaDocument *aDocument)
 {
@@ -180,38 +179,34 @@ MediaDocument::StartDocumentLoad(const c
   // |UpdateTitleAndCharset| and the worst thing possible is a mangled 
   // filename in the titlebar and the file picker.
 
   // When this document is opened in the window/tab of the referring 
   // document (by a simple link-clicking), |prevDocCharacterSet| contains 
   // 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 
   // in UTF-8, we don't lose anything because the default empty value is 
   // considered synonymous with UTF-8. 
     
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
 
   // 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));
-    if (csAtom) {   // opening in a new tab
-      csAtom->ToUTF8String(charset);
-    }
+  nsCOMPtr<nsIAtom> 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;
     docShell->GetContentViewer(getter_AddRefs(cv));
 
     // not being able to set the charset is not critical.
     NS_ENSURE_TRUE(cv, NS_OK); 
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -100,17 +100,16 @@
 #include "nsIFile.h"
 #include "nsEventListenerManager.h"
 #include "nsFrameSelection.h"
 #include "nsISelectionPrivate.h"//for toStringwithformat code
 
 #include "nsICharsetAlias.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
-#include "nsIDocumentCharsetInfo.h"
 #include "nsIDocumentEncoder.h" //for outputting selection
 #include "nsICachingChannel.h"
 #include "nsIJSContextStack.h"
 #include "nsIContentViewer.h"
 #include "nsIWyciwygChannel.h"
 #include "nsIScriptElement.h"
 #include "nsIScriptError.h"
 #include "nsIMutableArray.h"
@@ -378,17 +377,17 @@ nsHTMLDocument::TryHintCharset(nsIMarkup
     }
   }
   return false;
 }
 
 
 bool
 nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
-                                     nsIDocumentCharsetInfo*  aDocInfo,
+                                     nsIDocShell*  aDocShell,
                                      PRInt32& aCharsetSource,
                                      nsACString& aCharset)
 {
   nsresult rv = NS_OK;
 
   if(kCharsetFromUserForced <= aCharsetSource)
     return true;
 
@@ -396,23 +395,23 @@ nsHTMLDocument::TryUserForcedCharset(nsI
   if (aMarkupDV) {
     rv = aMarkupDV->GetForceCharacterSet(forceCharsetFromDocShell);
   }
 
   if(NS_SUCCEEDED(rv) && !forceCharsetFromDocShell.IsEmpty()) {
     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;
     }
   }
 
   return false;
 }
 
 bool
@@ -448,26 +447,26 @@ CheckSameOrigin(nsINode* aNode1, nsINode
   bool equal;
   return
     NS_SUCCEEDED(aNode1->NodePrincipal()->
                    Equals(aNode2->NodePrincipal(), &equal)) &&
     equal;
 }
 
 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) {
       // Make sure that's OK
       if (!aParentDocument || !CheckSameOrigin(this, aParentDocument)) {
         return false;
       }
       
@@ -484,17 +483,17 @@ nsHTMLDocument::TryParentCharset(nsIDocu
       source = kCharsetFromParentFrame;
     }
     else
       return false;
 
     if (source < aCharsetSource)
       return true;
 
-    aDocInfo->GetParentCharset(getter_AddRefs(csAtom));
+    aDocShell->GetParentCharset(getter_AddRefs(csAtom));
     if (csAtom) {
       csAtom->ToUTF8String(aCharset);
       aCharsetSource = source;
       return true;
     }
   }
   return false;
 }
@@ -739,32 +738,29 @@ nsHTMLDocument::StartDocumentLoad(const 
     charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault
                              : kCharsetFromDocTypeDefault;
     charset.AssignLiteral("UTF-8");
     TryChannelCharset(aChannel, charsetSource, charset);
     parserCharsetSource = charsetSource;
     parserCharset = charset;
   } else {
     NS_ASSERTION(docShell && docShellAsItem, "Unexpected null value");
-    
-    nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
-    docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
 
     charsetSource = kCharsetUninitialized;
     wyciwygChannel = do_QueryInterface(aChannel);
 
     // The following charset resolving calls has implied knowledge
     // about charset source priority order. Each try will return true
     // if the source is higher or equal to the source as its name
     // 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
       if (!wyciwygChannel &&
           TryChannelCharset(aChannel, charsetSource, charset)) {
         // Use the channel's charset (e.g., charset from HTTP
         // "Content-Type" header).
       }
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -58,17 +58,17 @@
 
 #include "nsICommandManager.h"
 
 class nsIEditor;
 class nsIEditorDocShell;
 class nsIParser;
 class nsIURI;
 class nsIMarkupDocumentViewer;
-class nsIDocumentCharsetInfo;
+class nsIDocShell;
 class nsICachingChannel;
 
 class nsHTMLDocument : public nsDocument,
                        public nsIHTMLDocument,
                        public nsIDOMHTMLDocument
 {
 public:
   using nsDocument::SetDocumentURI;
@@ -248,24 +248,24 @@ protected:
   PRInt32 mNumForms;
 
   static PRUint32 gWyciwygSessionCnt;
 
   static bool TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
                                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,
                                       nsACString& aCharset);
   static bool TryDefaultCharset(nsIMarkupDocumentViewer* aMarkupDV,
                                   PRInt32& aCharsetSource,
                                   nsACString& aCharset);
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -85,17 +85,16 @@
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIUploadChannel.h"
 #include "nsISecurityEventSink.h"
 #include "mozilla/FunctionTimer.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIJSContextStack.h"
 #include "nsIScriptObjectPrincipal.h"
-#include "nsDocumentCharsetInfoCID.h"
 #include "nsIScrollableFrame.h"
 #include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
 #include "nsICategoryManager.h"
 #include "nsXPCOMCID.h"
 #include "nsISeekableStream.h"
 #include "nsAutoPtr.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsIAppShell.h"
@@ -751,20 +750,21 @@ nsDocShell::nsDocShell():
     mIsAppTab(false),
     mUseGlobalHistory(false),
     mFiredUnloadEvent(false),
     mEODForCurrentDocument(false),
     mURIResultedInDocument(false),
     mIsBeingDestroyed(false),
     mIsExecutingOnLoadHandler(false),
     mIsPrintingOrPP(false),
-    mSavingOldViewer(false)
+    mSavingOldViewer(false),
 #ifdef DEBUG
-    , mInEnsureScriptEnv(false)
+    mInEnsureScriptEnv(false),
 #endif
+    mParentCharsetSource(0)
 {
     mHistoryID = ++gDocshellIDCounter;
     if (gDocShellCount++ == 0) {
         NS_ASSERTION(sURIFixup == nsnull,
                      "Huh, sURIFixup not null in first nsDocShell ctor!");
 
         CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup);
     }
@@ -1872,51 +1872,70 @@ nsDocShell::SetCharset(const char* aChar
       if (muDV) {
         nsCString charset(aCharset);
         NS_ENSURE_SUCCESS(muDV->SetDefaultCharacterSet(charset),
                           NS_ERROR_FAILURE);
       }
     }
 
     // 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_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);
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDocShell::SetDocumentCharsetInfo(nsIDocumentCharsetInfo *
-                                   aDocumentCharsetInfo)
-{
-    mDocumentCharsetInfo = aDocumentCharsetInfo;
-    return NS_OK;
+NS_IMETHODIMP nsDocShell::SetForcedCharset(nsIAtom * aCharset)
+{
+  mForcedCharset = aCharset;
+  return NS_OK;
+}
+
+NS_IMETHODIMP nsDocShell::GetForcedCharset(nsIAtom ** aResult)
+{
+  *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;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetChannelIsUnsafe(bool *aUnsafe)
 {
     *aUnsafe = false;
 
     nsIChannel* channel = GetCurrentDocChannel();
@@ -3179,34 +3198,28 @@ nsDocShell::AddChild(nsIDocShellTreeItem
     aChild->SetTreeOwner(mTreeOwner);
 
     nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild));
     if (!childAsDocShell)
         return NS_OK;
 
     // 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
     // alias resolution extra look-up.
 
     // we are NOT going to propagate the charset is this Chrome's docshell
     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;
     nsIDocument* doc = mContentViewer->GetDocument();
     if (!doc)
         return NS_OK;
     const nsACString &parentCS = doc->GetDocumentCharacterSet();
 
@@ -3220,24 +3233,24 @@ nsDocShell::AddChild(nsIDocShellTreeItem
     if (!isWyciwyg) {
         // If this docshell is loaded from a wyciwyg: URI, don't
         // advertise our charset since it does not in any way reflect
         // the actual source charset, which is what we're trying to
         // expose here.
 
         // 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;
     }
 
     // printf("### 1 >>> Adding child. Parent CS = %s. ItemType = %d.\n", NS_LossyConvertUTF16toASCII(parentCS).get(), mItemType);
 
     return NS_OK;
 }
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -73,17 +73,16 @@
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 
 // Threshold value in ms for META refresh based redirects
 #define REFRESH_REDIRECT_TIMER 15000
 
 // Interfaces Needed
-#include "nsIDocumentCharsetInfo.h"
 #include "nsIDocCharset.h"
 #include "nsIGlobalHistory2.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPrompt.h"
 #include "nsIRefreshURI.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptGlobalObjectOwner.h"
@@ -705,17 +704,16 @@ protected:
      */
     nsCString                  mContentTypeHint;
     nsIntPoint                 mDefaultScrollbarPref; // persistent across doc loads
 
     nsCOMPtr<nsISupportsArray> mRefreshURIList;
     nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
     nsRefPtr<nsDSURIContentListener> mContentListener;
     nsCOMPtr<nsIContentViewer> mContentViewer;
-    nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
     nsCOMPtr<nsIWidget>        mParentWidget;
 
     // mCurrentURI should be marked immutable on set if possible.
     nsCOMPtr<nsIURI>           mCurrentURI;
     nsCOMPtr<nsIURI>           mReferrerURI;
     nsCOMPtr<nsIScriptGlobalObject> mScriptGlobal;
     nsCOMPtr<nsISHistory>      mSessionHistory;
     nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
@@ -836,18 +834,22 @@ protected:
     bool                       mInEnsureScriptEnv;
 #endif
     PRUint64                   mHistoryID;
 
     static nsIURIFixup *sURIFixup;
 
     nsRefPtr<nsDOMNavigationTiming> mTiming;
 
+private:
+    nsCOMPtr<nsIAtom> mForcedCharset;
+    nsCOMPtr<nsIAtom> mParentCharset;
+    PRInt32          mParentCharsetSource;
+
 #ifdef DEBUG
-private:
     // We're counting the number of |nsDocShells| to help find leaks
     static unsigned long gNumberOfDocShells;
 #endif /* DEBUG */
 
 public:
     class InterfaceRequestorProxy : public nsIInterfaceRequestor {
     public:
         InterfaceRequestorProxy(nsIInterfaceRequestor* p);
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -34,16 +34,17 @@
  * 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 "nsISupports.idl"
+#include "nsIAtom.idl"
 
 %{ C++
 class nsPresContext;
 class nsIPresShell;
 struct JSContext;
 %}
 
 /**
@@ -54,17 +55,16 @@ struct JSContext;
 [ptr] native nsIPresShell(nsIPresShell);
 
 interface nsIURI;
 interface nsIChannel;
 interface nsIContentViewer;
 interface nsIURIContentListener;
 interface nsIDOMEventTarget;
 interface nsIDocShellLoadInfo;
-interface nsIDocumentCharsetInfo;
 interface nsIWebNavigation;
 interface nsISimpleEnumerator;
 interface nsIInputStream;
 interface nsIRequest;
 interface nsISHEntry;
 interface nsILayoutHistoryState;
 interface nsISecureBrowserUI;
 interface nsIDOMStorage;
@@ -232,22 +232,16 @@ interface nsIDocShell : nsISupports
 
   /**
    * This attribute allows chrome to tie in to handle DOM events that may
    * be of interest to chrome.
    */
   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
    */
   attribute boolean allowPlugins;
 
   /**
    * Whether to allow Javascript execution
    */
   attribute boolean allowJavascript;
@@ -584,9 +578,30 @@ interface nsIDocShell : nsISupports
    * document. Get returns the encoding used. Set forces 
    * (overrides) the encoding. After forcing the charset the 
    * embedding application will need to cause the data to be 
    * reparsed in order to update the DOM / display.
    *
    * 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;
 };
--- a/intl/chardet/public/Makefile.in
+++ b/intl/chardet/public/Makefile.in
@@ -39,23 +39,18 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= chardet
 
-XPIDLSRCS       = \
-                nsIDocumentCharsetInfo.idl \
-		$(NULL)
-
 EXPORTS		= \
 		nsDetectionConfident.h \
-		nsDocumentCharsetInfoCID.h \
 		nsICharsetDetectionObserver.h \
 		nsICharsetDetector.h \
 		nsIStringCharsetDetector.h \
 		nsXMLEncodingCID.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
deleted file mode 100644
--- a/intl/chardet/public/nsDocumentCharsetInfoCID.h
+++ /dev/null
@@ -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__
-
deleted file mode 100644
--- a/intl/chardet/public/nsIDocumentCharsetInfo.idl
+++ /dev/null
@@ -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;
-};
--- a/intl/chardet/src/Makefile.in
+++ b/intl/chardet/src/Makefile.in
@@ -50,13 +50,12 @@ MODULE_NAME = nsChardetModule
 GRE_MODULE = 1
 LIBXUL_LIBRARY  = 1
 
 
 CPPSRCS		= \
 		nsObserverBase.cpp \
 		nsDebugDetector.cpp \
 		nsCyrillicDetector.cpp \
-		nsDocumentCharsetInfo.cpp \
 		nsChardetModule.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/intl/chardet/src/nsCharDetConstructors.h
+++ b/intl/chardet/src/nsCharDetConstructors.h
@@ -43,24 +43,21 @@
 
 #ifndef nsCharDetConstructors_h__
 #define nsCharDetConstructors_h__
 
 // chardet
 #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)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKStringProbDetector)
 
 #ifdef INCLUDE_DBGDETECTOR
 NS_GENERIC_FACTORY_CONSTRUCTOR(ns1stBlkDbgDetector)
 NS_GENERIC_FACTORY_CONSTRUCTOR(ns2ndBlkDbgDetector)
--- a/intl/chardet/src/nsChardetModule.cpp
+++ b/intl/chardet/src/nsChardetModule.cpp
@@ -37,43 +37,40 @@
 
 #include "mozilla/ModuleUtils.h"
 #include "nsCOMPtr.h"
 #include "nsICategoryManager.h"
 #include "nsIServiceManager.h"
 
 #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);
 NS_DEFINE_NAMED_CID(NS_UK_STRING_PROBDETECTOR_CID);
 #ifdef INCLUDE_DBGDETECTOR
 NS_DEFINE_NAMED_CID(NS_1STBLKDBG_DETECTOR_CID);
 NS_DEFINE_NAMED_CID(NS_2NDBLKDBG_DETECTOR_CID);
 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 },
   { &kNS_UK_STRING_PROBDETECTOR_CID, false, NULL, nsUKStringProbDetectorConstructor },
 #ifdef INCLUDE_DBGDETECTOR
   { &kNS_1STBLKDBG_DETECTOR_CID, false, NULL, ns1stBlkDbgDetectorConstructor },
   { &kNS_2NDBLKDBG_DETECTOR_CID, false, NULL, ns2ndBlkDbgDetectorConstructor },
   { &kNS_LASTBLKDBG_DETECTOR_CID, false, NULL, nsLastBlkDbgDetectorConstructor },
 #endif /* INCLUDE_DBGDETECTOR */
   { NULL }
 };
 
 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 },
   { NS_STRCDETECTOR_CONTRACTID_BASE "ukprob", &kNS_UK_STRING_PROBDETECTOR_CID },
 #ifdef INCLUDE_DBGDETECTOR
   { NS_CHARSET_DETECTOR_CONTRACTID_BASE "1stblkdbg", &kNS_1STBLKDBG_DETECTOR_CID },
   { NS_CHARSET_DETECTOR_CONTRACTID_BASE "2ndblkdbg", &kNS_2NDBLKDBG_DETECTOR_CID },
   { NS_CHARSET_DETECTOR_CONTRACTID_BASE "lastblkdbg", &kNS_LASTBLKDBG_DETECTOR_CID },
deleted file mode 100644
--- a/intl/chardet/src/nsDocumentCharsetInfo.cpp
+++ /dev/null
@@ -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;
-}
-
deleted file mode 100644
--- a/intl/chardet/src/nsDocumentCharsetInfo.h
+++ /dev/null
@@ -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__
--- a/mobile/xul/chrome/content/CharsetMenu.js
+++ b/mobile/xul/chrome/content/CharsetMenu.js
@@ -47,17 +47,17 @@ var CharsetMenu = {
 
   init: function() {
     PageActions.register("pageaction-charset", this.updatePageAction, this);
   },
 
   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();
         aNode.setAttribute("description", this.strings.GetStringFromName(charset + ".title"));
       } else if (aNode.hasAttribute("description")) {
         aNode.removeAttribute("description");
       }
     }
@@ -90,17 +90,17 @@ var CharsetMenu = {
     selectedIndex: -1
   },
 
   get charsets() {
     if (!this._charsets) {
       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();
       currentCharset = currentCharset.trim().toLowerCase();
       if (charsets.indexOf(currentCharset) == -1)
         charsets.splice(0, 0, currentCharset);
     }
     return this._toMenuItems(charsets, currentCharset);
--- a/mobile/xul/chrome/content/bindings/browser.xml
+++ b/mobile/xul/chrome/content/bindings/browser.xml
@@ -645,18 +645,26 @@
         <getter>
           <![CDATA[
             throw "autoscrollEnabled: Supports Remote?";
           ]]>
         </getter>
       </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>
 
       <property name="contentTitle"
                 onget="return this._contentTitle;"
                 readonly="true"/>
 
       <property name="webNavigation"
@@ -678,28 +686,16 @@
       <property name="contentViewerEdit"
                 onget="return null"
                 readonly="true"/>
 
       <property name="contentViewerFile"
                 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>
         <![CDATA[
           this.messageManager.addMessageListener("scroll", this._messageListenerRemote);
         ]]>
       </constructor>
 
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -726,17 +726,17 @@ function BrowserSetForcedCharacterSet(aC
 
 // fix for bug #229503
 // we need to define BrowserSetForcedDetector() so that we can
 // change auto-detect options in the "View | Character Encoding" menu.
 // As with BrowserSetForcedCharacterSet(), call PageLoader.loadPage() 
 // instead of BrowserReloadWithFlags()
 function BrowserSetForcedDetector(doReload)
 {
-  gBrowser.documentCharsetInfo.forcedDetector = true; 
+  gBrowser.docShell.forcedDetector = true; 
   if (doReload)
   {
     if (isHistoryEnabled()) {
       gPageLoader.loadPage(gPageLoader.currentDescriptor,
                            gPageLoader.DISPLAY_NORMAL);
     } else {
       gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
     }
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -175,17 +175,17 @@
         <parameter name="aPostData"/>
         <body>
           <![CDATA[
             if (!aURI)
               aURI = "about:blank";
 
             if (aCharset) {
               try { 
-                this.documentCharsetInfo.parentCharset = this.mAtomService.getAtom(aCharset);
+                this.docShell.parentCharset = this.mAtomService.getAtom(aCharset);
               }
               catch (e) {
               }
             }
 
             if (!(aFlags & this.webNavigation.LOAD_FLAGS_FROM_EXTERNAL))
               this.userTypedClear++;
 
@@ -433,20 +433,16 @@
       <property name="contentViewerEdit"
                 onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"
                 readonly="true"/>
 
       <property name="contentViewerFile"
                 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"/>
 
       <property name="contentTitle"
                 onget="return this.contentDocument.title;"
                 readonly="true"/>