Bug 647273 - Remove nsIContentUtils and nsIContentUtils2. r=sicking
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 14 Apr 2011 13:58:36 -0700
changeset 68567 863db843fde46a9e34f49d3e61d789b3b5c766d8
parent 68566 4c54cf0d07c1d70600b8834bbbe179f298388ea1
child 68568 657cd15fa85d64e39d6fd7f1307f50daacfbb581
push id99
push usereakhgari@mozilla.com
push dateTue, 24 May 2011 18:03:59 +0000
treeherdermozilla-aurora@26d6981b3d6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs647273
milestone6.0a1
Bug 647273 - Remove nsIContentUtils and nsIContentUtils2. r=sicking
content/base/public/Makefile.in
content/base/public/nsContentUtils.h
content/base/public/nsIContentUtils.h
content/base/src/nsContentUtils.cpp
content/base/src/nsTextFragment.h
docshell/base/nsDocShell.cpp
docshell/base/nsWebNavigationInfo.cpp
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
layout/build/nsLayoutCID.h
layout/build/nsLayoutModule.cpp
modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
widget/tests/Makefile.in
widget/tests/TestChromeMargin.cpp
xpfe/appshell/src/nsXULWindow.cpp
--- a/content/base/public/Makefile.in
+++ b/content/base/public/Makefile.in
@@ -48,17 +48,16 @@ GRE_MODULE	= 1
 EXPORTS		= \
 mozFlushType.h \
 nsIContent.h \
 nsIAttribute.h \
 nsIContentIterator.h \
 nsContentErrors.h \
 nsContentPolicyUtils.h \
 nsContentUtils.h \
-nsIContentUtils.h \
 nsIDocument.h \
 nsIDocumentObserver.h \
 nsIMutationObserver.h \
 nsIMutationObserver2.h \
 nsINameSpaceManager.h \
 nsINode.h \
 nsINodeInfo.h \
 nsINodeList.h \
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -127,16 +127,17 @@ class nsIXTFService;
 class nsIBidiKeyboard;
 #endif
 class nsIMIMEHeaderParam;
 class nsIObserver;
 class nsPresContext;
 class nsIChannel;
 struct nsIntMargin;
 class nsPIDOMWindow;
