Bug 1025725 - Part 2: Encapsulate nsXBLPrototypeResources::mRuleProcessor. r=bzbarsky, a=sledru
authorCameron McCormack <cam@mcc.id.au>
Thu, 19 Jun 2014 17:02:56 +1000
changeset 208885 df0670536f69e2119b190970fa8c577b6acbb35c
parent 208884 4ee1eccd5cdd79f2d4a338059039b48fb960bc4d
child 208886 9e809dfdf2ae4c5d2842e88e9debc320bd877e75
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, sledru
bugs1025725
milestone32.0a2
Bug 1025725 - Part 2: Encapsulate nsXBLPrototypeResources::mRuleProcessor. r=bzbarsky, a=sledru
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;
 }