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

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

Issue 414453003: Simplify SelectorChecker's parentElement() function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 4ab0cf1615c59d4c0a71cf53cb7624bec8292016..8a31b0ae2dd5025fb339a5e3b95ad6b70eee3aa1 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -81,17 +81,13 @@ static bool matchesCustomPseudoElement(const Element* element, const CSSSelector
static Element* parentElement(const SelectorChecker::SelectorCheckingContext& context)
{
- // If context.scope is a shadow root, we should walk up to its shadow host.
- if (context.scope && context.scope == context.element->containingShadowRoot())
+ // - If context.scope is a shadow root, we should walk up to its shadow host.
+ // - If context.scope is some element in some shadow tree and querySelector initialized the context,
+ // e.g. shadowRoot.querySelector(':host *'),
+ // (a) context.element has the same treescope as context.scope, need to walk up to its shadow host.
+ // (b) Otherwise, should not walk up from a shadow root to a shadow host.
+ if (context.scope && (context.scope == context.element->containingShadowRoot() || context.scope->treeScope() == context.element->treeScope()))
return context.element->parentOrShadowHostElement();
-
- // If context.scope is some element in some shadow tree and querySelector initialized the context,
- // e.g. shadowRoot.querySelector(':host *'),
- // (a) context.element has the same treescope as context.scope, need to walk up to its shadow host.
- // (b) Otherwise, should not walk up from a shadow root to a shadow host.
- if (context.scope && context.scope->treeScope() == context.element->treeScope())
- return context.element->parentOrShadowHostElement();
-
return context.element->parentElement();
}
« 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