+class nsIDocumentLoaderFactory;
 
 #ifndef have_PrefChangedFunc_typedef
 typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
 #define have_PrefChangedFunc_typedef
 #endif
 
 namespace mozilla {
 
@@ -1753,16 +1754,28 @@ public:
   static void FlushLayoutForTree(nsIDOMWindow* aWindow);
 
   /**
    * Returns true if content with the given principal is allowed to use XUL
    * and XBL and false otherwise.
    */
   static bool AllowXULXBLForPrincipal(nsIPrincipal* aPrincipal);
 
+  enum ContentViewerType
+  {
+      TYPE_UNSUPPORTED,
+      TYPE_CONTENT,
+      TYPE_PLUGIN,
+      TYPE_UNKNOWN
+  };
+
+  static already_AddRefed<nsIDocumentLoaderFactory>
+  FindInternalContentViewer(const char* aType,
+                            ContentViewerType* aLoaderType = nsnull);
+
 private:
   static PRBool InitializeEventTable();
 
   static nsresult EnsureStringBundle(PropertiesFile aFile);
 
   static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
 
   static nsresult HoldScriptObject(PRUint32 aLangID, void* aObject);
deleted file mode 100644
--- a/content/base/public/nsIContentUtils.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; 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
- * Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * 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 nsIContentUtils_h__
-#define nsIContentUtils_h__
-
-#include "nsIDocumentLoaderFactory.h"
-#include "nsCOMPtr.h"
-#include "nsAString.h"
-#include "nsMargin.h"
-
-class nsIInterfaceRequestor;
-
-// {3682DD99-8560-44f4-9B8F-CCCE9D7B96FB}
-#define NS_ICONTENTUTILS_IID \
-{ 0x3682dd99, 0x8560, 0x44f4, \
-  { 0x9b, 0x8f, 0xcc, 0xce, 0x9d, 0x7b, 0x96, 0xfb } }
-
-class nsIContentUtils : public nsISupports
-{
-public:
-    NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTUTILS_IID)
-    NS_DECL_ISUPPORTS
-
-    virtual PRBool IsSafeToRunScript();
-    virtual PRBool ParseIntMarginValue(const nsAString& aString, nsIntMargin& result);
-
-    enum ContentViewerType
-    {
-        TYPE_UNSUPPORTED,
-        TYPE_CONTENT,
-        TYPE_PLUGIN,
-        TYPE_UNKNOWN
-    };
-
-    virtual already_AddRefed<nsIDocumentLoaderFactory>
-    FindInternalContentViewer(const char* aType,
-                              ContentViewerType* aLoaderType = NULL);
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentUtils, NS_ICONTENTUTILS_IID)
-
-// {c7193287-3e3d-467f-b6da-47b914eb4c83}
-#define NS_ICONTENTUTILS2_IID \
-{ 0xc7193287, 0x3e3d, 0x467f, \
-{ 0xb6, 0xda, 0x47, 0xb9, 0x14, 0xeb, 0x4c, 0x83 } }
-
-class nsIContentUtils2 : public nsISupports
-{
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTUTILS2_IID)
-  NS_DECL_ISUPPORTS
-
-  virtual nsIInterfaceRequestor* GetSameOriginChecker();
-  // Returns NS_OK for same origin, error (NS_ERROR_DOM_BAD_URI) if not.
-  virtual nsresult CheckSameOrigin(nsIChannel *aOldChannel, nsIChannel *aNewChannel);
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentUtils2, NS_ICONTENTUTILS2_IID)
-
-#endif /* nsIContentUtils_h__ */
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -53,17 +53,16 @@
 #include "nsIPrefBranch2.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsIDOMScriptObjectFactory.h"
 #include "nsDOMCID.h"
 #include "nsContentUtils.h"
-#include "nsIContentUtils.h"
 #include "nsIXPConnect.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsINodeInfo.h"
 #include "nsReadableUtils.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNodeList.h"
@@ -6461,33 +6460,19 @@ nsContentUtils::AllowXULXBLForPrincipal(
   nsCOMPtr<nsIURI> princURI;
   aPrincipal->GetURI(getter_AddRefs(princURI));
   
   return princURI &&
          ((sAllowXULXBL_for_file && SchemeIs(princURI, "file")) ||
           IsSitePermAllow(princURI, "allowXULXBL"));
 }
 
-NS_IMPL_ISUPPORTS1(nsIContentUtils, nsIContentUtils)
-
-PRBool
-nsIContentUtils::IsSafeToRunScript()
-{
-  return nsContentUtils::IsSafeToRunScript();
-}
-
-PRBool
-nsIContentUtils::ParseIntMarginValue(const nsAString& aString, nsIntMargin& result)
-{
-  return nsContentUtils::ParseIntMarginValue(aString, result);
-}
-
 already_AddRefed<nsIDocumentLoaderFactory>
-nsIContentUtils::FindInternalContentViewer(const char* aType,
-                                           ContentViewerType* aLoaderType)
+nsContentUtils::FindInternalContentViewer(const char* aType,
+                                          ContentViewerType* aLoaderType)
 {
   if (aLoaderType) {
     *aLoaderType = TYPE_UNSUPPORTED;
   }
 
   // one helper factory, please
   nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
   if (!catMan)
@@ -6501,17 +6486,17 @@ nsIContentUtils::FindInternalContentView
     docFactory = do_GetService(contractID);
     if (docFactory && aLoaderType) {
       if (contractID.EqualsLiteral(CONTENT_DLF_CONTRACTID))
         *aLoaderType = TYPE_CONTENT;
       else if (contractID.EqualsLiteral(PLUGIN_DLF_CONTRACTID))
         *aLoaderType = TYPE_PLUGIN;
       else
       *aLoaderType = TYPE_UNKNOWN;
-    }   
+    }
     return docFactory.forget();
   }
 
 #ifdef MOZ_MEDIA
 #ifdef MOZ_OGG
   if (nsHTMLMediaElement::IsOggEnabled()) {
     for (unsigned int i = 0; i < NS_ARRAY_LENGTH(nsHTMLMediaElement::gOggTypes); ++i) {
       const char* type = nsHTMLMediaElement::gOggTypes[i];
@@ -6539,22 +6524,8 @@ nsIContentUtils::FindInternalContentView
       }
     }
   }
 #endif
 #endif // MOZ_MEDIA
 
   return NULL;
 }
