From 4f08e9772acde128cb1152347530b86eb93f6caf Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Wed, 1 Nov 2017 21:20:39 +1100 Subject: [PATCH] Bug 1390694 - Part 2: Allow EnumerateBoundContentBindings callbacks to stop enumeration. r=emilio MozReview-Commit-ID: 25ZxscIi7T5 --HG-- extra : rebase_source : 64e9ff5cd35defd3bb8f5f13f6b2fe7623418f3e extra : source : b43ed8551cea5bf8fb86c94499810dcd458c8672 --- dom/xbl/nsBindingManager.cpp | 14 +++++++++++--- dom/xbl/nsBindingManager.h | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index b80ad057ce45..5ecd81327c9e 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -708,12 +708,12 @@ nsBindingManager::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, return NS_OK; } -void +bool nsBindingManager::EnumerateBoundContentBindings( const BoundContentBindingCallback& aCallback) const { if (!mBoundContentSet) { - return; + return true; } for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) { @@ -721,9 +721,13 @@ nsBindingManager::EnumerateBoundContentBindings( for (nsXBLBinding* binding = boundContent->GetXBLBinding(); binding; binding = binding->GetBaseBinding()) { - aCallback(binding); + if (!aCallback(binding)) { + return false; + } } } + + return true; } void @@ -736,6 +740,7 @@ nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, if (ruleProcessor) { (*(aFunc))(ruleProcessor, aData); } + return true; }); } @@ -775,6 +780,7 @@ nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext) rulesChanged = rulesChanged || thisChanged; } } + return true; }); return rulesChanged; @@ -794,6 +800,7 @@ nsBindingManager::UpdateBoundContentBindingsForServo(nsPresContext* aPresContext if (styleSet && styleSet->StyleSheetsHaveChanged()) { protoBinding->ComputeServoStyleSet(presContext); } + return true; }); } @@ -802,6 +809,7 @@ nsBindingManager::AppendAllSheets(nsTArray& aArray) { EnumerateBoundContentBindings([&aArray](nsXBLBinding* aBinding) { aBinding->PrototypeBinding()->AppendStyleSheetsTo(aArray); + return true; }); } diff --git a/dom/xbl/nsBindingManager.h b/dom/xbl/nsBindingManager.h index 0d381c9ac6d7..d86fea8c6f4a 100644 --- a/dom/xbl/nsBindingManager.h +++ b/dom/xbl/nsBindingManager.h @@ -196,9 +196,9 @@ protected: static void PostPAQEventCallback(nsITimer* aTimer, void* aClosure); // Enumerate each bound content's bindings (including its base bindings) - // in mBoundContentSet. - using BoundContentBindingCallback = std::function; - void EnumerateBoundContentBindings( + // in mBoundContentSet. Return false from the callback to stop enumeration. + using BoundContentBindingCallback = std::function; + bool EnumerateBoundContentBindings( const BoundContentBindingCallback& aCallback) const; // MEMBER VARIABLES