Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: third_party/WebKit/Source/core/css/SelectorChecker.cpp

Issue 2532813002: Matching part for >>> (shadow-piercing descendant combinator). (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSSelector.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSSelector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698