Chromium Code Reviews| Index: Source/core/css/ElementRuleCollector.cpp |
| diff --git a/Source/core/css/ElementRuleCollector.cpp b/Source/core/css/ElementRuleCollector.cpp |
| index f2d222b482ccd07df9c0c35a09c992fac3e364cd..934264d73435c3b64d2964a3b89260bd8fc37ec0 100644 |
| --- a/Source/core/css/ElementRuleCollector.cpp |
| +++ b/Source/core/css/ElementRuleCollector.cpp |
| @@ -206,57 +206,66 @@ inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co |
| return true; |
| } |
| -void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) |
| +void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) |
| { |
| - if (!rules) |
| + if (m_canUseFastReject && m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(ruleData.descendantSelectorIdentifierHashes())) |
| return; |
| - const StyleResolverState& 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 = 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)) { |
| - 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()) { |
| + StyleRule* rule = ruleData.rule(); |
| + InspectorInstrumentationCookie 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)) { |
| + InspectorInstrumentation::didMatchRule(cookie, false); |
| + return; |
| + } |
| + // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed. |
| + if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) { |
| + InspectorInstrumentation::didMatchRule(cookie, false); |
| + 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::CollectingRules) { |
| 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) { |
| - 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); |
| - InspectorInstrumentation::didMatchRule(cookie, true); |
| - continue; |
| + return; |
| } |
| + if (dynamicPseudo < FIRST_INTERNAL_PSEUDOID) |
| + m_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); |
| + InspectorInstrumentation::didMatchRule(cookie, true); |
| + return; |
| } |
| - InspectorInstrumentation::didMatchRule(cookie, false); |
| } |
| + InspectorInstrumentation::didMatchRule(cookie, false); |
| +} |
| + |
| +void ElementRuleCollector::collectMatchingRulesForList(const RuleData* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) |
| +{ |
| + if (!rules) |
| + return; |
| + while (!rules->isLastInArray()) |
| + collectRuleIfMatches(*rules++, matchRequest, ruleRange); |
|
esprehn
2013/06/26 00:37:33
you could maybe do/while {} but I don't know if th
abarth-chromium
2013/06/26 00:57:00
Yeah, I tried a few permutations of this loop, and
|
| + collectRuleIfMatches(*rules++, matchRequest, ruleRange); |
|
esprehn
2013/06/26 00:37:33
No reason to increment here.
abarth-chromium
2013/06/26 00:57:00
Done.
|
| +} |
| + |
| +void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) |
| +{ |
| + if (!rules) |
| + return; |
| + unsigned size = rules->size(); |
| + for (unsigned i = 0; i < size; ++i) |
| + collectRuleIfMatches(rules->at(i), matchRequest, ruleRange); |
| } |
| static inline bool compareRules(const RuleData* r1, const RuleData* r2) |