| 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 16a67e6dad8797e47ec29dc0aa3e9bb3d7fec918..283ffa0a4a28c583d9cdf1aab23bd2553cfabd32 100644
|
| --- a/third_party/WebKit/Source/core/css/SelectorChecker.cpp
|
| +++ b/third_party/WebKit/Source/core/css/SelectorChecker.cpp
|
| @@ -285,6 +285,14 @@ static inline Element* parentOrV0ShadowHostElement(const Element& element) {
|
| return element.parentOrShadowHostElement();
|
| }
|
|
|
| +static inline Element* parentOrOpenShadowHostElement(const Element& element) {
|
| + if (element.parentNode() && element.parentNode()->isShadowRoot()) {
|
| + if (toShadowRoot(element.parentNode())->type() != ShadowRootType::Open)
|
| + return nullptr;
|
| + }
|
| + return element.parentOrShadowHostElement();
|
| +}
|
| +
|
| SelectorChecker::Match SelectorChecker::matchForRelation(
|
| const SelectorCheckingContext& context,
|
| MatchResult& result) const {
|
| @@ -438,6 +446,26 @@ SelectorChecker::Match SelectorChecker::matchForRelation(
|
| return SelectorFailsCompletely;
|
| }
|
|
|
| + case CSSSelector::ShadowPiercingDescendant: {
|
| + DCHECK(m_isQuerySelector);
|
| + // TODO(kochi): parentOrOpenShadowHostElement() is necessary because
|
| + // SelectorQuery can pass V0 shadow roots. All closed shadow roots are
|
| + // already filtered out, thus once V0 is removed this logic can use
|
| + // parentOrShadowHostElement() instead.
|
| + for (nextContext.element =
|
| + parentOrOpenShadowHostElement(*context.element);
|
| + nextContext.element;
|
| + nextContext.element =
|
| + parentOrOpenShadowHostElement(*nextContext.element)) {
|
| + Match match = matchSelector(nextContext, result);
|
| + if (match == SelectorMatches || match == SelectorFailsCompletely)
|
| + return match;
|
| + if (nextSelectorExceedsScope(nextContext))
|
| + break;
|
| + }
|
| + return SelectorFailsCompletely;
|
| + }
|
| +
|
| case CSSSelector::ShadowSlot: {
|
| const HTMLSlotElement* slot = findSlotElementInScope(context);
|
| if (!slot)
|
|
|