Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/SelectorChecker.cpp |
| diff --git a/third_party/WebKit/Source/core/css/SelectorChecker.cpp b/third_party/WebKit/Source/core/css/SelectorChecker.cpp |
| index 23fbddd246ff8f5f3b73a0e372473ed56b83bff5..dec67ce648ead233e658006e99a657c484ecc9fd 100644 |
| --- a/third_party/WebKit/Source/core/css/SelectorChecker.cpp |
| +++ b/third_party/WebKit/Source/core/css/SelectorChecker.cpp |
| @@ -311,6 +311,15 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation( |
| relation != CSSSelector::kChild))) |
| next_context.visited_match_type = kVisitedMatchDisabled; |
| + // The ParentElement() method will walk up to the host element for :host() and |
| + // :host-context() rules in the same scope as the element we are matching. |
| + // For kSharingRules, we don't know which scope the rules came from, so we are |
| + // using nullptr as scope. This is a workaround to make ParentElement() walk |
| + // up to the host when matching :host rules by assuming the scope of the :host |
| + // rule is the same as the element we are matching rules for. |
| + if (mode_ == kSharingRules && next_context.selector->IsHostPseudoClass()) |
| + next_context.scope = next_context.element->ContainingShadowRoot(); |
| + |
| next_context.in_rightmost_compound = false; |
| next_context.is_sub_selector = false; |
| next_context.previous_element = context.element; |
| @@ -332,7 +341,8 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation( |
| return MatchForPseudoShadow( |
| next_context, context.element->ContainingShadowRoot(), result); |
| - for (next_context.element = ParentElement(context); next_context.element; |
| + for (next_context.element = ParentElement(next_context); |
|
kochi
2017/04/19 10:21:12
This looks like a bug, but is this for bug 711539?
rune
2017/04/19 22:49:47
The element is initially the same for context and
kochi
2017/04/20 10:45:21
Acknowledged.
|
| + next_context.element; |
| next_context.element = ParentElement(next_context)) { |
| MatchStatus match = MatchSelector(next_context, result); |
| if (match == kSelectorMatches || match == kSelectorFailsCompletely) |
| @@ -349,7 +359,7 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation( |
| return MatchForPseudoShadow(next_context, context.element->parentNode(), |
| result); |
| - next_context.element = ParentElement(context); |
| + next_context.element = ParentElement(next_context); |
|
kochi
2017/04/19 10:21:12
Ditto
|
| if (!next_context.element) |
| return kSelectorFailsCompletely; |
| return MatchSelector(next_context, result); |