void ElementRuleCollector::matchUARules(RuleSet* rules) { clearMatchedRules(); m_result.ranges.lastUARule = m_result.matchedProperties.size() - 1; StyleResolver::RuleRange ruleRange = m_result.ranges.UARuleRange(); collectMatchingRules(MatchRequest(rules), ruleRange); sortAndTransferMatchedRules(); }
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) { clearMatchedRules(); m_mode = SelectorChecker::SharingRules; int firstRuleIndex = -1, lastRuleIndex = -1; StyleResolver::RuleRange ruleRange(firstRuleIndex, lastRuleIndex); collectMatchingRules(MatchRequest(ruleSet), ruleRange); return m_matchedRules && !m_matchedRules->isEmpty(); }
bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet* ruleSet) { clearMatchedRules(); m_mode = SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements; int firstRuleIndex = -1, lastRuleIndex = -1; StyleResolver::RuleRange ruleRange(firstRuleIndex, lastRuleIndex); collectMatchingRules(MatchRequest(ruleSet), ruleRange); return !m_matchedRules.isEmpty(); }
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) { clearMatchedRules(); m_mode = SelectorChecker::SharingRules; // To check whether a given RuleSet has any rule matching a given element, // should not see the element's treescope. Because RuleSet has no information // about "scope". MatchRequest matchRequest(ruleSet); collectMatchingRules(matchRequest); collectMatchingShadowHostRules(matchRequest); return !m_matchedRules.isEmpty(); }
void ElementRuleCollector::matchAuthorRules(bool includeEmptyRules) { clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1; // Match global author rules. MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules); StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); sortAndTransferMatchedRules(); }
void ElementRuleCollector::matchUserRules(bool includeEmptyRules) { if (!m_ruleSets.userStyle()) return; clearMatchedRules(); m_result.ranges.lastUserRule = m_result.matchedProperties.size() - 1; MatchRequest matchRequest(m_ruleSets.userStyle(), includeEmptyRules); StyleResolver::RuleRange ruleRange = m_result.ranges.userRuleRange(); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); sortAndTransferMatchedRules(); }
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) { clearMatchedRules(); m_mode = SelectorChecker::SharingRules; // To check whether a given RuleSet has any rule matching a given element, // should not see the element's treescope. Because RuleSet has no // information about "scope". int firstRuleIndex = -1, lastRuleIndex = -1; RuleRange ruleRange(firstRuleIndex, lastRuleIndex); // FIXME: Verify whether it's ok to ignore CascadeScope here. collectMatchingRules(MatchRequest(ruleSet), ruleRange, SelectorChecker::StaysWithinTreeScope); return m_matchedRules && !m_matchedRules->isEmpty(); }
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet) { clearMatchedRules(); m_mode = SelectorChecker::SharingRules; // To check whether a given RuleSet has any rule matching a given element, // should not see the element's treescope. Because RuleSet has no // information about "scope". m_behaviorAtBoundary = SelectorChecker::StaysWithinTreeScope; int firstRuleIndex = -1, lastRuleIndex = -1; StyleResolver::RuleRange ruleRange(firstRuleIndex, lastRuleIndex); collectMatchingRules(MatchRequest(ruleSet), ruleRange); return m_matchedRules && !m_matchedRules->isEmpty(); }
void ElementRuleCollector::matchAuthorRules(bool includeEmptyRules) { #if ENABLE(SHADOW_DOM) if (m_element.shadowRoot()) matchHostPseudoClassRules(includeEmptyRules); #endif clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; // Match global author rules. MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); sortAndTransferMatchedRules(); }
void ElementRuleCollector::matchAuthorRules(bool includeEmptyRules) { clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1; if (!m_state.element()) return; // Match global author rules. MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules); StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); #if ENABLE(SHADOW_DOM) matchShadowDistributedRules(includeEmptyRules, ruleRange); #endif sortAndTransferMatchedRules(); matchScopedAuthorRules(includeEmptyRules); }
void ElementRuleCollector::matchHostPseudoClassRules(bool includeEmptyRules) { ASSERT(m_element.shadowRoot()); auto& shadowAuthorStyle = *m_element.shadowRoot()->styleResolver().ruleSets().authorStyle(); auto& shadowHostRules = shadowAuthorStyle.hostPseudoClassRules(); if (shadowHostRules.isEmpty()) return; clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; auto ruleRange = m_result.ranges.authorRuleRange(); MatchRequest matchRequest(&shadowAuthorStyle, includeEmptyRules); collectMatchingRulesForList(&shadowHostRules, matchRequest, ruleRange); // We just sort the host rules before other author rules. This matches the current vague spec language // but is not necessarily exactly what is needed. // FIXME: Match the spec when it is finalized. sortAndTransferMatchedRules(); }
void ElementRuleCollector::matchAuthorRules(bool includeEmptyRules) { clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); // Match global author rules. MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); auto* parent = m_element.parentElement(); if (parent && parent->shadowRoot()) matchSlottedPseudoElementRules(matchRequest, ruleRange); if (m_element.shadowRoot()) matchHostPseudoClassRules(matchRequest, ruleRange); sortAndTransferMatchedRules(); }
void ElementRuleCollector::matchHostRules(bool includeEmptyRules) { #if ENABLE(SHADOW_DOM) ASSERT(m_scopeResolver); clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1; Vector<RuleSet*> matchedRules; m_scopeResolver->matchHostRules(m_state.element(), matchedRules); if (matchedRules.isEmpty()) return; for (unsigned i = matchedRules.size(); i > 0; --i) { StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRules(MatchRequest(matchedRules.at(i-1), includeEmptyRules, m_state.element()), ruleRange); } sortAndTransferMatchedRules(); #else UNUSED_PARAM(includeEmptyRules); #endif }
void ElementRuleCollector::matchScopedAuthorRules(bool includeEmptyRules) { #if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM) if (!m_scopeResolver) return; // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent). if (m_scopeResolver->hasScopedStyles() && m_scopeResolver->ensureStackConsistency(m_state.element())) { bool applyAuthorStyles = m_state.element()->treeScope()->applyAuthorStyles(); bool documentScope = true; unsigned scopeSize = m_scopeResolver->stackSize(); for (unsigned i = 0; i < scopeSize; ++i) { clearMatchedRules(); m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1; const StyleScopeResolver::StackFrame& frame = m_scopeResolver->stackFrameAt(i); documentScope = documentScope && !frame.m_scope->isInShadowTree(); if (documentScope) { if (!applyAuthorStyles) continue; } else { if (!m_scopeResolver->matchesStyleBounds(frame)) continue; } MatchRequest matchRequest(frame.m_ruleSet, includeEmptyRules, frame.m_scope); StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRules(matchRequest, ruleRange); collectMatchingRulesForRegion(matchRequest, ruleRange); sortAndTransferMatchedRules(); } } matchHostRules(includeEmptyRules); #else UNUSED_PARAM(includeEmptyRules); #endif }
std::unique_ptr<RuleSet::RuleDataVector> ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules) { ASSERT(is<HTMLSlotElement>(m_element)); clearMatchedRules(); m_mode = SelectorChecker::Mode::CollectingRules; // Match global author rules. MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); collectMatchingRulesForList(&m_authorStyle.slottedPseudoElementRules(), matchRequest, ruleRange); if (m_matchedRules.isEmpty()) return { }; auto ruleDataVector = std::make_unique<RuleSet::RuleDataVector>(); ruleDataVector->reserveInitialCapacity(m_matchedRules.size()); for (auto& matchedRule : m_matchedRules) ruleDataVector->uncheckedAppend(*matchedRule.ruleData); return ruleDataVector; }