Bug 1318542 - part2: Add an argument in ResolvePseudoElementStyle and FileRules to refer ::cue in document under NAC. r?
MozReview-Commit-ID: CPyl6AyV2a3
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5069,17 +5069,18 @@ nsCSSFrameConstructor::ResolveStyleConte
"anonymous subtrees");
Element* parent = aContent->GetParentElement();
while (!parent->IsRootOfNativeAnonymousSubtree()) {
parent = parent->GetParentElement();
}
result = styleSet->ResolvePseudoElementStyle(parent,
pseudoType,
aParentStyleContext,
- aContent->AsElement());
+ aContent->AsElement(),
+ true);
}
} else {
NS_ASSERTION(aContent->IsNodeOfType(nsINode::eTEXT),
"shouldn't waste time creating style contexts for "
"comments and processing instructions");
result = styleSet->ResolveStyleForText(aContent, aParentStyleContext);
}
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -180,17 +180,18 @@ ServoStyleSet::ResolveStyleForOtherNonEl
nsCSSAnonBoxes::mozOtherNonElement,
CSSPseudoElementType::AnonBox);
}
already_AddRefed<nsStyleContext>
ServoStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- Element* aPseudoElement)
+ Element* aPseudoElement,
+ bool aForceDocSheet)
{
if (aPseudoElement) {
NS_ERROR("stylo: We don't support CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE yet");
}
MOZ_ASSERT(aParentContext);
MOZ_ASSERT(aType < CSSPseudoElementType::Count);
nsIAtom* pseudoTag = nsCSSPseudoElements::GetPseudoAtom(aType);
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -73,17 +73,18 @@ public:
already_AddRefed<nsStyleContext>
ResolveStyleForOtherNonElement(nsStyleContext* aParentContext);
already_AddRefed<nsStyleContext>
ResolvePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- dom::Element* aPseudoElement);
+ dom::Element* aPseudoElement,
+ bool aForceDocSheet = false);
// aFlags is an nsStyleSet flags bitfield
already_AddRefed<nsStyleContext>
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext,
uint32_t aFlags = 0);
// manage the set of style sheets in the style set
nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -128,17 +128,18 @@ public:
ResolveStyleForText(nsIContent* aTextNode,
nsStyleContext* aParentContext);
inline already_AddRefed<nsStyleContext>
ResolveStyleForOtherNonElement(nsStyleContext* aParentContext);
inline already_AddRefed<nsStyleContext>
ResolvePseudoElementStyle(dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- dom::Element* aPseudoElement);
+ dom::Element* aPseudoElement,
+ bool aForceDocSheet = false);
inline already_AddRefed<nsStyleContext>
ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag, nsStyleContext* aParentContext,
uint32_t aFlags = 0);
inline nsresult AppendStyleSheet(SheetType aType, StyleSheet* aSheet);
inline nsresult PrependStyleSheet(SheetType aType, StyleSheet* aSheet);
inline nsresult RemoveStyleSheet(SheetType aType, StyleSheet* aSheet);
inline nsresult ReplaceSheets(SheetType aType,
const nsTArray<RefPtr<StyleSheet>>& aNewSheets);
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -108,20 +108,21 @@ StyleSetHandle::Ptr::ResolveStyleForOthe
{
FORWARD(ResolveStyleForOtherNonElement, (aParentContext));
}
already_AddRefed<nsStyleContext>
StyleSetHandle::Ptr::ResolvePseudoElementStyle(dom::Element* aParentElement,
CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- dom::Element* aPseudoElement)
+ dom::Element* aPseudoElement,
+ bool aForceDocSheet)
{
FORWARD(ResolvePseudoElementStyle, (aParentElement, aType, aParentContext,
- aPseudoElement));
+ aPseudoElement, aForceDocSheet));
}
// aFlags is an nsStyleSet flags bitfield
already_AddRefed<nsStyleContext>
StyleSetHandle::Ptr::ResolveAnonymousBoxStyle(nsIAtom* aPseudoTag,
nsStyleContext* aParentContext,
uint32_t aFlags)
{
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1091,17 +1091,17 @@ nsStyleSet::AssertNoCSSRules(nsRuleNode*
}
}
#endif
// Enumerate the rules in a way that cares about the order of the rules.
void
nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
RuleProcessorData* aData, Element* aElement,
- nsRuleWalker* aRuleWalker)
+ nsRuleWalker* aRuleWalker, bool aForceDocSheet)
{
PROFILER_LABEL("nsStyleSet", "FileRules",
js::ProfileEntry::Category::CSS);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
// Cascading order:
// [least important]
@@ -1149,17 +1149,17 @@ nsStyleSet::FileRules(nsIStyleRuleProces
aRuleWalker->SetLevel(SheetType::Doc, false, true);
bool cutOffInheritance = false;
if (mBindingManager && aElement) {
// We can supply additional document-level sheets that should be walked.
mBindingManager->WalkRules(aCollectorFunc,
static_cast<ElementDependentRuleProcessorData*>(aData),
&cutOffInheritance);
}
- if (!skipUserStyles && !cutOffInheritance && // NOTE: different
+ if (((!skipUserStyles && !cutOffInheritance) || aForceDocSheet) && // NOTE: different
mRuleProcessors[SheetType::Doc])
(*aCollectorFunc)(mRuleProcessors[SheetType::Doc], aData);
nsRuleNode* lastDocRN = aRuleWalker->CurrentNode();
bool haveImportantDocRules = !aRuleWalker->GetCheckForImportantRules();
nsTArray<nsRuleNode*> lastScopedRNs;
nsTArray<bool> haveImportantScopedRules;
bool haveAnyImportantScopedRules = false;
if (!skipUserStyles && !cutOffInheritance &&
@@ -1816,34 +1816,35 @@ nsStyleSet::WalkDisableTextZoomRule(Elem
if (aElement->IsSVGElement(nsGkAtoms::text))
aRuleWalker->Forward(mDisableTextZoomStyleRule);
}
already_AddRefed<nsStyleContext>
nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- Element* aPseudoElement)
+ Element* aPseudoElement,
+ bool aForceDocSheet)
{
NS_ENSURE_FALSE(mInShutdown, nullptr);
NS_ASSERTION(aType < CSSPseudoElementType::Count,
"must have pseudo element type");
NS_ASSERTION(aParentElement, "Must have parent element");
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
aParentElement->OwnerDoc());
InitStyleScopes(treeContext, aParentElement);
PseudoElementRuleProcessorData data(PresContext(), aParentElement,
&ruleWalker, aType, treeContext,
aPseudoElement);
WalkRestrictionRule(aType, &ruleWalker);
FileRules(EnumRulesMatching<PseudoElementRuleProcessorData>, &data,
- aParentElement, &ruleWalker);
+ aParentElement, &ruleWalker, aForceDocSheet);
nsRuleNode *ruleNode = ruleWalker.CurrentNode();
nsRuleNode *visitedRuleNode = nullptr;
if (treeContext.HaveRelevantLink()) {
treeContext.ResetForVisitedMatching();
ruleWalker.Reset();
WalkRestrictionRule(aType, &ruleWalker);
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -214,17 +214,18 @@ class nsStyleSet final
// non-null. aPseudoID is the CSSPseudoElementType for the
// pseudo-element. aPseudoElement must be non-null if the pseudo-element
// type is one that allows user action pseudo-classes after it or allows
// style attributes; otherwise, it is ignored.
already_AddRefed<nsStyleContext>
ResolvePseudoElementStyle(mozilla::dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext,
- mozilla::dom::Element* aPseudoElement);
+ mozilla::dom::Element* aPseudoElement,
+ bool aForceDocSheet = false);
// This functions just like ResolvePseudoElementStyle except that it will
// return nullptr if there are no explicit style rules for that
// pseudo element.
already_AddRefed<nsStyleContext>
ProbePseudoElementStyle(mozilla::dom::Element* aParentElement,
mozilla::CSSPseudoElementType aType,
nsStyleContext* aParentContext);
@@ -497,17 +498,17 @@ private:
// Enumerate the rules in a way that cares about the order of the
// rules.
// aElement is the element the rules are for. It might be null. aData
// is the closure to pass to aCollectorFunc. If aContent is not null,
// aData must be a RuleProcessorData*
void FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
RuleProcessorData* aData, mozilla::dom::Element* aElement,
- nsRuleWalker* aRuleWalker);
+ nsRuleWalker* aRuleWalker, bool aForceDocSheet = false);
// Enumerate all the rules in a way that doesn't care about the order
// of the rules and break out if the enumeration is halted.
void WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
ElementDependentRuleProcessorData* aData,
bool aWalkAllXBLStylesheets);
// Helper for ResolveStyleWithReplacement