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

Side by Side Diff: third_party/WebKit/Source/core/css/RuleSet.cpp

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 determinePropertyWhitelistType(addRuleFlags, selector())), 132 determinePropertyWhitelistType(addRuleFlags, selector())),
133 m_descendantSelectorIdentifierHashes() { 133 m_descendantSelectorIdentifierHashes() {
134 SelectorFilter::collectIdentifierHashes( 134 SelectorFilter::collectIdentifierHashes(
135 selector(), m_descendantSelectorIdentifierHashes, maximumIdentifierCount); 135 selector(), m_descendantSelectorIdentifierHashes, maximumIdentifierCount);
136 } 136 }
137 137
138 void RuleSet::addToRuleSet(const AtomicString& key, 138 void RuleSet::addToRuleSet(const AtomicString& key,
139 PendingRuleMap& map, 139 PendingRuleMap& map,
140 const RuleData& ruleData) { 140 const RuleData& ruleData) {
141 Member<HeapLinkedStack<RuleData>>& rules = 141 Member<HeapLinkedStack<RuleData>>& rules =
142 map.add(key, nullptr).storedValue->value; 142 map.insert(key, nullptr).storedValue->value;
143 if (!rules) 143 if (!rules)
144 rules = new HeapLinkedStack<RuleData>; 144 rules = new HeapLinkedStack<RuleData>;
145 rules->push(ruleData); 145 rules->push(ruleData);
146 } 146 }
147 147
148 static void extractValuesforSelector(const CSSSelector* selector, 148 static void extractValuesforSelector(const CSSSelector* selector,
149 AtomicString& id, 149 AtomicString& id,
150 AtomicString& className, 150 AtomicString& className,
151 AtomicString& customPseudoElementName, 151 AtomicString& customPseudoElementName,
152 AtomicString& tagName) { 152 AtomicString& tagName) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 selectorIndex = 344 selectorIndex =
345 rule->selectorList().indexOfNextSelectorAfter(selectorIndex)) 345 rule->selectorList().indexOfNextSelectorAfter(selectorIndex))
346 addRule(rule, selectorIndex, addRuleFlags); 346 addRule(rule, selectorIndex, addRuleFlags);
347 } 347 }
348 348
349 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, 349 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap,
350 CompactRuleMap& compactMap) { 350 CompactRuleMap& compactMap) {
351 for (auto& item : pendingMap) { 351 for (auto& item : pendingMap) {
352 HeapLinkedStack<RuleData>* pendingRules = item.value.release(); 352 HeapLinkedStack<RuleData>* pendingRules = item.value.release();
353 CompactRuleMap::ValueType* compactRules = 353 CompactRuleMap::ValueType* compactRules =
354 compactMap.add(item.key, nullptr).storedValue; 354 compactMap.insert(item.key, nullptr).storedValue;
355 355
356 HeapTerminatedArrayBuilder<RuleData> builder(compactRules->value.release()); 356 HeapTerminatedArrayBuilder<RuleData> builder(compactRules->value.release());
357 builder.grow(pendingRules->size()); 357 builder.grow(pendingRules->size());
358 while (!pendingRules->isEmpty()) { 358 while (!pendingRules->isEmpty()) {
359 builder.append(pendingRules->peek()); 359 builder.append(pendingRules->peek());
360 pendingRules->pop(); 360 pendingRules->pop();
361 } 361 }
362 362
363 compactRules->value = builder.release(); 363 compactRules->value = builder.release();
364 } 364 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 #ifndef NDEBUG 428 #ifndef NDEBUG
429 void RuleSet::show() const { 429 void RuleSet::show() const {
430 for (const auto& rule : m_allRules) 430 for (const auto& rule : m_allRules)
431 rule.selector().show(); 431 rule.selector().show();
432 } 432 }
433 #endif 433 #endif
434 434
435 } // namespace blink 435 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/RuleFeature.cpp ('k') | third_party/WebKit/Source/core/css/StyleSheetContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698