Move nsIDocCharset out of intl/chardet into nsIDocShell, Bug 713825, r=bz
authorSimon Montagu <smontagu@smontagu.org>
Tue, 24 Jan 2012 11:52:04 +0200
changeset 88006 1cbdfc84d7e30a602e3d30ae31744f9e796a19f6
parent 88005 388edf50e323695b2254c775ddd63a8f23f23f50
child 88007 57f0b07c2dc5108e3c1fb477dc4e134e3161158b
push id129
push userffxbld
push dateFri, 20 Apr 2012 19:40:49 +0000
treeherdermozilla-release@5bcfa0da3be9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs713825
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Move nsIDocCharset out of intl/chardet into nsIDocShell, Bug 713825, r=bz
browser/base/content/browser.js
docshell/base/Makefile.in
docshell/base/nsIDocCharset.idl
docshell/base/nsIDocShell.idl
docshell/test/Makefile.in
docshell/test/test_bug713825.html
dom/base/nsGlobalWindow.cpp
intl/chardet/public/Makefile.in
intl/chardet/public/nsIDocCharset.idl
mobile/xul/chrome/content/content.js
toolkit/components/viewsource/content/viewSource.js
uriloader/prefetch/nsPrefetchService.cpp
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6016,18 +6016,17 @@ function SetForcedDetector(doReload)
 
 function SetForcedCharset(charset)
 {
     BrowserSetForcedCharacterSet(charset);
 }
 
 function BrowserSetForcedCharacterSet(aCharset)
 {
-  var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
-  docCharset.charset = aCharset;
+  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;
--- a/docshell/base/Makefile.in
+++ b/docshell/base/Makefile.in
@@ -64,16 +64,17 @@ XPIDLSRCS = \
   nsIDocShellTreeItem.idl \
   nsIDocShellTreeNode.idl \
   nsIDocShellTreeOwner.idl \
   nsIDocShellHistory.idl \
   nsIGlobalHistory2.idl \
   nsIMarkupDocumentViewer.idl \
   nsIScrollable.idl \
   nsITextScroll.idl \
+  nsIDocCharset.idl \
   nsIWebNavigation.idl \
   nsIWebNavigationInfo.idl \
   nsIContentViewer.idl \
   nsIContentViewerEdit.idl \
   nsIContentViewerFile.idl \
   nsIURIFixup.idl \
   nsIEditorDocShell.idl \
   nsIWebPageDescriptor.idl \
new file mode 100644
--- /dev/null
+++ b/docshell/base/nsIDocCharset.idl
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+/**
+ * The functionality of the nsIDocCharset interface has been incorporated into
+ * nsIDocShell.
+ *
+ * This is an empty interface for backwards compatibility that will go away at
+ * some point in the future
+ *
+ */
+
+[scriptable, uuid(c3faaf6e-40f0-11e1-95fc-6c626d69675c)]
+interface nsIDocCharset : nsISupports
+{};
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -67,17 +67,17 @@ interface nsIRequest;
 interface nsISHEntry;
 interface nsILayoutHistoryState;
 interface nsISecureBrowserUI;
 interface nsIDOMStorage;
 interface nsIPrincipal;
 interface nsIWebBrowserPrint;
 interface nsIVariant;
 
-[scriptable, uuid(0666adf8-8738-4ca7-a917-0348f47d2f40)]
+[scriptable, uuid(0615d1a6-313f-11e1-a043-6c626d69675c)]
 interface nsIDocShell : nsISupports
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing	this interface.  If it can't be loaded here
    * however, the URL dispatcher will go through its normal process of content
    * loading.
    *
@@ -548,9 +548,45 @@ interface nsIDocShell : nsISupports
    */
   attribute boolean isAppTab;
 
   /**
    * Create a new about:blank document and content viewer.
    * @param aPrincipal the principal to use for the new document.
    */
   void createAboutBlankContentViewer(in nsIPrincipal aPrincipal);
+
+  /**
+   * The charset attribute allows the user to view, hint, and set which
+   * converter is used to read the document's data.
+   *
+   * <P>Inside Mozilla all text is encoded as Unicode. By standardizing  
+   * on Unicode every piece of code that handles characters no longer 
+   * needs to: 
+   *
+   *     Have access to a character encoding parameter.
+   *     Ask is the data stateful?
+   *     Ask is the data single byte?
+   *     Ask is the data multi-byte?
+   *     If multi-byte: have access to a routine that can
+   *         determine how many bytes in the current character.
+   *
+   * When the document is read in a converter is used to convert 
+   * the document's data to Unicode.
+   *
+   * The charset attribute provides the ability to:
+   *
+   *   See what converter was used when inputting the documents
+   *   data.
+   *
+   *   Override the character set for documents where the specified 
+   *   fallback, or auto-detected character set is incorrect
+   *
+   * Get/sets the encoding (converter) used to read the 
+   * 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;
 };
--- a/docshell/test/Makefile.in
+++ b/docshell/test/Makefile.in
@@ -120,16 +120,17 @@ include $(topsrcdir)/config/rules.mk
 		file_bug669671.sjs \
 		test_bug675587.html \
 		test_bfcache_plus_hash.html \
 		test_bug680257.html \
 		file_bug680257.html \
 		test_bug691547.html \
 		bug691547_frame.html \
 		test_bug694612.html \
+		test_bug713825.html \
 		$(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 _TEST_FILES += \
 		test_bug511449.html \
 		file_bug511449.html \
 		$(NULL)
 endif
new file mode 100644
--- /dev/null
+++ b/docshell/test/test_bug713825.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=713825
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 713825</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=713825">Mozilla Bug 713825</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** 
+ * Test for Bug 713825 
+ *  test that nsIDocCharset still works backward compatibly
+ */
+netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+var Ci = Components.interfaces;
+var docShell = window.QueryInterface(Ci.nsIInterfaceRequestor).
+                      getInterface(Ci.nsIWebNavigation).
+                      QueryInterface(Ci.nsIDocShell);
+
+var charset1 = docShell.charset;
+var charset2 = docShell.QueryInterface(Ci.nsIDocCharset).charset;
+var charset3 = window.QueryInterface(Ci.nsIInterfaceRequestor).
+                      getInterface(Ci.nsIDocCharset).charset;
+
+/* if we get here without throwing and the three charsets are equal, all is OK */
+is(charset1, charset2, "QI'd nsIDocCharset.charset should equal nsIDocShell.charset");
+is(charset1, charset3, "getInterface'd nsIDocCharset.charset should equal nsIDocShell.charset");
+
+</script>
+</pre>
+</body>
+</html>
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8313,16 +8313,17 @@ nsGlobalWindow::GetInterface(const nsIID
   *aSink = nsnull;
 
   if (aIID.Equals(NS_GET_IID(nsIDocCharset))) {
     FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
 
     if (mDocShell) {
       nsCOMPtr<nsIDocCharset> docCharset(do_QueryInterface(mDocShell));
       if (docCharset) {
+        NS_WARNING("Using deprecated nsIDocCharset: use nsIDocShell.GetCharset() instead ");
         *aSink = docCharset;
         NS_ADDREF(((nsISupports *) *aSink));
       }
     }
   }
   else if (aIID.Equals(NS_GET_IID(nsIWebNavigation))) {
     FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED);
 
--- a/intl/chardet/public/Makefile.in
+++ b/intl/chardet/public/Makefile.in
@@ -41,17 +41,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= chardet
 
 XPIDLSRCS       = \
                 nsIDocumentCharsetInfo.idl \
-                nsIDocCharset.idl \
 		$(NULL)
 
 EXPORTS		= \
 		nsDetectionConfident.h \
 		nsDocumentCharsetInfoCID.h \
 		nsICharsetDetectionObserver.h \
 		nsICharsetDetector.h \
 		nsIStringCharsetDetector.h \
deleted file mode 100644
--- a/intl/chardet/public/nsIDocCharset.idl
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** 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) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Brian Stell <bstell@netscape.com>
- *
- * 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 "nsISupports.idl"
-
-/**
- * The nsIDocCharset interface allows the user to view, 
- * hint, and set which converter is used to read the document's 
- * data.
- *
- * <P>Inside Mozilla all text is encoded as Unicode. By standardizing  
- * on Unicode every piece of code that handles characters no longer 
- * needs to: 
- *
- *     Have access to a character encoding parameter.
- *     Ask is the data stateful?
- *     Ask is the data single byte?
- *     Ask is the data multi-byte?
- *     If multi-byte: have access to a routine that can
- *         determine how many bytes in the current character.
- *
- * When the document is read in a converter is used to convert 
- * the document's data to Unicode.
- *
- * nsIDocCharset provides the ability to:
- *
- *   See what converter was used when inputting the documents
- *   data.
- *
- *   Override the character set for documents where the specified 
- *   fallback, or auto-detected character set is incorrect
- *
- */
-[scriptable, uuid(9c18bb4e-1dd1-11b2-bf91-9cc82c275823)]
-interface nsIDocCharset : nsISupports
-{
-    
-    /**
-     * Get/sets the encoding (converter) used to read the 
-     * 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;
-
-};
-
-
--- a/mobile/xul/chrome/content/content.js
+++ b/mobile/xul/chrome/content/content.js
@@ -590,18 +590,17 @@ let Content = {
         let manifestURI = Services.io.newURI(json.manifest, json.charset, currentURI);
         let updateService = Cc["@mozilla.org/offlinecacheupdate-service;1"]
                             .getService(Ci.nsIOfflineCacheUpdateService);
         updateService.scheduleUpdate(manifestURI, currentURI, content);
         break;
       }
 
       case "Browser:SetCharset": {
-        let docCharset = docShell.QueryInterface(Ci.nsIDocCharset);
-        docCharset.charset = json.charset;
+        docShell.charset = json.charset;
 
         let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
         webNav.reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
         break;
       }
 
       case "Browser:CanCaptureMouse": {
         sendAsyncMessage("Browser:CanCaptureMouse:Return", {
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -159,18 +159,17 @@ function viewSource(url)
       }
     }
     // If the document had a forced charset, set it here also
     if (window.arguments.length >= 5) {
       arg = window.arguments[4];
 
       try {
         if (arg === true) {
-          var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
-          docCharset.charset = charset;
+          gBrowser.docShell.charset = charset;
         }
       } catch (ex) {
         // Ignore the failure and keep processing arguments...
       }
     }
 
     // Get any specified line to jump to.
     if (window.arguments.length >= 4) {
@@ -711,18 +710,17 @@ function highlightSyntax()
 
   gPageLoader.loadPage(gPageLoader.currentDescriptor, gPageLoader.DISPLAY_NORMAL);
 }
 
 // Fix for bug 136322: this function overrides the function in
 // browser.js to call PageLoader.loadPage() instead of BrowserReloadWithFlags()
 function BrowserSetForcedCharacterSet(aCharset)
 {
-  var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
-  docCharset.charset = aCharset;
+  gBrowser.docShell.charset = aCharset;
   if (isHistoryEnabled()) {
     gPageLoader.loadPage(gPageLoader.currentDescriptor,
                          gPageLoader.DISPLAY_NORMAL);
   } else {
     gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
   }
 }
 
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -36,17 +36,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsPrefetchService.h"
 #include "nsICacheSession.h"
 #include "nsICacheService.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsIObserverService.h"
-#include "nsIDocCharset.h"
 #include "nsIWebProgress.h"
 #include "nsCURILoader.h"
 #include "nsICachingChannel.h"
 #include "nsICacheVisitor.h"
 #include "nsIHttpChannel.h"
 #include "nsIURL.h"
 #include "nsISimpleEnumerator.h"
 #include "nsNetUtil.h"