Bug 940717 - Unify the IsChromeURI functions we have in various places - r=ehsan
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 20 Nov 2013 11:29:03 -0500
changeset 171196 70b5b1f081f231880326ab0223dea8d89d15b90c
parent 171195 d8cd50781edc8ce156693f9a8bb946ae059fd252
child 171197 b855b6c36a6af496d6931b6c856eca4f2cfe6de3
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs940717
milestone28.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
Bug 940717 - Unify the IsChromeURI functions we have in various places - r=ehsan
chrome/src/nsChromeRegistry.cpp
content/xbl/src/nsXBLDocumentInfo.cpp
content/xbl/src/nsXBLPrototypeResources.cpp
content/xul/document/src/XULDocument.cpp
dom/base/URL.cpp
dom/base/URL.h
layout/style/Loader.cpp
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -22,18 +22,20 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMLocation.h"
 #include "nsIDOMWindowCollection.h"
 #include "nsIDOMWindow.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsIScriptError.h"
 #include "nsIWindowMediator.h"
+#include "mozilla/dom/URL.h"
 
 nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
+using mozilla::dom::IsChromeURI;
 
 ////////////////////////////////////////////////////////////////////////////////
 
 void
 nsChromeRegistry::LogMessage(const char* aMsg, ...)
 {
   nsCOMPtr<nsIConsoleService> console 
     (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
@@ -366,24 +368,16 @@ nsChromeRegistry::FlushSkinCaches()
   nsCOMPtr<nsIObserverService> obsSvc =
     mozilla::services::GetObserverService();
   NS_ASSERTION(obsSvc, "Couldn't get observer service.");
 
   obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
                           NS_CHROME_FLUSH_SKINS_TOPIC, nullptr);
 }
 
-static bool IsChromeURI(nsIURI* aURI)
-{
-    bool isChrome=false;
-    if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
-        return true;
-    return false;
-}
-
 // XXXbsmedberg: move this to windowmediator
 nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
 {
   // Deal with our subframes first.
   nsCOMPtr<nsIDOMWindowCollection> frames;
   aWindow->GetFrames(getter_AddRefs(frames));
   uint32_t length;
   frames->GetLength(&length);
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -28,19 +28,21 @@
 #include "nsCxPusher.h"
 #include "nsDOMJSUtils.h"
 #include "mozilla/Services.h"
 #include "xpcpublic.h"
 #include "mozilla/scache/StartupCache.h"
 #include "mozilla/scache/StartupCacheUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/URL.h"
 
+using namespace mozilla;
 using namespace mozilla::scache;
-using namespace mozilla;
+using namespace mozilla::dom;
 
 static const char kXBLCachePrefix[] = "xblcache";
 
 class nsXBLDocGlobalObject : public nsISupports
 {
 public:
   nsXBLDocGlobalObject(nsXBLDocumentInfo *aGlobalObjectOwner);
 
@@ -277,24 +279,16 @@ nsXBLDocGlobalObject::GetPrincipal()
 
   nsCOMPtr<nsIDocument> document = docInfo->GetDocument();
   if (!document)
     return nullptr;
 
   return document->NodePrincipal();
 }
 
-static bool IsChromeURI(nsIURI* aURI)
-{
-  bool isChrome = false;
-  if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)))
-      return isChrome;
-  return false;
-}
-
 /* Implementation file */
 
 static bool
 TraverseProtos(nsHashKey *aKey, void *aData, void* aClosure)
 {
   nsCycleCollectionTraversalCallback *cb = 
     static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
   nsXBLPrototypeBinding *proto = static_cast<nsXBLPrototypeBinding*>(aData);
--- a/content/xbl/src/nsXBLPrototypeResources.cpp
+++ b/content/xbl/src/nsXBLPrototypeResources.cpp
@@ -11,16 +11,19 @@
 #include "nsXBLPrototypeResources.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsIDocumentObserver.h"
 #include "mozilla/css/Loader.h"
 #include "nsIURI.h"
 #include "nsLayoutCID.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsStyleSet.h"
+#include "mozilla/dom/URL.h"
+
+using mozilla::dom::IsChromeURI;
 
 nsXBLPrototypeResources::nsXBLPrototypeResources(nsXBLPrototypeBinding* aBinding)
 {
   MOZ_COUNT_CTOR(nsXBLPrototypeResources);
 
   mLoader = new nsXBLResourceLoader(aBinding, this);
   NS_IF_ADDREF(mLoader);
 }
@@ -52,24 +55,16 @@ nsXBLPrototypeResources::LoadResources(b
 
 void
 nsXBLPrototypeResources::AddResourceListener(nsIContent* aBoundElement) 
 {
   if (mLoader)
     mLoader->AddResourceListener(aBoundElement);
 }
 
-static bool IsChromeURI(nsIURI* aURI)
-{
-  bool isChrome=false;
-  if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
-    return true;
-  return false;
-}
-
 nsresult
 nsXBLPrototypeResources::FlushSkinSheets()
 {
   if (mStyleSheetList.Length() == 0)
     return NS_OK;
 
   nsCOMPtr<nsIDocument> doc =
     mLoader->mBinding->XBLDocumentInfo()->GetDocument();
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -85,35 +85,28 @@
 #include "nsURILoader.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ProcessingInstruction.h"
 #include "mozilla/dom/XULDocumentBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsTextNode.h"
 #include "nsJSUtils.h"
+#include "mozilla/dom/URL.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 //----------------------------------------------------------------------
 //
 // CIDs
 //
 
 static NS_DEFINE_CID(kParserCID,                 NS_PARSER_CID);
 
-static bool IsChromeURI(nsIURI* aURI)
-{
-    bool isChrome = false;
-    if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
-        return true;
-    return false;
-}
-
 static bool IsOverlayAllowed(nsIURI* aURI)
 {
     bool canOverlay = false;
     if (NS_SUCCEEDED(aURI->SchemeIs("about", &canOverlay)) && canOverlay)
         return true;
     if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &canOverlay)) && canOverlay)
         return true;
     return false;
--- a/dom/base/URL.cpp
+++ b/dom/base/URL.cpp
@@ -404,10 +404,18 @@ URL::GetHash(nsString& aHash) const
 }
 
 void
 URL::SetHash(const nsAString& aHash)
 {
   mURI->SetRef(NS_ConvertUTF16toUTF8(aHash));
 }
 
