Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: Source/core/css/ElementRuleCollector.cpp

Issue 795043002: Have ElementRuleCollector keep match result vector as part object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove a local binding Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/ElementRuleCollector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/ElementRuleCollector.cpp
diff --git a/Source/core/css/ElementRuleCollector.cpp b/Source/core/css/ElementRuleCollector.cpp
index d7c7a0e596bc0ab06ef9ca89b5d1db75176712e3..6683d405535be1e8d6703779331f1531e3c690c7 100644
--- a/Source/core/css/ElementRuleCollector.cpp
+++ b/Source/core/css/ElementRuleCollector.cpp
@@ -81,16 +81,12 @@ PassRefPtrWillBeRawPtr<CSSRuleList> ElementRuleCollector::matchedCSSRuleList()
inline void ElementRuleCollector::addMatchedRule(const RuleData* rule, unsigned specificity, CascadeScope cascadeScope, CascadeOrder cascadeOrder, unsigned styleSheetIndex, const CSSStyleSheet* parentStyleSheet)
{
- if (!m_matchedRules)
- m_matchedRules = adoptPtrWillBeNoop(new WillBeHeapVector<MatchedRule, 32>);
- m_matchedRules->append(MatchedRule(rule, specificity, cascadeScope, cascadeOrder, styleSheetIndex, parentStyleSheet));
+ m_matchedRules.append(MatchedRule(rule, specificity, cascadeScope, cascadeOrder, styleSheetIndex, parentStyleSheet));
}
void ElementRuleCollector::clearMatchedRules()
{
- if (!m_matchedRules)
- return;
- m_matchedRules->clear();
+ m_matchedRules.clear();
}
inline StyleRuleList* ElementRuleCollector::ensureStyleRuleList()
@@ -227,28 +223,27 @@ void ElementRuleCollector::appendCSSOMWrapperForRule(CSSStyleSheet* parentStyleS
void ElementRuleCollector::sortAndTransferMatchedRules()
{
- if (!m_matchedRules || m_matchedRules->isEmpty())
+ if (m_matchedRules.isEmpty())
return;
sortMatchedRules();
- WillBeHeapVector<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());
+ for (unsigned i = 0; i < m_matchedRules.size(); ++i)
+ ensureStyleRuleList()->m_list.append(m_matchedRules[i].ruleData()->rule());
return;
}
if (m_mode == SelectorChecker::CollectingCSSRules) {
- for (unsigned i = 0; i < matchedRules.size(); ++i)
- appendCSSOMWrapperForRule(const_cast<CSSStyleSheet*>(matchedRules[i].parentStyleSheet()), matchedRules[i].ruleData()->rule());
+ 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 < matchedRules.size(); i++) {
+ for (unsigned i = 0; i < m_matchedRules.size(); i++) {
// FIXME: Matching should not modify the style directly.
- const RuleData* ruleData = matchedRules[i].ruleData();
+ const RuleData* ruleData = m_matchedRules[i].ruleData();
if (m_style && ruleData->containsUncommonAttributeSelector())
m_style->setUnique();
m_result.addMatchedProperties(&ruleData->rule()->properties(), ruleData->linkMatchType(), ruleData->propertyWhitelistType(m_matchingUARules));
@@ -330,8 +325,7 @@ static inline bool compareRules(const MatchedRule& matchedRule1, const MatchedRu
void ElementRuleCollector::sortMatchedRules()
{
- ASSERT(m_matchedRules);
- std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules);
+ std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules);
}
bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet)
@@ -347,7 +341,7 @@ bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet)
// FIXME: Verify whether it's ok to ignore CascadeScope here.
collectMatchingRules(MatchRequest(ruleSet), ruleRange);
- return m_matchedRules && !m_matchedRules->isEmpty();
+ return !m_matchedRules.isEmpty();
}
} // namespace blink
« no previous file with comments | « Source/core/css/ElementRuleCollector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698