Bug 1428491: Remove redundant mBindingManager member in ServoStyleSet. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 05 Jan 2018 20:17:26 +0100
changeset 454014 030453672f86258c0973943180c03b3c0a60db13
parent 454013 d96bbef4fdb60126d731c5bbfb8e75903bdc1d92
child 454015 5cf0e7a54c3f402c1bbc7c847e57c569638a4c41
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1428491
milestone59.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 1428491: Remove redundant mBindingManager member in ServoStyleSet. r=heycam MozReview-Commit-ID: KMiivgik0fr
layout/base/PresShell.cpp
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/StyleSetHandle.h
layout/style/StyleSetHandleInlines.h
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -954,17 +954,17 @@ PresShell::Init(nsIDocument* aDocument,
   // Bind the context to the presentation shell.
   mPresContext = aPresContext;
   mPresContext->AttachShell(this, aStyleSet->BackendType());
 
   // Now we can initialize the style set. Make sure to set the member before
   // calling Init, since various subroutines need to find the style set off
   // the PresContext during initialization.
   mStyleSet = aStyleSet;
-  mStyleSet->Init(aPresContext, mDocument->BindingManager());
+  mStyleSet->Init(aPresContext);
 
   // Notify our prescontext that it now has a compatibility mode.  Note that
   // this MUST happen after we set up our style set but before we create any
   // frames.
   mPresContext->CompatibilityModeChanged();
 
   // Add the preference style sheet.
   UpdatePreferenceStyles();
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -115,17 +115,17 @@ ServoStyleSet::~ServoStyleSet()
 }
 
 UniquePtr<ServoStyleSet>
 ServoStyleSet::CreateXBLServoStyleSet(
   nsPresContext* aPresContext,
   const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets)
 {
   auto set = MakeUnique<ServoStyleSet>(Kind::ForXBL);
-  set->Init(aPresContext, nullptr);
+  set->Init(aPresContext);
 
   // The XBL style sheets aren't document level sheets, but we need to
   // decide a particular SheetType to add them to style set. This type
   // doesn't affect the place where we pull those rules from
   // stylist::push_applicable_declarations_as_xbl_only_stylist().
   set->ReplaceSheets(SheetType::Doc, aNewSheets);
 
   // Update stylist immediately.
@@ -149,25 +149,24 @@ ServoStyleSet::GetPresContext()
   if (!shell) {
     return nullptr;
   }
 
   return shell->GetPresContext();
 }
 
 void
