Index: third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp |
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp |
index bfd0f9fab4f5a90fbc5758c04248954b227fa73a..2c0d3bfddadcddc130349a38bb16152be891144f 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp |
@@ -23,6 +23,9 @@ static void recordSelectorStats(const CSSParserContext& context, const CSSSelect |
case CSSSelector::PseudoUnresolved: |
feature = UseCounter::CSSSelectorPseudoUnresolved; |
break; |
+ case CSSSelector::PseudoSlotted: |
+ feature = UseCounter::CSSSelectorPseudoSlotted; |
+ break; |
case CSSSelector::PseudoContent: |
feature = UseCounter::CSSSelectorPseudoContent; |
break; |
@@ -370,6 +373,18 @@ PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumePseudo(CSSParserTokenRan |
selector->adoptSelectorVector(selectorVector); |
return selector.release(); |
} |
+ case CSSSelector::PseudoSlotted: |
+ { |
+ OwnPtr<CSSParserSelector> innerSelector = consumeCompoundSelector(block); |
+ block.consumeWhitespace(); |
+ if (!innerSelector || !block.atEnd()) |
+ return nullptr; |
+ Vector<OwnPtr<CSSParserSelector>> selectorVector; |
+ selectorVector.append(innerSelector.release()); |
+ selector->adoptSelectorVector(selectorVector); |
+ selector->setRelationIsAffectedByPseudoSlotted(); |
+ return selector.release(); |
+ } |
case CSSSelector::PseudoLang: |
{ |
// FIXME: CSS Selectors Level 4 allows :lang(*-foo) |
@@ -563,7 +578,7 @@ const AtomicString& CSSSelectorParser::determineNamespace(const AtomicString& pr |
void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespacePrefix, const AtomicString& elementName, CSSParserSelector* compoundSelector) |
{ |
- if (elementName.isNull() && defaultNamespace() == starAtom && !compoundSelector->crossesTreeScopes()) |
+ if (elementName.isNull() && defaultNamespace() == starAtom && !compoundSelector->crossesTreeScopes() && !compoundSelector->relationIsAffectedByPseudoSlotted()) |
return; |
AtomicString determinedElementName = elementName.isNull() ? starAtom : elementName; |
@@ -575,8 +590,8 @@ void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac |
if (compoundSelector->crossesTreeScopes()) |
return rewriteSpecifiersWithElementNameForCustomPseudoElement(tag, compoundSelector, elementName.isNull()); |
- if (compoundSelector->pseudoType() == CSSSelector::PseudoContent) |
- return rewriteSpecifiersWithElementNameForContentPseudoElement(tag, compoundSelector, elementName.isNull()); |
+ if (compoundSelector->pseudoType() == CSSSelector::PseudoContent || compoundSelector->pseudoType() == CSSSelector::PseudoSlotted) |
+ return rewriteSpecifiersWithElementNameForContentOrSlottedPseudoElement(tag, compoundSelector, elementName.isNull()); |
// *:host never matches, so we can't discard the * otherwise we can't tell the |
// difference between *:host and just :host. |
@@ -608,13 +623,14 @@ void CSSSelectorParser::rewriteSpecifiersWithElementNameForCustomPseudoElement(c |
lastShadowPseudo->setRelation(CSSSelector::ShadowPseudo); |
} |
-void CSSSelectorParser::rewriteSpecifiersWithElementNameForContentPseudoElement(const QualifiedName& tag, CSSParserSelector* specifiers, bool tagIsImplicit) |
+void CSSSelectorParser::rewriteSpecifiersWithElementNameForContentOrSlottedPseudoElement(const QualifiedName& tag, CSSParserSelector* specifiers, bool tagIsImplicit) |
{ |
CSSParserSelector* last = specifiers; |
CSSParserSelector* history = specifiers; |
while (history->tagHistory()) { |
history = history->tagHistory(); |
- if (history->pseudoType() == CSSSelector::PseudoContent || history->relationIsAffectedByPseudoContent()) |
+ if (history->pseudoType() == CSSSelector::PseudoContent || history->relationIsAffectedByPseudoContent() |
+ || history->pseudoType() == CSSSelector::PseudoSlotted || history->relationIsAffectedByPseudoSlotted()) |
last = history; |
} |
@@ -624,10 +640,10 @@ void CSSSelectorParser::rewriteSpecifiersWithElementNameForContentPseudoElement( |
return; |
} |
- // For shadow-ID pseudo-elements to be correctly matched, the ShadowPseudo combinator has to be used. |
- // We therefore create a new Selector with that combinator here in any case, even if matching any (host) element in any namespace (i.e. '*'). |
OwnPtr<CSSParserSelector> elementNameSelector = CSSParserSelector::create(tag); |
last->setTagHistory(elementNameSelector.release()); |
+ if (last->pseudoType() == CSSSelector::PseudoSlotted) |
+ last->setRelation(CSSSelector::ShadowSlot); |
} |
PassOwnPtr<CSSParserSelector> CSSSelectorParser::addSimpleSelectorToCompound(PassOwnPtr<CSSParserSelector> compoundSelector, PassOwnPtr<CSSParserSelector> simpleSelector) |