Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/CSSSelector.cpp |
| diff --git a/third_party/WebKit/Source/core/css/CSSSelector.cpp b/third_party/WebKit/Source/core/css/CSSSelector.cpp |
| index 3a40cb6d6e723789f75dbb111b07a776a24d645e..2c2e05bcd0afe439e4481760a5c7a33146a67c9c 100644 |
| --- a/third_party/WebKit/Source/core/css/CSSSelector.cpp |
| +++ b/third_party/WebKit/Source/core/css/CSSSelector.cpp |
| @@ -912,6 +912,51 @@ bool CSSSelector::matchesPseudoElement() const |
| return false; |
| } |
| +template <typename Functor> |
| +static bool forEachTagSelector(const Functor& functor, const CSSSelector& selector) |
|
rune
2016/09/02 09:14:31
This is a weird name. It sounds like it's looking
hayato
2016/09/05 02:36:11
I think this name is coming from CSSSelector::m_ta
|
| +{ |
| + for (const CSSSelector* current = &selector; current; current = current->tagHistory()) { |
| + if (functor(*current)) |
| + return true; |
| + if (const CSSSelectorList* selectorList = current->selectorList()) { |
| + for (const CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(*subSelector)) { |
| + if (forEachTagSelector(functor, *subSelector)) |
| + return true; |
| + } |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool CSSSelector::hasContentPseudo() const |
| +{ |
| + return forEachTagSelector([](const CSSSelector& selector) -> bool { |
| + return selector.relationIsAffectedByPseudoContent(); |
| + }, *this); |
| +} |
| + |
| +bool CSSSelector::hasSlottedPseudo() const |
| +{ |
| + return forEachTagSelector([](const CSSSelector& selector) -> bool { |
| + return selector.getPseudoType() == CSSSelector::PseudoSlotted; |
| + }, *this); |
| +} |
| + |
| +bool CSSSelector::hasDeepCombinatorOrShadowPseudo() const |
| +{ |
| + return forEachTagSelector([](const CSSSelector& selector) -> bool { |
| + return selector.relation() == CSSSelector::ShadowDeep || selector.getPseudoType() == CSSSelector::PseudoShadow; |
| + }, *this); |
| +} |
| + |
| +bool CSSSelector::needsUpdatedDistribution() const |
| +{ |
| + return forEachTagSelector([](const CSSSelector& selector) -> bool { |
| + return selector.relationIsAffectedByPseudoContent() || selector.getPseudoType() == CSSSelector::PseudoSlotted || selector.getPseudoType() == CSSSelector::PseudoHostContext; |
| + }, *this); |
| +} |
| + |
| CSSSelector::RareData::RareData(const AtomicString& value) |
| : m_matchingValue(value) |
| , m_serializingValue(value) |