Bug 1390694 - Part 2: Allow EnumerateBoundContentBindings callbacks to stop enumeration. r=emilio

MozReview-Commit-ID: 25ZxscIi7T5

--HG--
extra : rebase_source : 64e9ff5cd35defd3bb8f5f13f6b2fe7623418f3e
extra : source : b43ed8551cea5bf8fb86c94499810dcd458c8672
This commit is contained in:
Cameron McCormack 2017-11-01 21:20:39 +11:00
Родитель 1e2c9293c6
Коммит 4f08e9772a
2 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -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<StyleSheet*>& aArray)
{
EnumerateBoundContentBindings([&aArray](nsXBLBinding* aBinding) {
aBinding->PrototypeBinding()->AppendStyleSheetsTo(aArray);
return true;
});
}

Просмотреть файл

@ -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 (nsXBLBinding*)>;
void EnumerateBoundContentBindings(
// in mBoundContentSet. Return false from the callback to stop enumeration.
using BoundContentBindingCallback = std::function<bool (nsXBLBinding*)>;
bool EnumerateBoundContentBindings(
const BoundContentBindingCallback& aCallback) const;
// MEMBER VARIABLES