Bug 1429959 - Make nsBindingManager::EnumerateBoundContentBindings yield each binding only once. r=emilio
authorXidorn Quan <me@upsuper.org>
Fri, 12 Jan 2018 11:59:51 +1100
changeset 453432 a16df11dae3fba36cb958b06917f35d9d0591f78
parent 453431 29006b3597ccb3e279af3aa61045fb14a57d0e56
child 453433 7647a5900c99198390ee3c7e12dac4200caf87a5
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)
reviewersemilio
bugs1429959
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 1429959 - Make nsBindingManager::EnumerateBoundContentBindings yield each binding only once. r=emilio MozReview-Commit-ID: LxiF2RngJmq
dom/xbl/nsBindingManager.cpp
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -717,21 +717,28 @@ nsBindingManager::WalkRules(nsIStyleRule
 bool
 nsBindingManager::EnumerateBoundContentBindings(
   const BoundContentBindingCallback& aCallback) const
 {
   if (!mBoundContentSet) {
     return true;
   }
 
+  nsTHashtable<nsPtrHashKey<nsXBLBinding>> bindings;
   for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) {
     nsIContent* boundContent = iter.Get()->GetKey();
     for (nsXBLBinding* binding = boundContent->GetXBLBinding();
          binding;
          binding = binding->GetBaseBinding()) {
+      // If we have already invoked the callback with a binding, we
+      // should have also invoked it for all its base bindings, so we
+      // don't need to continue this loop anymore.
+      if (!bindings.EnsureInserted(binding)) {
+        break;
+      }
       if (!aCallback(binding)) {
         return false;
       }
     }
   }
 
   return true;
 }