static bool forEachSelector(Functor& functor, const CSSSelectorList* selectorList) { for (CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(selector)) { if (forEachTagSelector(functor, selector)) return true; } return false; }
static bool forEachTagSelector(Functor& functor, CSSSelector* selector) { ASSERT(selector); do { if (functor(selector)) return true; if (CSSSelector* simpleSelector = selector->simpleSelector()) { if (forEachTagSelector(functor, simpleSelector)) return true; } } while ((selector = selector->tagHistory())); return false; }
static bool forEachTagSelector(Functor& functor, const CSSSelector& selector) { 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; }
static bool forEachTagSelector(Functor& functor, CSSSelector* selector) { ASSERT(selector); do { if (functor(selector)) return true; if (CSSSelectorList* selectorList = selector->selectorList()) { for (CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(subSelector)) { if (forEachTagSelector(functor, subSelector)) return true; } } } while ((selector = selector->tagHistory())); return false; }
bool CSSSelectorList::selectorCrossesTreeScopes(size_t index) const { SelectorCrossesTreeScopes functor; return forEachTagSelector(functor, selectorAt(index)); }
bool CSSSelectorList::hasShadowDistributedAt(size_t index) const { SelectorHasShadowDistributed functor; return forEachTagSelector(functor, selectorAt(index)); }
bool CSSSelectorList::hasCombinatorCrossingTreeBoundaryAt(size_t index) const { SelectorHasCombinatorCrossingTreeBoundary functor; return forEachTagSelector(functor, selectorAt(index)); }
bool CSSSelectorList::selectorNeedsUpdatedDistribution(size_t index) const { return forEachTagSelector([](const CSSSelector& selector) -> bool { return selector.relationIsAffectedByPseudoContent() || selector.pseudoType() == CSSSelector::PseudoSlotted || selector.pseudoType() == CSSSelector::PseudoHostContext; }, selectorAt(index)); }
bool CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(size_t index) const { return forEachTagSelector([](const CSSSelector& selector) -> bool { return selector.relation() == CSSSelector::ShadowDeep || selector.pseudoType() == CSSSelector::PseudoShadow; }, selectorAt(index)); }
bool CSSSelectorList::selectorHasSlottedPseudo(size_t index) const { return forEachTagSelector([](const CSSSelector& selector) -> bool { return selector.pseudoType() == CSSSelector::PseudoSlotted; }, selectorAt(index)); }
bool CSSSelectorList::selectorHasContentPseudo(size_t index) const { return forEachTagSelector([](const CSSSelector& selector) -> bool { return selector.relationIsAffectedByPseudoContent(); }, selectorAt(index)); }