Bug 1390694 - Part 3: Add nsBindingManager function to check for document state dependencies. r=emilio
authorCameron McCormack <cam@mcc.id.au>
Wed, 01 Nov 2017 21:20:39 +1100
changeset 442823 4617a3675f588775c5cbbefe75ade5da3333aca1
parent 442822 68e5971edabb7d004505ebf57850c247b58c1adc
child 442824 6b2e7817128b0406aa974c3e6b9490be67ab5ea7
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1390694
milestone58.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 1390694 - Part 3: Add nsBindingManager function to check for document state dependencies. r=emilio MozReview-Commit-ID: Aw04MrVHyIz
dom/xbl/nsBindingManager.cpp
dom/xbl/nsBindingManager.h
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -1164,8 +1164,25 @@ nsBindingManager::FindNestedSingleInsert
     if (newParent == parent) {
       break;
     }
     parent = newParent;
   }
 
   return parent;
 }
+
+bool
+nsBindingManager::AnyBindingHasDocumentStateDependency(EventStates aStateMask)
+{
+  MOZ_ASSERT(mDocument->IsStyledByServo());
+
+  bool result = false;
+  EnumerateBoundContentBindings([&](nsXBLBinding* aBinding) {
+    ServoStyleSet* styleSet = aBinding->PrototypeBinding()->GetServoStyleSet();
+    if (styleSet && styleSet->HasDocumentStateDependency(aStateMask)) {
+      result = true;
+      return false;
+    }
+    return true;
+  });
+  return result;
+}
--- a/dom/xbl/nsBindingManager.h
+++ b/dom/xbl/nsBindingManager.h
@@ -14,16 +14,17 @@
 #include "nsInterfaceHashtable.h"
 #include "nsRefPtrHashtable.h"
 #include "nsURIHashKey.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsXBLBinding.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "mozilla/StyleSheet.h"
+#include "mozilla/EventStates.h"
 
 struct ElementDependentRuleProcessorData;
 class nsIXPConnectWrappedJS;
 class nsAtom;
 class nsIDOMNodeList;
 class nsIDocument;
 class nsIURI;
 class nsXBLDocumentInfo;
@@ -170,16 +171,18 @@ public:
   // Called when the document is going away
   void DropDocumentReference();
 
   nsIContent* FindNestedInsertionPoint(nsIContent* aContainer,
                                        nsIContent* aChild);
 
   nsIContent* FindNestedSingleInsertionPoint(nsIContent* aContainer, bool* aMulti);
 
+  bool AnyBindingHasDocumentStateDependency(mozilla::EventStates aStateMask);
+
 protected:
   nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent);
   nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult);
 
   // Called by ContentAppended and ContentInserted to handle a single child
   // insertion.  aChild must not be null.  aContainer may be null.
   // aAppend is true if this child is being appended, not inserted.
   void HandleChildInsertion(nsIContent* aContainer, nsIContent* aChild,