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

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

Issue 1270313002: Handle closed mode shadow for /deep/ and ::shadow selectors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix for comment29 Created 5 years, 4 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
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index 45134f9de9d78959dbf1e6d710c414dcf91105de..2d0337e5ea8c69fe85827812b2f1e0a6016217ce 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -309,6 +309,15 @@ SelectorChecker::Match SelectorChecker::matchForPseudoShadow(const SelectorCheck
return matchSelector(context, result);
}
+static inline Element* parentOrOpenShadowHostElement(const Element* element)
hayato 2015/08/20 07:09:59 This might be confusing name because shadow host's
hayato 2015/08/20 07:09:59 const Element&
kochi 2015/08/20 07:32:50 How about parentOrShadowHostElementWithoutExceedin
kochi 2015/08/20 07:32:50 Done.
hayato 2015/08/20 10:16:29 I would prefer parentOrShadowHostButDisallowEscapi
+{
+ if (element->parentNode() && element->parentNode()->isShadowRoot()) {
+ if (!toShadowRoot(element->parentNode())->isOpen())
+ return nullptr;
+ }
+ return element->parentOrShadowHostElement();
+}
+
SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingContext& context, MatchResult& result) const
{
SelectorCheckingContext nextContext = prepareNextContextForRelation(context);
@@ -423,6 +432,7 @@ SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
}
if (context.selector->relationIsAffectedByPseudoContent()) {
+ // TODO(kochi): closed mode tree should be handled as well for ::content.
kochi 2015/08/20 06:04:26 Added TODO for fixing this later.
for (Element* element = context.element; element; element = element->parentOrShadowHostElement()) {
if (matchForShadowDistributed(nextContext, *element, result) == SelectorMatches)
return SelectorMatches;
@@ -432,7 +442,8 @@ SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
nextContext.isSubSelector = false;
nextContext.inRightmostCompound = false;
- for (nextContext.element = context.element->parentOrShadowHostElement(); nextContext.element; nextContext.element = nextContext.element->parentOrShadowHostElement()) {
+
+ 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;
« no previous file with comments | « LayoutTests/fast/dom/shadow/closed-mode-deep-combinators-expected.txt ('k') | Source/core/css/resolver/SharedStyleFinder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698