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

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

Issue 1143003008: Simplify UserAgentShadowRoot check for /deep/ selectors. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index e05b11cb917b6a936a328bd104840dc232c45b8d..7d05b704e5231a59543b1a704821063e02beb54b 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -295,18 +295,6 @@ SelectorChecker::Match SelectorChecker::matchForSubSelector(const SelectorChecki
return matchSelector(nextContext, result);
}
-static inline Element* parentOrShadowHostButDisallowEscapingUserAgentShadowTree(const Element& element)
-{
- ContainerNode* parent = element.parentOrShadowHostNode();
- if (!parent)
- return nullptr;
- if (parent->isShadowRoot())
- return (toShadowRoot(parent)->type() == ShadowRoot::UserAgentShadowRoot) ? nullptr : toShadowRoot(parent)->host();
- if (!parent->isElementNode())
- return nullptr;
- return toElement(parent);
-}
-
static inline bool isOpenShadowRoot(const Node* node)
{
return node && node->isShadowRoot() && toShadowRoot(node)->type() == ShadowRoot::OpenShadowRoot;
@@ -425,8 +413,13 @@ SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
case CSSSelector::ShadowDeep:
{
+ if (ShadowRoot* root = context.element->containingShadowRoot()) {
+ if (root->type() == ShadowRoot::UserAgentShadowRoot)
+ return SelectorFailsCompletely;
+ }
+
if (context.selector->relationIsAffectedByPseudoContent()) {
- for (Element* element = context.element; element; element = parentOrShadowHostButDisallowEscapingUserAgentShadowTree(*element)) {
+ for (Element* element = context.element; element; element = element->parentOrShadowHostElement()) {
if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches)
return SelectorMatches;
}
@@ -435,7 +428,7 @@ SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
nextContext.isSubSelector = false;
nextContext.inRightmostCompound = false;
- for (nextContext.element = parentOrShadowHostButDisallowEscapingUserAgentShadowTree(*context.element); nextContext.element; nextContext.element = parentOrShadowHostButDisallowEscapingUserAgentShadowTree(*nextContext.element)) {
+ for (nextContext.element = context.element->parentOrShadowHostElement(); nextContext.element; nextContext.element = nextContext.element->parentOrShadowHostElement()) {
Match match = matchSelector(nextContext, result);
if (match == SelectorMatches || match == SelectorFailsCompletely)
return match;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698