Bug 1290276 Part 1 - Make LoadResources() return bool directly. r=heycam
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 05 Jun 2017 14:29:31 +0800
changeset 411105 002da609b9a4eef7a04ad4b4fb78828c37a42c79
parent 411104 4104db6e97c8420ee9b0001ea83e1a1cbb3cf551
child 411106 b47e827616c4ae4549f865729bf421d63d7f3e01
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1290276
milestone55.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 1290276 Part 1 - Make LoadResources() return bool directly. r=heycam MozReview-Commit-ID: 4z3cHiWXMAh
dom/xbl/nsXBLPrototypeBinding.cpp
dom/xbl/nsXBLPrototypeResources.cpp
dom/xbl/nsXBLPrototypeResources.h
dom/xbl/nsXBLResourceLoader.cpp
dom/xbl/nsXBLResourceLoader.h
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -228,19 +228,17 @@ nsXBLPrototypeBinding::GetAllowScripts()
 {
   return mXBLDocInfoWeak->GetScriptAccess();
 }
 
 bool
 nsXBLPrototypeBinding::LoadResources()
 {
   if (mResources) {
-    bool result;
-    mResources->LoadResources(&result);
-    return result;
+    return mResources->LoadResources();
   }
 
   return true;
 }
 
 nsresult
 nsXBLPrototypeBinding::AddResource(nsIAtom* aResourceType, const nsAString& aSrc)
 {
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -42,23 +42,24 @@ nsXBLPrototypeResources::~nsXBLPrototype
 
 void
 nsXBLPrototypeResources::AddResource(nsIAtom* aResourceType, const nsAString& aSrc)
 {
   if (mLoader)
     mLoader->AddResource(aResourceType, aSrc);
 }
 
-void
-nsXBLPrototypeResources::LoadResources(bool* aResult)
+bool
+nsXBLPrototypeResources::LoadResources()
 {
-  if (mLoader)
-    mLoader->LoadResources(aResult);
-  else
-    *aResult = true; // All resources loaded.
+  if (mLoader) {
+    return mLoader->LoadResources();
+  }
+
+  return true; // All resources loaded.
 }
 
 void
 nsXBLPrototypeResources::AddResourceListener(nsIContent* aBoundElement)
 {
   if (mLoader)
     mLoader->AddResourceListener(aBoundElement);
 }
--- a/dom/xbl/nsXBLPrototypeResources.h
+++ b/dom/xbl/nsXBLPrototypeResources.h
@@ -24,17 +24,17 @@ class CSSStyleSheet;
 // The XBLPrototypeResources class
 
 class nsXBLPrototypeResources
 {
 public:
   explicit nsXBLPrototypeResources(nsXBLPrototypeBinding* aBinding);
   ~nsXBLPrototypeResources();
 
-  void LoadResources(bool* aResult);
+  bool LoadResources();
   void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
   void AddResourceListener(nsIContent* aElement);
   nsresult FlushSkinSheets();
 
   nsresult Write(nsIObjectOutputStream* aStream);
 
   void Traverse(nsCycleCollectionTraversalCallback &cb);
   void Unlink();
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -76,29 +76,27 @@ nsXBLResourceLoader::nsXBLResourceLoader
 {
 }
 
 nsXBLResourceLoader::~nsXBLResourceLoader()
 {
   delete mResourceList;
 }
 
-void
-nsXBLResourceLoader::LoadResources(bool* aResult)
+bool
+nsXBLResourceLoader::LoadResources()
 {
   mInLoadResourcesFunc = true;
 
   if (mLoadingResources) {
-    *aResult = (mPendingSheets == 0);
     mInLoadResourcesFunc = false;
-    return;
+    return mPendingSheets == 0;
   }
 
   mLoadingResources = true;
-  *aResult = true;
 
   // Declare our loaders.
   nsCOMPtr<nsIDocument> doc = mBinding->XBLDocumentInfo()->GetDocument();
 
   mozilla::css::Loader* cssLoader = doc->CSSLoader();
   nsIURI *docURL = doc->GetDocumentURI();
   nsIPrincipal* docPrincipal = doc->NodePrincipal();
 
@@ -149,22 +147,23 @@ nsXBLResourceLoader::LoadResources(bool*
       {
         rv = cssLoader->LoadSheet(url, false, docPrincipal, EmptyCString(), this);
         if (NS_SUCCEEDED(rv))
           ++mPendingSheets;
       }
     }
   }
 
-  *aResult = (mPendingSheets == 0);
   mInLoadResourcesFunc = false;
 
   // Destroy our resource list.
   delete mResourceList;
   mResourceList = nullptr;
+
+  return mPendingSheets == 0;
 }
 
 // nsICSSLoaderObserver
 NS_IMETHODIMP
 nsXBLResourceLoader::StyleSheetLoaded(StyleSheet* aSheet,
                                       bool aWasAlternate,
                                       nsresult aStatus)
 {
--- a/dom/xbl/nsXBLResourceLoader.h
+++ b/dom/xbl/nsXBLResourceLoader.h
@@ -29,17 +29,17 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsXBLResourceLoader)
 
   // nsICSSLoaderObserver
   NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheet* aSheet,
                               bool aWasAlternate,
                               nsresult aStatus) override;
 
-  void LoadResources(bool* aResult);
+  bool LoadResources();
   void AddResource(nsIAtom* aResourceType, const nsAString& aSrc);
   void AddResourceListener(nsIContent* aElement);
 
   nsXBLResourceLoader(nsXBLPrototypeBinding* aBinding,
                       nsXBLPrototypeResources* aResources);
 
   void NotifyBoundElements();