Chromium Code Reviews| 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 076f85f14eb4f2913a189c91955f70fb1c273c62..72628a7d539ac7119fe46709b09b4544e7314eba 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; |
| @@ -374,6 +377,20 @@ PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumePseudo(CSSParserTokenRan |
| selector->adoptSelectorVector(selectorVector); |
| return selector.release(); |
| } |
| + case CSSSelector::PseudoSlotted: |
| + { |
| + DisallowPseudoElementsScope scope(this); |
| + |
| + 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(); |
|
rune
2016/01/13 09:59:09
I don't think you need this flag at all, only the
kochi
2016/01/14 09:02:20
Acknowledged.
|
| + return selector.release(); |
| + } |
| case CSSSelector::PseudoLang: |
| { |
| // FIXME: CSS Selectors Level 4 allows :lang(*-foo) |
| @@ -567,7 +584,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->needsImplicitShadowCrossingCombinatorForMatching()) |
| + if (elementName.isNull() && defaultNamespace() == starAtom && !compoundSelector->needsImplicitShadowCrossingCombinatorForMatching() && !compoundSelector->relationIsAffectedByPseudoSlotted()) |
| return; |
| AtomicString determinedElementName = elementName.isNull() ? starAtom : elementName; |
| @@ -579,8 +596,8 @@ void CSSSelectorParser::prependTypeSelectorIfNeeded(const AtomicString& namespac |
| if (compoundSelector->needsImplicitShadowCrossingCombinatorForMatching()) |
| 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. |
| @@ -615,13 +632,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; |
| } |
| @@ -631,10 +649,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) |