void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; if (ruleMatches(ruleData)) { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); } } }
void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVector* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (!ruleData.canMatchPseudoElement() && m_pseudoStyleRequest.pseudoId != NOPSEUDO) continue; if (m_selectorFilter && m_selectorFilter->fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; unsigned specificity; if (ruleMatches(ruleData, specificity)) addMatchedRule(ruleData, specificity, matchRequest.treeContextOrdinal, ruleRange); } }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary, CascadeScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) { if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) return; StyleRule* rule = ruleData.rule(); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo, behaviorAtBoundary)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet* properties = rule->properties(); if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) return; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) return; // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingCSSRules || m_mode == SelectorChecker::CollectingStyleRules) return; // FIXME: Matching should not modify the style directly. if (m_style && dynamicPseudo < FIRST_INTERNAL_PSEUDOID) m_style->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeScope, cascadeOrder); return; } } }
void ElementRuleCollector::doCollectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; const StyleResolver::State& state = m_state; unsigned size = rules->size(); for (unsigned i = 0; i < size; ++i) { const RuleData& ruleData = rules->at(i); if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); InspectorInstrumentationCookie cookie; if (hasInspectorFrontends) cookie = InspectorInstrumentation::willMatchRule(document(), rule, m_inspectorCSSOMWrappers, document()->styleSheetCollection()); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet* properties = rule->properties(); if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingRules) { if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); continue; } if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) state.style()->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, true); continue; } } if (hasInspectorFrontends) InspectorInstrumentation::didMatchRule(cookie, false); } }
void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { if (!rules) return; for (unsigned i = 0, size = rules->size(); i < size; ++i) { const RuleData& ruleData = rules->data()[i]; if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) continue; StyleRule* rule = ruleData.rule(); PseudoId dynamicPseudo = NOPSEUDO; if (ruleMatches(ruleData, dynamicPseudo)) { // For SharingRules testing, any match is good enough, we don't care what is matched. if (m_mode == SelectorChecker::SharingRules || m_mode == SelectorChecker::StyleInvalidation) { addMatchedRule(&ruleData); break; } // If the rule has no properties to apply, then ignore it in the non-debug mode. const StyleProperties& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) continue; // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) continue; // If we're matching normal rules, set a pseudo bit if // we really just matched a pseudo-element. if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) { if (m_mode == SelectorChecker::CollectingRules) continue; if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID && m_style) m_style->setHasPseudoStyle(dynamicPseudo); } else { // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData); continue; } } } }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, CascadeOrder cascadeOrder, const MatchRequest& matchRequest) { StyleRule* rule = ruleData.rule(); if (ruleMatches(ruleData)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet& properties = rule->properties(); if (properties.isEmpty()) return; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeOrder, matchRequest.styleSheetIndex, matchRequest.styleSheet); } }
void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) { StyleRule* rule = ruleData.rule(); if (ruleMatches(ruleData, matchRequest.scope, contextFlags)) { // If the rule has no properties to apply, then ignore it in the non-debug mode. const StylePropertySet& properties = rule->properties(); if (properties.isEmpty() && !matchRequest.includeEmptyRules) return; // Update our first/last rule indices in the matched rules array. ++ruleRange.lastRuleIndex; if (ruleRange.firstRuleIndex == -1) ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; // Add this rule to our list of matched rules. addMatchedRule(&ruleData, cascadeScope, cascadeOrder, matchRequest.styleSheetIndex, matchRequest.styleSheet); } }
void ElementRuleCollector::matchHostPseudoClassRules(MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) { ASSERT(m_element.shadowRoot()); matchRequest.treeContextOrdinal++; auto& shadowAuthorStyle = m_element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle(); auto& shadowHostRules = shadowAuthorStyle.hostPseudoClassRules(); if (shadowHostRules.isEmpty()) return; SelectorChecker::CheckingContext context(m_mode); SelectorChecker selectorChecker(m_element.document()); for (auto& ruleData : shadowHostRules) { if (ruleData.rule()->properties().isEmpty() && !matchRequest.includeEmptyRules) continue; auto& selector = *ruleData.selector(); unsigned specificity = 0; if (!selectorChecker.matchHostPseudoClass(selector, m_element, context, specificity)) continue; addMatchedRule(ruleData, specificity, matchRequest.treeContextOrdinal, ruleRange); } }