void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector* selector)
{
    if (selector->m_match == CSSSelector::Id)
        idsInRules.add(selector->value().impl());
    else if (selector->m_match == CSSSelector::Class)
        classesInRules.add(selector->value().impl());
    else if (selector->isAttributeSelector())
        attrsInRules.add(selector->attribute().localName().impl());
    switch (selector->pseudoType()) {
    case CSSSelector::PseudoFirstLine:
        m_usesFirstLineRules = true;
        break;
    case CSSSelector::PseudoBefore:
    case CSSSelector::PseudoAfter:
        m_usesBeforeAfterRules = true;
        break;
    case CSSSelector::PseudoPart:
        attrsInRules.add(HTMLNames::partAttr.localName().impl());
        break;
    case CSSSelector::PseudoHost:
        collectFeaturesFromSelectorList(selector->selectorList());
        break;
    default:
        break;
    }
}
void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, RuleFeatureSet::FeatureMetadata& metadata, SelectorFeatureCollectionMode collectionMode)
{
    unsigned maxDirectAdjacentSelectors = 0;

    for (const CSSSelector* current = &selector; current; current = current->tagHistory()) {
        if (current->m_match == CSSSelector::Id) {
            metadata.idsInRules.add(current->value());
        } else if (current->m_match == CSSSelector::Class && collectionMode == ProcessClasses) {
            DescendantInvalidationSet& invalidationSet = ensureClassInvalidationSet(current->value());
            invalidationSet.setWholeSubtreeInvalid();
        } else if (current->isAttributeSelector()) {
            metadata.attrsInRules.add(current->attribute().localName());
        }
        if (current->pseudoType() == CSSSelector::PseudoFirstLine)
            metadata.usesFirstLineRules = true;
        if (current->isDirectAdjacentSelector()) {
            maxDirectAdjacentSelectors++;
        } else if (maxDirectAdjacentSelectors) {
            if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors)
                metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors;
            maxDirectAdjacentSelectors = 0;
        }
        if (current->isSiblingSelector())
            metadata.foundSiblingSelector = true;

        collectFeaturesFromSelectorList(current->selectorList(), metadata, collectionMode);
    }

    ASSERT(!maxDirectAdjacentSelectors);
}
Exemple #3
0
void RuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& selector, RuleFeatureSet::FeatureMetadata& metadata, InvalidationSetMode mode)
{
    unsigned maxDirectAdjacentSelectors = 0;

    for (const CSSSelector* current = &selector; current; current = current->tagHistory()) {
        if (mode != AddFeatures) {
            if (DescendantInvalidationSet* invalidationSet = invalidationSetForSelector(*current)) {
                if (mode == UseSubtreeStyleChange)
                    invalidationSet->setWholeSubtreeInvalid();
            }
        }
        if (current->pseudoType() == CSSSelector::PseudoFirstLine)
            metadata.usesFirstLineRules = true;
        if (current->isDirectAdjacentSelector()) {
            maxDirectAdjacentSelectors++;
        } else if (maxDirectAdjacentSelectors) {
            if (maxDirectAdjacentSelectors > metadata.maxDirectAdjacentSelectors)
                metadata.maxDirectAdjacentSelectors = maxDirectAdjacentSelectors;
            maxDirectAdjacentSelectors = 0;
        }
        if (current->isSiblingSelector())
            metadata.foundSiblingSelector = true;

        collectFeaturesFromSelectorList(current->selectorList(), metadata, mode);

        if (mode == UseLocalStyleChange && current->relation() != CSSSelector::SubSelector)
            mode = UseSubtreeStyleChange;
    }

    ASSERT(!maxDirectAdjacentSelectors);
}
void SelectRuleFeatureSet::collectFeaturesFromSelectorList(
    const CSSSelectorList& list) {
  for (const CSSSelector* selector = list.first(); selector;
       selector = CSSSelectorList::next(*selector)) {
    for (const CSSSelector* component = selector; component;
         component = component->tagHistory()) {
      if (invalidationSetForSimpleSelector(*component, InvalidateDescendants))
        continue;

      if (component->selectorList())
        collectFeaturesFromSelectorList(*component->selectorList());
    }
  }
}