-ServoStyleSet::Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager)
+ServoStyleSet::Init(nsPresContext* aPresContext)
 {
   mDocument = aPresContext->Document();
   MOZ_ASSERT(GetPresContext() == aPresContext);
 
   mLastPresContextUsesXBLStyleSet = aPresContext;
 
   mRawSet.reset(Servo_StyleSet_Init(aPresContext));
-  mBindingManager = aBindingManager;
 
   aPresContext->DeviceContext()->InitFontCache();
 
   // Now that we have an mRawSet, go ahead and notify about whatever stylesheets
   // we have so far.
   for (auto& sheetArray : mSheets) {
     for (auto& sheet : sheetArray) {
       // There's no guarantee this will create a list on the servo side whose
@@ -827,18 +826,18 @@ ServoStyleSet::StyleSheetAt(SheetType aT
 {
   MOZ_ASSERT(IsCSSSheetType(aType));
   return mSheets[aType][aIndex];
 }
 
 void
 ServoStyleSet::AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const
 {
-  if (mBindingManager) {
-    mBindingManager->AppendAllSheets(aArray);
+  if (mDocument) {
+    mDocument->BindingManager()->AppendAllSheets(aArray);
   }
 }
 
 nsresult
 ServoStyleSet::RemoveDocStyleSheet(ServoStyleSheet* aSheet)
 {
   return RemoveStyleSheet(SheetType::Doc, aSheet);
 }
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -127,17 +127,17 @@ public:
 
   explicit ServoStyleSet(Kind aKind);
   ~ServoStyleSet();
 
   static UniquePtr<ServoStyleSet>
   CreateXBLServoStyleSet(nsPresContext* aPresContext,
                          const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
 
-  void Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager);
+  void Init(nsPresContext* aPresContext);
   void BeginShutdown() {}
   void Shutdown();
 
   // Called when a rules in a stylesheet in this set, or a child sheet of that,
   // are mutated from CSSOM.
   void RuleAdded(ServoStyleSheet&, css::Rule&);
   void RuleRemoved(ServoStyleSheet&, css::Rule&);
   void RuleChanged(ServoStyleSheet& aSheet, css::Rule* aRule);
@@ -644,19 +644,16 @@ private:
   // These are similar to Servo's SequentialTasks, except that they are
   // posted by C++ code running on style worker threads.
   nsTArray<PostTraversalTask> mPostTraversalTasks;
 
   // Map from raw Servo style rule to Gecko's wrapper object.
   // Constructed lazily when requested by devtools.
   UniquePtr<ServoStyleRuleMap> mStyleRuleMap;
 
-  // This can be null if we are used to hold XBL style sheets.
-  RefPtr<nsBindingManager> mBindingManager;
-
   static ServoStyleSet* sInServoTraversal;
 };
 
 class UACacheReporter final : public nsIMemoryReporter
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMEMORYREPORTER
 
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -110,17 +110,17 @@ public:
     // These inline methods are defined in StyleSetHandleInlines.h.
     inline void Delete();
 
     // Style set interface.  These inline methods are defined in
     // StyleSetHandleInlines.h and just forward to the underlying
     // nsStyleSet or ServoStyleSet.  See corresponding comments in
     // nsStyleSet.h for descriptions of these methods.
 
-    inline void Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager);
+    inline void Init(nsPresContext* aPresContext);
     inline void BeginShutdown();
     inline void Shutdown();
     inline bool GetAuthorStyleDisabled() const;
     inline nsresult SetAuthorStyleDisabled(bool aStyleDisabled);
     inline void BeginUpdate();
     inline nsresult EndUpdate();
     inline already_AddRefed<nsStyleContext>
     ResolveStyleFor(dom::Element* aElement,
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -39,20 +39,19 @@ StyleSetHandle::Ptr::Delete()
       delete AsGecko();
     } else {
       delete AsServo();
     }
   }
 }
 
 void
-StyleSetHandle::Ptr::Init(nsPresContext* aPresContext,
-                          nsBindingManager* aBindingManager)
+StyleSetHandle::Ptr::Init(nsPresContext* aPresContext)
 {
-  FORWARD(Init, (aPresContext, aBindingManager));
+  FORWARD(Init, (aPresContext));
 }
 
 void
 StyleSetHandle::Ptr::BeginShutdown()
 {
   FORWARD(BeginShutdown, ());
 }
 
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -269,25 +269,25 @@ nsStyleSet::AddSizeOfIncludingThis(nsWin
     n += mScopedDocSheetRuleProcessors[i]->SizeOfIncludingThis(mallocSizeOf);
   }
   n += mScopedDocSheetRuleProcessors.ShallowSizeOfExcludingThis(mallocSizeOf);
 
   aSizes.mLayoutGeckoStyleSets += n;
 }
 
 void
-nsStyleSet::Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager)
+nsStyleSet::Init(nsPresContext* aPresContext)
 {
   mFirstLineRule = new nsEmptyStyleRule;
   mFirstLetterRule = new nsEmptyStyleRule;
   mPlaceholderRule = new nsEmptyStyleRule;
   mDisableTextZoomStyleRule = new nsDisableTextZoomStyleRule;
+  mBindingManager = aPresContext->Document()->BindingManager();
 
   mRuleTree = nsRuleNode::CreateRootNode(aPresContext);
-  mBindingManager = aBindingManager;
 
   // Make an explicit GatherRuleProcessors call for the levels that
   // don't have style sheets.  The other levels will have their calls
   // triggered by DirtyRuleProcessors.
   GatherRuleProcessors(SheetType::PresHint);
   GatherRuleProcessors(SheetType::StyleAttr);
   GatherRuleProcessors(SheetType::Animation);
   GatherRuleProcessors(SheetType::Transition);
@@ -2697,19 +2697,16 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets
   for (SheetType type : gCSSSheetTypes) {
     for (StyleSheet* sheet : mSheets[type]) {
       queue.AppendElement(sheet);
     }
   }
 
   if (mBindingManager) {
     AutoTArray<StyleSheet*, 32> sheets;
-    // XXXheycam stylo: AppendAllSheets will need to be able to return either
-    // CSSStyleSheets or ServoStyleSheets, on request (and then here requesting
-    // CSSStyleSheets).
     mBindingManager->AppendAllSheets(sheets);
     for (StyleSheet* sheet : sheets) {
       MOZ_ASSERT(sheet->IsGecko(), "stylo: AppendAllSheets shouldn't give us "
                                    "ServoStyleSheets yet");
       queue.AppendElement(sheet->AsGecko());
     }
   }
 
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -105,17 +105,17 @@ public:
 class nsStyleSet final
 {
  public:
   nsStyleSet();
   ~nsStyleSet();
 
   void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
 
-  void Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager);
+  void Init(nsPresContext* aPresContext);
 
   nsRuleNode* GetRuleTree() { return mRuleTree; }
 
   // get a style context for a non-pseudo frame.
   already_AddRefed<mozilla::GeckoStyleContext>
   ResolveStyleFor(mozilla::dom::Element* aElement,
                   mozilla::GeckoStyleContext* aParentContext);