зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382078
Part 1 - Add method to nsBindingManager to iterate all bound contents. r=emilio
MozReview-Commit-ID: H00b3pGNC8V --HG-- extra : rebase_source : 8329b86b8690c13366a1421a977fb20165d5be5e
This commit is contained in:
Родитель
54d4464f85
Коммит
1405de1443
|
@ -709,77 +709,9 @@ nsBindingManager::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef nsTHashtable<nsPtrHashKey<nsIStyleRuleProcessor> > RuleProcessorSet;
|
|
||||||
|
|
||||||
static RuleProcessorSet*
|
|
||||||
GetContentSetRuleProcessors(nsTHashtable<nsRefPtrHashKey<nsIContent>>* aContentSet)
|
|
||||||
{
|
|
||||||
RuleProcessorSet* set = nullptr;
|
|
||||||
|
|
||||||
for (auto iter = aContentSet->Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
nsIContent* boundContent = iter.Get()->GetKey();
|
|
||||||
for (nsXBLBinding* binding = boundContent->GetXBLBinding(); binding;
|
|
||||||
binding = binding->GetBaseBinding()) {
|
|
||||||
nsIStyleRuleProcessor* ruleProc =
|
|
||||||
binding->PrototypeBinding()->GetRuleProcessor();
|
|
||||||
if (ruleProc) {
|
|
||||||
if (!set) {
|
|
||||||
set = new RuleProcessorSet;
|
|
||||||
}
|
|
||||||
set->PutEntry(ruleProc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc,
|
nsBindingManager::EnumerateBoundContentBindings(
|
||||||
ElementDependentRuleProcessorData* aData)
|
const BoundContentBindingCallback& aCallback) const
|
||||||
{
|
|
||||||
if (!mBoundContentSet) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoPtr<RuleProcessorSet> set;
|
|
||||||
set = GetContentSetRuleProcessors(mBoundContentSet);
|
|
||||||
if (!set) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto iter = set->Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
nsIStyleRuleProcessor* ruleProcessor = iter.Get()->GetKey();
|
|
||||||
(*(aFunc))(ruleProcessor, aData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext,
|
|
||||||
bool* aRulesChanged)
|
|
||||||
{
|
|
||||||
*aRulesChanged = false;
|
|
||||||
if (!mBoundContentSet) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoPtr<RuleProcessorSet> set;
|
|
||||||
set = GetContentSetRuleProcessors(mBoundContentSet);
|
|
||||||
if (!set) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto iter = set->Iter(); !iter.Done(); iter.Next()) {
|
|
||||||
nsIStyleRuleProcessor* ruleProcessor = iter.Get()->GetKey();
|
|
||||||
bool thisChanged = ruleProcessor->MediumFeaturesChanged(aPresContext);
|
|
||||||
*aRulesChanged = *aRulesChanged || thisChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray)
|
|
||||||
{
|
{
|
||||||
if (!mBoundContentSet) {
|
if (!mBoundContentSet) {
|
||||||
return;
|
return;
|
||||||
|
@ -787,13 +719,54 @@ nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray)
|
||||||
|
|
||||||
for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mBoundContentSet->Iter(); !iter.Done(); iter.Next()) {
|
||||||
nsIContent* boundContent = iter.Get()->GetKey();
|
nsIContent* boundContent = iter.Get()->GetKey();
|
||||||
for (nsXBLBinding* binding = boundContent->GetXBLBinding(); binding;
|
for (nsXBLBinding* binding = boundContent->GetXBLBinding();
|
||||||
|
binding;
|
||||||
binding = binding->GetBaseBinding()) {
|
binding = binding->GetBaseBinding()) {
|
||||||
binding->PrototypeBinding()->AppendStyleSheetsTo(aArray);
|
aCallback(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc,
|
||||||
|
ElementDependentRuleProcessorData* aData)
|
||||||
|
{
|
||||||
|
EnumerateBoundContentBindings([=](nsXBLBinding* aBinding) {
|
||||||
|
nsIStyleRuleProcessor* ruleProcessor =
|
||||||
|
aBinding->PrototypeBinding()->GetRuleProcessor();
|
||||||
|
if (ruleProcessor) {
|
||||||
|
(*(aFunc))(ruleProcessor, aData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext,
|
||||||
|
bool* aRulesChanged)
|
||||||
|
{
|
||||||
|
*aRulesChanged = false;
|
||||||
|
RefPtr<nsPresContext> presContext = aPresContext;
|
||||||
|
|
||||||
|
EnumerateBoundContentBindings([=](nsXBLBinding* aBinding) {
|
||||||
|
nsIStyleRuleProcessor* ruleProcessor =
|
||||||
|
aBinding->PrototypeBinding()->GetRuleProcessor();
|
||||||
|
if (ruleProcessor) {
|
||||||
|
bool thisChanged = ruleProcessor->MediumFeaturesChanged(presContext);
|
||||||
|
*aRulesChanged = *aRulesChanged || thisChanged;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray)
|
||||||
|
{
|
||||||
|
EnumerateBoundContentBindings([&aArray](nsXBLBinding* aBinding) {
|
||||||
|
aBinding->PrototypeBinding()->AppendStyleSheetsTo(aArray);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InsertAppendedContent(XBLChildrenElement* aPoint,
|
InsertAppendedContent(XBLChildrenElement* aPoint,
|
||||||
nsIContent* aFirstNewContent)
|
nsIContent* aFirstNewContent)
|
||||||
|
|
|
@ -193,6 +193,12 @@ protected:
|
||||||
// Call PostProcessAttachedQueueEvent() on a timer.
|
// Call PostProcessAttachedQueueEvent() on a timer.
|
||||||
static void PostPAQEventCallback(nsITimer* aTimer, void* aClosure);
|
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(
|
||||||
|
const BoundContentBindingCallback& aCallback) const;
|
||||||
|
|
||||||
// MEMBER VARIABLES
|
// MEMBER VARIABLES
|
||||||
protected:
|
protected:
|
||||||
// A set of nsIContent that currently have a binding installed.
|
// A set of nsIContent that currently have a binding installed.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче