Exemplo n.º 1
0
void ElementRuleCollector::sortAndTransferMatchedRules() {
  if (m_matchedRules.isEmpty())
    return;

  sortMatchedRules();

  if (m_mode == SelectorChecker::CollectingStyleRules) {
    for (unsigned i = 0; i < m_matchedRules.size(); ++i)
      ensureStyleRuleList()->append(m_matchedRules[i].ruleData()->rule());
    return;
  }

  if (m_mode == SelectorChecker::CollectingCSSRules) {
    for (unsigned i = 0; i < m_matchedRules.size(); ++i)
      appendCSSOMWrapperForRule(
          const_cast<CSSStyleSheet*>(m_matchedRules[i].parentStyleSheet()),
          m_matchedRules[i].ruleData()->rule());
    return;
  }

  // Now transfer the set of matched rules over to our list of declarations.
  for (unsigned i = 0; i < m_matchedRules.size(); i++) {
    const RuleData* ruleData = m_matchedRules[i].ruleData();
    m_result.addMatchedProperties(
        &ruleData->rule()->properties(), ruleData->linkMatchType(),
        ruleData->propertyWhitelist(m_matchingUARules));
  }
}
void ElementRuleCollector::sortAndTransferMatchedRules()
{
    if (!m_matchedRules || m_matchedRules->isEmpty())
        return;

    sortMatchedRules();

    Vector<MatchedRule, 32>& matchedRules = *m_matchedRules;
    if (m_mode == SelectorChecker::CollectingStyleRules) {
        for (unsigned i = 0; i < matchedRules.size(); ++i)
            ensureStyleRuleList()->m_list.append(matchedRules[i].ruleData()->rule());
        return;
    }

    if (m_mode == SelectorChecker::CollectingCSSRules) {
        for (unsigned i = 0; i < matchedRules.size(); ++i)
            appendCSSOMWrapperForRule(matchedRules[i].ruleData()->rule());
        return;
    }

    // Now transfer the set of matched rules over to our list of declarations.
    for (unsigned i = 0; i < matchedRules.size(); i++) {
        // FIXME: Matching should not modify the style directly.
        const RuleData* ruleData = matchedRules[i].ruleData();
        if (m_style && ruleData->containsUncommonAttributeSelector())
            m_style->setUnique();
        m_result.addMatchedProperties(ruleData->rule()->properties(), ruleData->rule(), ruleData->linkMatchType(), ruleData->propertyWhitelistType(m_matchingUARules));
    }
}