Bug 508725 - Part 4: Add a content flag representing whether an element is a scoped style root. r=dbaron

This commit is contained in:
Cameron McCormack 2013-01-09 10:25:47 +11:00
parent 343037880d
commit 1e351dcb1e
2 changed files with 14 additions and 0 deletions

View File

@ -1322,6 +1322,8 @@ private:
// Set if the element is in the scope of a scoped style sheet; this flag is
// only accurate for elements bounds to a document
ElementIsInStyleScope,
// Set if the element is a scoped style sheet root
ElementIsScopedStyleRoot,
// Guard value
BooleanFlagCount
};
@ -1452,6 +1454,10 @@ public:
ClearBoolFlag(ElementIsInStyleScope);
}
bool IsElementInStyleScope() const { return GetBoolFlag(ElementIsInStyleScope); }
void SetIsScopedStyleRoot() { SetBoolFlag(ElementIsScopedStyleRoot); }
void ClearIsScopedStyleRoot() { ClearBoolFlag(ElementIsScopedStyleRoot); }
bool IsScopedStyleRoot() { return GetBoolFlag(ElementIsScopedStyleRoot); }
protected:
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
void SetInDocument() { SetBoolFlag(IsInDocument); }

View File

@ -295,6 +295,12 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
{
mRuleProcessors[aType] = nullptr;
if (aType == eScopedDocSheet) {
for (int i = 0; i < mScopedDocSheetRuleProcessors.Length(); i++) {
nsIStyleRuleProcessor* processor = mScopedDocSheetRuleProcessors[i].get();
Element* scope =
static_cast<nsCSSRuleProcessor*>(processor)->GetScopeElement();
scope->ClearIsScopedStyleRoot();
}
mScopedDocSheetRuleProcessors.Clear();
}
if (mAuthorStyleDisabled && (aType == eDocSheet ||
@ -348,6 +354,8 @@ nsStyleSet::GatherRuleProcessors(sheetType aType)
end++;
}
scope->SetIsScopedStyleRoot();
// Create a rule processor for the scope.
nsTArray< nsRefPtr<nsCSSStyleSheet> > sheetsForScope;
sheetsForScope.AppendElements(sheets.Elements() + start, end - start);