Beispiel #1
0
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();
}
Beispiel #2
0
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();
}
Beispiel #4
0
inline void ElementRuleCollector::matchShadowDistributedRules(bool includeEmptyRules, StyleResolver::RuleRange& ruleRange)
{
    if (m_ruleSets.shadowDistributedRules().isEmpty())
        return;

    TemporaryChange<bool> canUseFastReject(m_canUseFastReject, false);
    TemporaryChange<SelectorChecker::BehaviorAtBoundary> behaviorAtBoundary(m_behaviorAtBoundary, SelectorChecker::CrossesBoundary);

    Vector<MatchRequest> matchRequests;
    m_ruleSets.shadowDistributedRules().collectMatchRequests(includeEmptyRules, matchRequests);
    for (size_t i = 0; i < matchRequests.size(); ++i)
        collectMatchingRules(matchRequests[i], ruleRange);
}
Beispiel #5
0
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();
}
Beispiel #7
0
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();
}
Beispiel #8
0
void ElementRuleCollector::collectMatchingRulesForRegion(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
{
    if (!m_regionForStyling)
        return;

    unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size();
    for (unsigned i = 0; i < size; ++i) {
        const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector;
        if (checkRegionSelector(regionSelector, toElement(m_regionForStyling->node()))) {
            RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
            ASSERT(regionRules);
            collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange);
        }
    }
}
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();
}
void ElementRuleCollector::collectMatchingRulesForRegion(const MatchRequest& matchRequest, RuleRange& ruleRange, SelectorChecker::BehaviorAtBoundary behaviorAtBoundary, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
{
    if (!m_regionForStyling)
        return;

    unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size();
    for (unsigned i = 0; i < size; ++i) {
        const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector;
        if (checkRegionSelector(regionSelector, toElement(m_regionForStyling->node()))) {
            RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
            ASSERT(regionRules);
            collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange, behaviorAtBoundary, cascadeScope, cascadeOrder);
        }
    }
}
Beispiel #11
0
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();
}
Beispiel #13
0
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::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();
}
Beispiel #15
0
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
}
Beispiel #16
0
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
}