Esempio n. 1
0
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
{
    ASSERT(matchRequest.ruleSet);
    ASSERT(m_context.element());

    Element& element = *m_context.element();

    // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
    // a) it's a UA rule
    // b) the tree scope allows author rules
    // c) the rules comes from a scoped style sheet within the same tree scope
    // d) the rules comes from a scoped style sheet within an active shadow root whose host is the given element
    // e) the rules can cross boundaries
    // b)-e) is checked in rulesApplicableInCurrentTreeScope.
    if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope, matchRequest.elementApplyAuthorStyles))
        return;

    // We need to collect the rules for id, class, tag, and everything else into a buffer and
    // then sort the buffer.
    if (element.hasID())
        collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForStyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange);
    if (element.isStyledElement() && element.hasClass()) {
        for (size_t i = 0; i < element.classNames().size(); ++i)
            collectMatchingRulesForList(matchRequest.ruleSet->classRules(element.classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange);
    }

    collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localName()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange);
    collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange);
}
Esempio n. 2
0
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, RuleRange& ruleRange, CascadeScope cascadeScope, CascadeOrder cascadeOrder, bool matchingTreeBoundaryRules)
{
    ASSERT(matchRequest.ruleSet);
    ASSERT(m_context.element());

    Element& element = *m_context.element();
    const AtomicString& pseudoId = element.shadowPseudoId();
    if (!pseudoId.isEmpty()) {
        ASSERT(element.isStyledElement());
        collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), ignoreCascadeScope, cascadeOrder, matchRequest, ruleRange);
    }

    if (element.isVTTElement())
        collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
    // a) it's a UA rule
    // b) the rules comes from a scoped style sheet within the same tree scope
    // c) the rules comes from a scoped style sheet within an active shadow root whose host is the given element
    // d) the rules can cross boundaries
    // b)-e) is checked in rulesApplicableInCurrentTreeScope.
    if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope, matchingTreeBoundaryRules))
        return;

    // We need to collect the rules for id, class, tag, and everything else into a buffer and
    // then sort the buffer.
    if (element.hasID())
        collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForStyleResolution()), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    if (element.isStyledElement() && element.hasClass()) {
        for (size_t i = 0; i < element.classNames().size(); ++i)
            collectMatchingRulesForList(matchRequest.ruleSet->classRules(element.classNames()[i]), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    }

    if (element.isLink())
        collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    if (SelectorChecker::matchesFocusPseudoClass(element))
        collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localName()), cascadeScope, cascadeOrder, matchRequest, ruleRange);
    collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), cascadeScope, cascadeOrder, matchRequest, ruleRange);
}
Esempio n. 3
0
DISABLE_CFI_PERF
void ElementRuleCollector::collectMatchingRules(
    const MatchRequest& matchRequest,
    CascadeOrder cascadeOrder,
    bool matchingTreeBoundaryRules) {
  ASSERT(matchRequest.ruleSet);
  ASSERT(m_context.element());

  Element& element = *m_context.element();
  const AtomicString& pseudoId = element.shadowPseudoId();
  if (!pseudoId.isEmpty()) {
    ASSERT(element.isStyledElement());
    collectMatchingRulesForList(
        matchRequest.ruleSet->shadowPseudoElementRules(pseudoId), cascadeOrder,
        matchRequest);
    if (pseudoId == "-webkit-input-placeholder") {
      collectMatchingRulesForList(
          matchRequest.ruleSet->placeholderPseudoRules(), cascadeOrder,
          matchRequest);
    }
  }

  if (element.isVTTElement())
    collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(),
                                cascadeOrder, matchRequest);
  // Check whether other types of rules are applicable in the current tree
  // scope. Criteria for this:
  // a) the rules are UA rules.
  // b) matching tree boundary crossing rules.
  // c) the rules come from a shadow style sheet in the same tree scope as the
  //    given element.
  // c) is checked in rulesApplicableInCurrentTreeScope.
  if (!m_matchingUARules && !matchingTreeBoundaryRules &&
      !rulesApplicableInCurrentTreeScope(&element, matchRequest.scope))
    return;

  // We need to collect the rules for id, class, tag, and everything else into a
  // buffer and then sort the buffer.
  if (element.hasID())
    collectMatchingRulesForList(
        matchRequest.ruleSet->idRules(element.idForStyleResolution()),
        cascadeOrder, matchRequest);
  if (element.isStyledElement() && element.hasClass()) {
    for (size_t i = 0; i < element.classNames().size(); ++i)
      collectMatchingRulesForList(
          matchRequest.ruleSet->classRules(element.classNames()[i]),
          cascadeOrder, matchRequest);
  }

  if (element.isLink())
    collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(),
                                cascadeOrder, matchRequest);
  if (SelectorChecker::matchesFocusPseudoClass(element))
    collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(),
                                cascadeOrder, matchRequest);
  collectMatchingRulesForList(
      matchRequest.ruleSet->tagRules(element.localNameForSelectorMatching()),
      cascadeOrder, matchRequest);
  collectMatchingRulesForList(matchRequest.ruleSet->universalRules(),
                              cascadeOrder, matchRequest);
}