| Index: Source/core/css/ElementRuleCollector.cpp
|
| diff --git a/Source/core/css/ElementRuleCollector.cpp b/Source/core/css/ElementRuleCollector.cpp
|
| index e421fbb7e5f520afda79d359612f3b52af914737..d8fe6cd80bd5b875960b72a7fb342b72680251f7 100644
|
| --- a/Source/core/css/ElementRuleCollector.cpp
|
| +++ b/Source/core/css/ElementRuleCollector.cpp
|
| @@ -118,14 +118,12 @@ void ElementRuleCollector::addElementStyleProperties(const StylePropertySet* pro
|
| m_result.isCacheable = false;
|
| }
|
|
|
| -static bool rulesApplicableInCurrentTreeScope(const Element* element, const ContainerNode* scopingNode, bool elementApplyAuthorStyles)
|
| +static bool rulesApplicableInCurrentTreeScope(const Element* element, const ContainerNode* scopingNode)
|
| {
|
| TreeScope& treeScope = element->treeScope();
|
|
|
| // [skipped, because already checked] a) it's a UA rule
|
| - // b) element is allowed to apply author rules
|
| - if (elementApplyAuthorStyles)
|
| - return true;
|
| + // [skipped, because already checked] b) element is not in shadow tree
|
| // c) the rules comes from a scoped style sheet within the same tree scope
|
| if (!scopingNode || treeScope == scopingNode->treeScope())
|
| return true;
|
| @@ -135,11 +133,15 @@ static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont
|
| return false;
|
| }
|
|
|
| -void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
|
| +void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
|
| {
|
| ASSERT(matchRequest.ruleSet);
|
| ASSERT(m_context.element());
|
|
|
| + SelectorChecker::ContextFlags contextFlags = SelectorChecker::DefaultBehavior;
|
| + if (matchRequest.isInShadowTree)
|
| + contextFlags = SelectorChecker::ScopeContainsLastMatchedElement;
|
| +
|
| Element& element = *m_context.element();
|
| const AtomicString& pseudoId = element.shadowPseudoId();
|
| if (!pseudoId.isEmpty()) {
|
| @@ -151,12 +153,12 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
|
| collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange);
|
| // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
|
| // a) it's a UA rule
|
| - // b) the tree scope allows author rules
|
| + // b) the tree scope is not shadow tree
|
| // c) the rules comes from a scoped style sheet within the same tree scope
|
| // d) the rules comes from a scoped style sheet within an active shadow root whose host is the given element
|
| // e) the rules can cross boundaries
|
| - // b)-e) is checked in rulesApplicableInCurrentTreeScope.
|
| - if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope, matchRequest.elementApplyAuthorStyles))
|
| + // c)-e) is checked in rulesApplicableInCurrentTreeScope.
|
| + if (!m_matchingUARules && matchRequest.isInShadowTree && !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope))
|
| return;
|
|
|
| // We need to collect the rules for id, class, tag, and everything else into a buffer and
|
|
|