Bug 1025725 - Part 2: Encapsulate nsXBLPrototypeResources::mRuleProcessor. r=bzbarsky
authorCameron McCormack <cam@mcc.id.au>
Thu, 19 Jun 2014 17:02:56 +1000
changeset 189521 6038055f6b19cb8e5a88fd2c7fde840c8d7f2e94
parent 189520 d37890e3b9db0d966ef01eb71d2915d2e786ab7f
child 189522 d4e7841a2cacc1590a9b386f87ad234c2b67b816
push id26988
push useremorley@mozilla.com
push dateThu, 19 Jun 2014 14:39:10 +0000
treeherdermozilla-central@ad11457bae17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1025725
milestone33.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 1025725 - Part 2: Encapsulate nsXBLPrototypeResources::mRuleProcessor. r=bzbarsky
dom/xbl/nsXBLPrototypeBinding.cpp
dom/xbl/nsXBLPrototypeResources.cpp
dom/xbl/nsXBLPrototypeResources.h
dom/xbl/nsXBLResourceLoader.cpp
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -579,17 +579,17 @@ nsXBLPrototypeBinding::SetInitialAttribu
     mAttributeTable->EnumerateRead(SetAttrsNS, &data);
   }
 }
 
 nsIStyleRuleProcessor*
 nsXBLPrototypeBinding::GetRuleProcessor()
 {
   if (mResources) {
-    return mResources->mRuleProcessor;
+    return mResources->GetRuleProcessor();
   }
 
   return nullptr;
 }
 
 nsXBLPrototypeResources::sheet_array_type*
 nsXBLPrototypeBinding::GetOrCreateStyleSheets()
 {
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -95,19 +95,18 @@ nsXBLPrototypeResources::FlushSkinSheets
         continue;
     }
     else {
       newSheet = oldSheet;
     }
 
     mStyleSheetList.AppendElement(newSheet);
   }
-  mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
-                                          nsStyleSet::eDocSheet,
-                                          nullptr);
+
+  GatherRuleProcessor();
 
   return NS_OK;
 }
 
 nsresult
 nsXBLPrototypeResources::Write(nsIObjectOutputStream* aStream)
 {
   if (mLoader)
@@ -122,8 +121,16 @@ nsXBLPrototypeResources::Traverse(nsCycl
   cb.NoteXPCOMChild(mLoader);
 }
 
 void
 nsXBLPrototypeResources::ClearLoader()
 {
   mLoader = nullptr;
 }
+
+void
+nsXBLPrototypeResources::GatherRuleProcessor()
+{
+  mRuleProcessor = new nsCSSRuleProcessor(mStyleSheetList,
+                                          nsStyleSet::eDocSheet,
+                                          nullptr);
+}
--- a/dom/xbl/nsXBLPrototypeResources.h
+++ b/dom/xbl/nsXBLPrototypeResources.h
@@ -33,22 +33,31 @@ public:
   nsresult Write(nsIObjectOutputStream* aStream);
 
   void Traverse(nsCycleCollectionTraversalCallback &cb) const;
 
   void ClearLoader();
 
   typedef nsTArray<nsRefPtr<nsCSSStyleSheet> > sheet_array_type;
 
+  /**
+   * Recreates mRuleProcessor to represent the current list of style sheets
+   * stored in mStyleSheetList.  (Named GatherRuleProcessor to parallel
+   * nsStyleSet::GatherRuleProcessors.)
+   */
+  void GatherRuleProcessor();
+
+  nsCSSRuleProcessor* GetRuleProcessor() const { return mRuleProcessor; }
+
 private:
   // A loader object. Exists only long enough to load resources, and then it dies.
   nsRefPtr<nsXBLResourceLoader> mLoader;
 
 public:
   // A list of loaded stylesheets for this binding.
   sheet_array_type mStyleSheetList;
 
+private:
   // The list of stylesheets converted to a rule processor.
   nsRefPtr<nsCSSRuleProcessor> mRuleProcessor;
 };
 
 #endif
-
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -175,20 +175,17 @@ nsXBLResourceLoader::StyleSheetLoaded(ns
    
   mResources->mStyleSheetList.AppendElement(aSheet);
 
   if (!mInLoadResourcesFunc)
     mPendingSheets--;
   
   if (mPendingSheets == 0) {
     // All stylesheets are loaded.  
-    mResources->mRuleProcessor =
-      new nsCSSRuleProcessor(mResources->mStyleSheetList, 
-                             nsStyleSet::eDocSheet,
-                             nullptr);
+    mResources->GatherRuleProcessor();
 
     // XXX Check for mPendingScripts when scripts also come online.
     if (!mInLoadResourcesFunc)
       NotifyBoundElements();
   }
   return NS_OK;
 }