void RuleFeatureSet::extractInvalidationSetFeature(const CSSSelector& selector, InvalidationSetFeatures& features) { if (selector.m_match == CSSSelector::Tag) features.tagName = selector.tagQName().localName(); else if (selector.m_match == CSSSelector::Id) features.id = selector.value(); else if (selector.m_match == CSSSelector::Class) features.classes.append(selector.value()); else if (selector.isAttributeSelector()) features.attributes.append(selector.attribute().localName()); else if (selector.isCustomPseudoElement()) features.customPseudoElement = true; }
void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addRuleFlags) { RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); collectFeaturesFromRuleData(m_features, ruleData); CSSSelector* selector = ruleData.selector(); if (selector->m_match == CSSSelector::Id) { addToRuleSet(selector->value().impl(), m_idRules, ruleData); return; } if (selector->m_match == CSSSelector::Class) { addToRuleSet(selector->value().impl(), m_classRules, ruleData); return; } if (selector->isCustomPseudoElement()) { addToRuleSet(selector->value().impl(), m_shadowPseudoElementRules, ruleData); return; } #if ENABLE(VIDEO_TRACK) if (selector->pseudoType() == CSSSelector::PseudoCue) { m_cuePseudoRules.append(ruleData); return; } #endif if (SelectorChecker::isCommonPseudoClassSelector(selector)) { switch (selector->pseudoType()) { case CSSSelector::PseudoLink: case CSSSelector::PseudoVisited: case CSSSelector::PseudoAnyLink: m_linkPseudoClassRules.append(ruleData); return; case CSSSelector::PseudoFocus: m_focusPseudoClassRules.append(ruleData); return; default: ASSERT_NOT_REACHED(); } return; } const AtomicString& localName = selector->tag().localName(); if (localName != starAtom) { addToRuleSet(localName.impl(), m_tagRules, ruleData); return; } m_universalRules.append(ruleData); }
static bool isSkippableComponentForInvalidation(const CSSSelector& selector) { if (selector.m_match == CSSSelector::Tag || selector.m_match == CSSSelector::Id || selector.isAttributeSelector()) return true; if (selector.m_match == CSSSelector::PseudoElement) { switch (selector.pseudoType()) { case CSSSelector::PseudoBefore: case CSSSelector::PseudoAfter: case CSSSelector::PseudoBackdrop: case CSSSelector::PseudoShadow: return true; default: return selector.isCustomPseudoElement(); } } if (selector.m_match != CSSSelector::PseudoClass) return false; switch (selector.pseudoType()) { case CSSSelector::PseudoEmpty: case CSSSelector::PseudoFirstChild: case CSSSelector::PseudoFirstOfType: case CSSSelector::PseudoLastChild: case CSSSelector::PseudoLastOfType: case CSSSelector::PseudoOnlyChild: case CSSSelector::PseudoOnlyOfType: case CSSSelector::PseudoNthChild: case CSSSelector::PseudoNthOfType: case CSSSelector::PseudoNthLastChild: case CSSSelector::PseudoNthLastOfType: case CSSSelector::PseudoLink: case CSSSelector::PseudoVisited: case CSSSelector::PseudoAnyLink: case CSSSelector::PseudoHover: case CSSSelector::PseudoDrag: case CSSSelector::PseudoFocus: case CSSSelector::PseudoActive: case CSSSelector::PseudoChecked: case CSSSelector::PseudoEnabled: case CSSSelector::PseudoDefault: case CSSSelector::PseudoDisabled: case CSSSelector::PseudoOptional: case CSSSelector::PseudoRequired: case CSSSelector::PseudoReadOnly: case CSSSelector::PseudoReadWrite: case CSSSelector::PseudoValid: case CSSSelector::PseudoInvalid: case CSSSelector::PseudoIndeterminate: case CSSSelector::PseudoTarget: case CSSSelector::PseudoLang: case CSSSelector::PseudoRoot: case CSSSelector::PseudoScope: case CSSSelector::PseudoInRange: case CSSSelector::PseudoOutOfRange: case CSSSelector::PseudoUnresolved: return true; default: return false; } }