-
-NS_IMPL_ISUPPORTS1(nsIContentUtils2, nsIContentUtils2)
-
-nsIInterfaceRequestor*
-nsIContentUtils2::GetSameOriginChecker()
-{
-  return nsContentUtils::GetSameOriginChecker();
-}
-
-nsresult
-nsIContentUtils2::CheckSameOrigin(nsIChannel *aOldChannel, nsIChannel *aNewChannel)
-{
-  return nsContentUtils::CheckSameOrigin(aOldChannel, aNewChannel);
-}
--- a/content/base/src/nsTextFragment.h
+++ b/content/base/src/nsTextFragment.h
@@ -40,16 +40,17 @@
  * node); if only codepoints below 256 are used, the text is stored as
  * a char*; otherwise the text is stored as a PRUnichar*
  */
 
 #ifndef nsTextFragment_h___
 #define nsTextFragment_h___
 
 #include "nsString.h"
+#include "nsReadableUtils.h"
 #include "nsTraceRefcnt.h"
 class nsString;
 class nsCString;
 
 // XXX should this normalize the code to keep a \u0000 at the end?
 
 // XXX nsTextFragmentPool?
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -44,17 +44,16 @@
 #ifdef MOZ_LOGGING
 // so we can get logging even in release builds (but only for some things)
 #define FORCE_PR_LOG 1
 #endif
 
 #include "nsIBrowserDOMWindow.h"
 #include "nsIComponentManager.h"
 #include "nsIContent.h"
-#include "nsIContentUtils.h"
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMStorageObsolete.h"
 #include "nsIDOMStorage.h"
 #include "nsPIDOMStorage.h"
@@ -6486,21 +6485,19 @@ nsDocShell::CreateAboutBlankContentViewe
   }
 
   // Now make sure we don't think we're in the middle of firing unload after
   // this point.  This will make us fire unload when the about:blank document
   // unloads... but that's ok, more or less.  Would be nice if it fired load
   // too, of course.
   mFiredUnloadEvent = PR_FALSE;
 
