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

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

Issue 15657003: Make a '::distributed' pseudo element the first-ever client who can accept a relative selector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Introduce m_relationIsForShadowDistributed Created 7 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 | « Source/core/css/SelectorChecker.h ('k') | Source/core/css/SelectorFilter.cpp » ('j') | 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 768de63972ce3c8e4be511c17f62fa86a73e7a0c..cde161331e076fd622ec972a06ee67b4f66e1a85 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -139,6 +139,13 @@ SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext& con
switch (relation) {
case CSSSelector::Descendant:
+ if (context.selector->relationIsForShadowDistributed()) {
+ for (Element* element = context.element; element; element = element->parentElement()) {
+ if (matchForShadowDistributed(element, siblingTraversalStrategy, ignoreDynamicPseudo, nextContext) == SelectorMatches)
+ return SelectorMatches;
+ }
+ return SelectorFailsCompletely;
+ }
nextContext.element = context.element->parentElement();
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
@@ -150,15 +157,15 @@ SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext& con
return SelectorFailsCompletely;
}
return SelectorFailsCompletely;
-
case CSSSelector::Child:
+ if (context.selector->relationIsForShadowDistributed())
+ return matchForShadowDistributed(context.element, siblingTraversalStrategy, ignoreDynamicPseudo, nextContext);
nextContext.element = context.element->parentElement();
if (!nextContext.element)
return SelectorFailsCompletely;
nextContext.isSubSelector = false;
nextContext.elementStyle = 0;
return match(nextContext, ignoreDynamicPseudo, siblingTraversalStrategy);
-
case CSSSelector::DirectAdjacent:
if (m_mode == ResolvingStyle) {
if (Element* parentElement = context.element->parentElement())
@@ -212,28 +219,27 @@ SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext& con
nextContext.elementStyle = 0;
return match(nextContext, ignoreDynamicPseudo, siblingTraversalStrategy);
}
- case CSSSelector::ShadowDistributed:
- {
- Vector<InsertionPoint*, 8> insertionPoints;
- for (Element* element = context.element; element; element = element->parentElement()) {
- insertionPoints.clear();
- collectInsertionPointsWhereNodeIsDistributed(element, insertionPoints);
- for (size_t i = 0; i < insertionPoints.size(); ++i) {
- nextContext.element = insertionPoints[i];
- nextContext.isSubSelector = false;
- nextContext.elementStyle = 0;
- if (match(nextContext, ignoreDynamicPseudo, siblingTraversalStrategy) == SelectorMatches)
- return SelectorMatches;
- }
- }
- return SelectorFailsCompletely;
- }
}
ASSERT_NOT_REACHED();
return SelectorFailsCompletely;
}
+template<typename SiblingTraversalStrategy>
+SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Element* element, const SiblingTraversalStrategy& siblingTraversalStrategy, PseudoId& dynamicPseudo, SelectorCheckingContext& nextContext) const
+{
+ Vector<InsertionPoint*, 8> insertionPoints;
+ collectInsertionPointsWhereNodeIsDistributed(element, insertionPoints);
+ for (size_t i = 0; i < insertionPoints.size(); ++i) {
+ nextContext.element = insertionPoints[i];
+ nextContext.isSubSelector = false;
+ nextContext.elementStyle = 0;
+ if (match(nextContext, dynamicPseudo, siblingTraversalStrategy) == SelectorMatches)
+ return SelectorMatches;
+ }
+ return SelectorFailsCompletely;
+}
+
static inline bool containsHTMLSpace(const AtomicString& string)
{
for (unsigned i = 0; i < string.length(); i++)
« no previous file with comments | « Source/core/css/SelectorChecker.h ('k') | Source/core/css/SelectorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698