+bool IsChromeURI(nsIURI* aURI)
+{
+  bool isChrome = false;
+  if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)))
+      return isChrome;
+  return false;
+}
+
 }
 }
--- a/dom/base/URL.h
+++ b/dom/base/URL.h
@@ -125,12 +125,14 @@ private:
                                       nsString& aResult,
                                       ErrorResult& aError);
 
   nsCOMPtr<nsIURI> mURI;
 
   friend class mozilla::dom::workers::URLProxy;
 };
 
+bool IsChromeURI(nsIURI* aURI);
+
 }
 }
 
 #endif /* URL_h___ */
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -43,16 +43,17 @@
 #include "nsICSSLoaderObserver.h"
 #include "nsCSSParser.h"
 #include "mozilla/css/ImportRule.h"
 #include "nsThreadUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIThreadInternal.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsINetworkSeer.h"
+#include "mozilla/dom/URL.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPrototypeCache.h"
 #endif
 
 #include "nsIMediaList.h"
 #include "nsIDOMStyleSheet.h"
 #include "nsError.h"
@@ -937,26 +938,16 @@ SheetLoadData::OnStreamComplete(nsIUnich
   mSheet->SetURIs(channelURI, originalURI, channelURI);
 
   bool completed;
   result = mLoader->ParseSheet(aBuffer, this, completed);
   NS_ASSERTION(completed || !mSyncLoad, "sync load did not complete");
   return result;
 }
 
-#ifdef MOZ_XUL
-static bool IsChromeURI(nsIURI* aURI)
-{
-  NS_ASSERTION(aURI, "Have to pass in a URI");
-  bool isChrome = false;
-  aURI->SchemeIs("chrome", &isChrome);
-  return isChrome;
-}
-#endif
-
 bool
 Loader::IsAlternate(const nsAString& aTitle, bool aHasAlternateRel)
 {
   // A sheet is alternate if it has a nonempty title that doesn't match the
   // currently selected style set.  But if there _is_ no currently selected
   // style set, the sheet wasn't marked as an alternate explicitly, and aTitle
   // is nonempty, we should select the style set corresponding to aTitle, since
   // that's a preferred sheet.