-  nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
-  if (!cutils)
-      return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIDocumentLoaderFactory> docFactory = cutils->FindInternalContentViewer("text/html");
+  nsCOMPtr<nsIDocumentLoaderFactory> docFactory =
+      nsContentUtils::FindInternalContentViewer("text/html");
+
   if (docFactory) {
     // generate (about:blank) document to load
     docFactory->CreateBlankDocument(mLoadGroup, aPrincipal,
                                     getter_AddRefs(blankDoc));
     if (blankDoc) {
       // Hack: set the base URI manually, since this document never
       // got Reset() with a channel.
       blankDoc->SetBaseURI(aBaseURI);
@@ -7515,23 +7512,18 @@ nsDocShell::CreateContentViewer(const ch
 nsresult
 nsDocShell::NewContentViewerObj(const char *aContentType,
                                 nsIRequest * request, nsILoadGroup * aLoadGroup,
                                 nsIStreamListener ** aContentHandler,
                                 nsIContentViewer ** aViewer)
 {
     nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
 
-    nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
-    if (!cutils) {
-        return NS_ERROR_FAILURE;
-    }
-
     nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
-        cutils->FindInternalContentViewer(aContentType);
+        nsContentUtils::FindInternalContentViewer(aContentType);
     if (!docLoaderFactory) {
         return NS_ERROR_FAILURE;
     }
 
     // Now create an instance of the content viewer
     // nsLayoutDLF makes the determination if it should be a "view-source" instead of "view"
     nsresult rv = docLoaderFactory->CreateInstance("view",
                                                    aOpenedChannel,
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -34,19 +34,19 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsWebNavigationInfo.h"
 #include "nsIWebNavigation.h"
 #include "nsString.h"
 #include "nsServiceManagerUtils.h"
-#include "nsIContentUtils.h"
 #include "nsIDocumentLoaderFactory.h"
 #include "nsIPluginHost.h"
+#include "nsContentUtils.h"
 
 NS_IMPL_ISUPPORTS1(nsWebNavigationInfo, nsIWebNavigationInfo)
 
 #define CONTENT_DLF_CONTRACT "@mozilla.org/content/document-loader-factory;1"
 #define PLUGIN_DLF_CONTRACT \
     "@mozilla.org/content/plugin/document-loader-factory;1"
 
 nsresult
@@ -105,44 +105,40 @@ nsWebNavigationInfo::IsTypeSupported(con
 
 nsresult
 nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
                                              PRUint32* aIsSupported)
 {
   NS_PRECONDITION(aIsSupported, "Null out param?");
 
 
-  nsCOMPtr<nsIContentUtils> cutils = do_GetService("@mozilla.org/content/contentutils;1");
-  if (!cutils)
-      return NS_ERROR_FAILURE;
-
-  nsIContentUtils::ContentViewerType vtype = nsIContentUtils::TYPE_UNSUPPORTED;
+  nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
 
   nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
-    cutils->FindInternalContentViewer(aType.get(), &vtype);
-  
+    nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
+
   switch (vtype) {
-  case nsIContentUtils::TYPE_UNSUPPORTED:
+  case nsContentUtils::TYPE_UNSUPPORTED:
     *aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
     break;
 
-  case nsIContentUtils::TYPE_PLUGIN:
+  case nsContentUtils::TYPE_PLUGIN:
     *aIsSupported = nsIWebNavigationInfo::PLUGIN;
     break;
 
-  case nsIContentUtils::TYPE_UNKNOWN:
+  case nsContentUtils::TYPE_UNKNOWN:
     *aIsSupported = nsIWebNavigationInfo::OTHER;
     break;
 
-  case nsIContentUtils::TYPE_CONTENT:
+  case nsContentUtils::TYPE_CONTENT:
     PRBool isImage = PR_FALSE;
     mImgLoader->SupportImageWithMimeType(aType.get(), &isImage);
     if (isImage) {
       *aIsSupported = nsIWebNavigationInfo::IMAGE;
     }
     else {
       *aIsSupported = nsIWebNavigationInfo::OTHER;
     }
     break;
   }
-  
+
   return NS_OK;
 }
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -41,17 +41,16 @@
 
 #include "nsWindowWatcher.h"
 #include "nsAutoWindowStateHelper.h"
 
 #include "nsCRT.h"
 #include "nsNetUtil.h"
 #include "nsWWJSUtils.h"
 #include "plstr.h"
-#include "nsIContentUtils.h"
 
 #include "nsIBaseWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocumentLoader.h"
 #include "nsIDocument.h"
@@ -507,19 +506,17 @@ nsWindowWatcher::OpenWindowJSInternal(ns
   nsCOMPtr<nsIURI>                uriToLoad;        // from aUrl, if any
   nsCOMPtr<nsIDocShellTreeOwner>  parentTreeOwner;  // from the parent window, if any
   nsCOMPtr<nsIDocShellTreeItem>   newDocShellItem;  // from the new window
   JSContextAutoPopper             callerContextGuard;
 
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = 0;
 
-  nsCOMPtr<nsIContentUtils> utils =
-    do_GetService("@mozilla.org/content/contentutils;1");
-  if (utils && !utils->IsSafeToRunScript()) {
+  if (!nsContentUtils::IsSafeToRunScript()) {
     return NS_ERROR_FAILURE;
   }
 
   GetWindowTreeOwner(aParent, getter_AddRefs(parentTreeOwner));
 
   if (aUrl) {
     rv = URIfromURL(aUrl, aParent, getter_AddRefs(uriToLoad));
     if (NS_FAILED(rv))
--- a/layout/build/nsLayoutCID.h
+++ b/layout/build/nsLayoutCID.h
@@ -233,24 +233,16 @@
 // {93ad72a6-02cd-4716-9626-d47d5ec275ec}
 #define NS_DOMJSON_CID \
 { 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } }
 
 // {CF7FD51F-ABA2-44C1-9FF0-11F7508EFCD4}
 #define NS_FOCUSMANAGER_CID \
 { 0xcf7fd51f, 0xaba2, 0x44c1, { 0x9f, 0xf0, 0x11, 0xf7, 0x50, 0x8e, 0xfc, 0xd4 } }
 
-// {762C4AE7-B923-422F-B97E-B9BFC1EF7BF0}
-#define NS_ICONTENTUTILS_CID \
-{ 0x762C4AE7, 0xB923, 0x422F, { 0xB9, 0x7E, 0xB9, 0xBF, 0xC1, 0xEF, 0x7B, 0xF0 } }
-
-// {1802442d-a59b-43b8-b8fd-070da5549593}
-#define NS_ICONTENTUTILS2_CID \
-{ 0x1802442d, 0xa59b, 0x43b8, { 0xb8, 0xfd, 0x07, 0x0d, 0xa5, 0x54, 0x95, 0x93 } }
-
 // {1A26A7B7-D06E-4F45-8B45-D7AD60F7A9AB}
 #define INDEXEDDB_MANAGER_CID \
 { 0x1a26a7b7, 0xd06e, 0x4f45, { 0x8b, 0x45, 0xd7, 0xad, 0x60, 0xf7, 0xa9, 0xab } }
 
 #ifdef MOZ_MEDIA
 #define NS_HTMLAUDIOELEMENT_CID                   \
 { /* 1d40026b-4c44-4f6f-b158-26bb5e9c65e9 */      \
  0x1d40026b, 0x4c44, 0x4f6f,                      \
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -89,17 +89,16 @@
 #include "nsSyncLoadService.h"
 #include "nsBox.h"
 #include "nsIFrameTraversal.h"
 #include "nsLayoutCID.h"
 #include "nsILanguageAtomService.h"
 #include "nsStyleSheetService.h"
 #include "nsXULPopupManager.h"
 #include "nsFocusManager.h"
-#include "nsIContentUtils.h"
 #include "ThirdPartyUtil.h"
 #include "mozilla/Services.h"
 
 #include "nsIEventListenerService.h"
 #include "nsIFrameMessageManager.h"
 
 // Transformiix stuff
 #include "nsXPathEvaluator.h"
@@ -575,19 +574,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDoc
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoadService)
 MAKE_CTOR(CreatePluginDocument,           nsIDocument,                 NS_NewPluginDocument)
 #ifdef MOZ_MEDIA
 MAKE_CTOR(CreateVideoDocument,            nsIDocument,                 NS_NewVideoDocument)
 #endif
 MAKE_CTOR(CreateFocusManager,             nsIFocusManager,      NS_NewFocusManager)
 
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIContentUtils)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIContentUtils2)
-
 MAKE_CTOR(CreateCanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D, NS_NewCanvasRenderingContext2D)
 MAKE_CTOR(CreateCanvasRenderingContextWebGL, nsIDOMWebGLRenderingContext, NS_NewCanvasRenderingContextWebGL)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURI)
 
 // views are not refcounted, so this is the same as
@@ -863,18 +859,16 @@ NS_DEFINE_NAMED_CID(NS_HTMLEDITOR_CID);
 NS_DEFINE_NAMED_CID(NS_HTMLEDITOR_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_EDITORCONTROLLER_CID);
 NS_DEFINE_NAMED_CID(NS_EDITORCOMMANDTABLE_CID);
 NS_DEFINE_NAMED_CID(NS_TEXTSERVICESDOCUMENT_CID);
 NS_DEFINE_NAMED_CID(NS_GEOLOCATION_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID);
 NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID);
-NS_DEFINE_NAMED_CID(NS_ICONTENTUTILS_CID);
-NS_DEFINE_NAMED_CID(NS_ICONTENTUTILS2_CID);
 NS_DEFINE_NAMED_CID(CSPSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_EVENTLISTENERSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_GLOBALMESSAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_PARENTPROCESSMESSAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_CHILDPROCESSMESSAGEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NSCHANNELPOLICY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTSECURITYMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_PRINCIPAL_CID);
@@ -1014,18 +1008,16 @@ static const mozilla::Module::CIDEntry k
   { &kNS_HTMLEDITOR_CID, false, NULL, nsHTMLEditorConstructor },
 #endif
   { &kNS_EDITORCONTROLLER_CID, false, NULL, nsEditorControllerConstructor },
   { &kNS_EDITORCOMMANDTABLE_CID, false, NULL, nsEditorCommandTableConstructor },
   { &kNS_TEXTSERVICESDOCUMENT_CID, false, NULL, nsTextServicesDocumentConstructor },
   { &kNS_GEOLOCATION_SERVICE_CID, false, NULL, nsGeolocationServiceConstructor },
   { &kNS_GEOLOCATION_CID, false, NULL, nsGeolocationConstructor },
   { &kNS_FOCUSMANAGER_CID, false, NULL, CreateFocusManager },
-  { &kNS_ICONTENTUTILS_CID, false, NULL, nsIContentUtilsConstructor },
-  { &kNS_ICONTENTUTILS2_CID, false, NULL, nsIContentUtils2Constructor },
   { &kCSPSERVICE_CID, false, NULL, CSPServiceConstructor },
   { &kNS_EVENTLISTENERSERVICE_CID, false, NULL, CreateEventListenerService },
   { &kNS_GLOBALMESSAGEMANAGER_CID, false, NULL, CreateGlobalMessageManager },
   { &kNS_PARENTPROCESSMESSAGEMANAGER_CID, false, NULL, CreateParentMessageManager },
   { &kNS_CHILDPROCESSMESSAGEMANAGER_CID, false, NULL, CreateChildMessageManager },
   { &kNSCHANNELPOLICY_CID, false, NULL, nsChannelPolicyConstructor },
   { &kNS_SCRIPTSECURITYMANAGER_CID, false, NULL, Construct_nsIScriptSecurityManager },
   { &kNS_PRINCIPAL_CID, false, NULL, nsPrincipalConstructor },
@@ -1159,18 +1151,16 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/editor/htmleditor;1", &kNS_HTMLEDITOR_CID },
 #endif
   { "@mozilla.org/editor/editorcontroller;1", &kNS_EDITORCONTROLLER_CID },
   { "", &kNS_EDITORCOMMANDTABLE_CID },
   { "@mozilla.org/textservices/textservicesdocument;1", &kNS_TEXTSERVICESDOCUMENT_CID },
   { "@mozilla.org/geolocation/service;1", &kNS_GEOLOCATION_SERVICE_CID },
   { "@mozilla.org/geolocation;1", &kNS_GEOLOCATION_CID },
   { "@mozilla.org/focus-manager;1", &kNS_FOCUSMANAGER_CID },
-  { "@mozilla.org/content/contentutils;1", &kNS_ICONTENTUTILS_CID },
-  { "@mozilla.org/content/contentutils2;1", &kNS_ICONTENTUTILS2_CID },
   { CSPSERVICE_CONTRACTID, &kCSPSERVICE_CID },
   { NS_EVENTLISTENERSERVICE_CONTRACTID, &kNS_EVENTLISTENERSERVICE_CID },
   { NS_GLOBALMESSAGEMANAGER_CONTRACTID, &kNS_GLOBALMESSAGEMANAGER_CID },
   { NS_PARENTPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_PARENTPROCESSMESSAGEMANAGER_CID },
   { NS_CHILDPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_CHILDPROCESSMESSAGEMANAGER_CID },
   { NSCHANNELPOLICY_CONTRACTID, &kNSCHANNELPOLICY_CID },
   { NS_SCRIPTSECURITYMANAGER_CONTRACTID, &kNS_SCRIPTSECURITYMANAGER_CID },
   { NS_GLOBAL_CHANNELEVENTSINK_CONTRACTID, &kNS_SCRIPTSECURITYMANAGER_CID },
--- a/modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
+++ b/modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
@@ -49,20 +49,20 @@
 #include "nsNetCID.h"
 #include "nsPluginLogging.h"
 #include "nsIURI.h"
 #include "nsPluginHost.h"
 #include "nsIByteRangeRequest.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIInputStreamTee.h"
 #include "nsPrintfCString.h"
-#include "nsIContentUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIDocument.h"
 #include "nsIWebNavigation.h"
+#include "nsContentUtils.h"
 
 #define MAGIC_REQUEST_CONTEXT 0x01020304
 
 // nsPluginByteRangeStreamListener
 
 class nsPluginByteRangeStreamListener
   : public nsIStreamListener
   , public nsIInterfaceRequestor
@@ -1418,19 +1418,17 @@ nsPluginStreamListenerPeer::AsyncOnChann
     }
     if (responseStatus == 307) {
       nsCAutoString method;
       rv = oldHttpChannel->GetRequestMethod(method);
       if (NS_FAILED(rv)) {
         return rv;
       }
       if (method.EqualsLiteral("POST")) {
-        nsCOMPtr<nsIContentUtils2> contentUtils2 = do_GetService("@mozilla.org/content/contentutils2;1");
-        NS_ENSURE_TRUE(contentUtils2, NS_ERROR_FAILURE);
-        rv = contentUtils2->CheckSameOrigin(oldChannel, newChannel);
+        rv = nsContentUtils::CheckSameOrigin(oldChannel, newChannel);
         if (NS_FAILED(rv)) {
           return rv;
         }
       }
     }
   }
 
   // Fall back to channel event sink for window.
--- a/widget/tests/Makefile.in
+++ b/widget/tests/Makefile.in
@@ -42,23 +42,27 @@ VPATH		= @srcdir@
 relativesrcdir  = widget/tests
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE          = test_widget
 XPCSHELL_TESTS  = unit
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
+
 ifdef NS_ENABLE_TSF
 #Test disabled because it uses the internal string APIs incorrectly (see bug 582863)
 #CPP_UNIT_TESTS += TestWinTSF.cpp  \
 #                  $(NULL)
 endif
-CPP_UNIT_TESTS += TestChromeMargin.cpp  \
-                  $(NULL)
+
+# Test disabled because it requires the internal API.  Re-enabling this test is
+# bug 652123.
+#CPP_UNIT_TESTS += TestChromeMargin.cpp  \
+#                 $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES =
 
 _CHROME_FILES =	test_bug343416.xul \
 		test_bug429954.xul \
--- a/widget/tests/TestChromeMargin.cpp
+++ b/widget/tests/TestChromeMargin.cpp
@@ -32,21 +32,26 @@
  * 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 ***** */
 
 /* This tests the margin parsing functionality in nsAttrValue.cpp, which
- * is accessible via nsIContentUtils, and is used in setting chromemargins
+ * is accessible via nsContentUtils, and is used in setting chromemargins
  * to widget windows. It's located here due to linking issues in the
  * content directory.
  */
 
+/* This test no longer compiles now that we've removed nsIContentUtils (bug
+ * 647273).  We need to be internal code in order to include nsContentUtils.h,
+ * but defining MOZILLA_INTERNAL_API is not enough to make us internal.
+ */
+
 #include "TestHarness.h"
 
 #ifndef MOZILLA_INTERNAL_API
 // some of the includes make use of internal string types
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
@@ -56,17 +61,17 @@ class nsAFlatString;
 class nsAFlatCString;
 class nsAdoptingString;
 class nsAdoptingCString;
 class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nscore.h"
-#include "nsIContentUtils.h"
+#include "nsContentUtils.h"
 
 #ifndef MOZILLA_INTERNAL_API
 #undef nsString_h___
 #undef nsAString_h___
 #undef nsReadableUtils_h___
 #endif
 
 struct DATA {
@@ -110,29 +115,23 @@ const DATA Data[] = {
   { SHOULD_PASS, "2147483647,2147483647,2147483647,2147483647", 2147483647, 2147483647, 2147483647, 2147483647 },
   { SHOULD_PASS, "-2147483647,3,2,1000", -2147483647, 3, 2, 1000 },
   { SHOULD_FAIL, "2147483648,3,2,1000", 1, 3, 2, 1000 },
   { 0, nsnull, 0, 0, 0, 0 }
 };
 
 void DoAttrValueTest()
 {
-  nsCOMPtr<nsIContentUtils> utils =
-   do_GetService("@mozilla.org/content/contentutils;1");
-
-  if (!utils)
-    fail("No nsIContentUtils");
-
   int idx = -1;
   bool didFail = false;
   while (Data[++idx].margins) {
     nsAutoString str;
     str.AssignLiteral(Data[idx].margins);
     nsIntMargin values(99,99,99,99);
-    bool result = utils->ParseIntMarginValue(str, values);
+    bool result = nsContentUtils::ParseIntMarginValue(str, values);
 
     // if the parse fails
     if (!result) {
       if (Data[idx].shouldfail)
         continue;
       fail(Data[idx].margins);
       didFail = true;
       printf("*1\n");
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -87,17 +87,16 @@
 #include "nsIDOMDocumentView.h"
 #include "nsIDOMViewCSS.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsITimelineService.h"
 #include "nsAppShellCID.h"
 #include "nsReadableUtils.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
-#include "nsIContentUtils.h"
 
 #include "nsWebShellWindow.h" // get rid of this one, too...
 
 #include "prenv.h"
 
 #define SIZEMODE_NORMAL     NS_LITERAL_STRING("normal")
 #define SIZEMODE_MAXIMIZED  NS_LITERAL_STRING("maximized")
 #define SIZEMODE_MINIMIZED  NS_LITERAL_STRING("minimized")
@@ -1387,20 +1386,18 @@ void nsXULWindow::SyncAttributesToWidget
   // "hidechrome" attribute
   nsresult rv = windowElement->GetAttribute(NS_LITERAL_STRING("hidechrome"), attr);
   if (NS_SUCCEEDED(rv) && attr.EqualsLiteral("true")) {
     mWindow->HideWindowChrome(PR_TRUE);
   }
 
   // "chromemargin" attribute
   nsIntMargin margins;
-  nsCOMPtr<nsIContentUtils> cutils =
-    do_GetService("@mozilla.org/content/contentutils;1");
   rv = windowElement->GetAttribute(NS_LITERAL_STRING("chromemargin"), attr);
-  if (NS_SUCCEEDED(rv) && cutils && cutils->ParseIntMarginValue(attr, margins)) {
+  if (NS_SUCCEEDED(rv) && nsContentUtils::ParseIntMarginValue(attr, margins)) {
     mWindow->SetNonClientMargins(margins);
   }
 
   // "accelerated" attribute
   PRBool isAccelerated;
   rv = windowElement->HasAttribute(NS_LITERAL_STRING("accelerated"), &isAccelerated);
   if (NS_SUCCEEDED(rv)) {
     mWindow->SetAcceleratedRendering(isAccelerated);