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

Unified Diff: third_party/WebKit/Source/core/css/RuleFeature.cpp

Issue 2377953003: CSS style invalidation: simplify updates to invalidation set collections (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/RuleFeature.cpp
diff --git a/third_party/WebKit/Source/core/css/RuleFeature.cpp b/third_party/WebKit/Source/core/css/RuleFeature.cpp
index 8357290f1b22d41e9964103d47766d12bd42e9c7..988e0367b1c288a152376e24921cbd9774e9609f 100644
--- a/third_party/WebKit/Source/core/css/RuleFeature.cpp
+++ b/third_party/WebKit/Source/core/css/RuleFeature.cpp
@@ -202,27 +202,36 @@ bool requiresSubtreeInvalidation(const CSSSelector& selector)
}
}
-template<class Map>
-InvalidationSet& ensureInvalidationSet(Map& map, const typename Map::KeyType& key, InvalidationType type)
+InvalidationSet& storedInvalidationSet(RefPtr<InvalidationSet>& invalidationSet, InvalidationType type)
{
- typename Map::AddResult addResult = map.add(key, nullptr);
- if (addResult.isNewEntry) {
+ if (!invalidationSet) {
if (type == InvalidateDescendants)
- addResult.storedValue->value = DescendantInvalidationSet::create();
+ invalidationSet = DescendantInvalidationSet::create();
else
- addResult.storedValue->value = SiblingInvalidationSet::create(nullptr);
- return *addResult.storedValue->value;
+ invalidationSet = SiblingInvalidationSet::create(nullptr);
+ return *invalidationSet;
}
- if (addResult.storedValue->value->type() == type)
- return *addResult.storedValue->value;
+ if (invalidationSet->type() == type)
+ return *invalidationSet;
if (type == InvalidateDescendants)
- return toSiblingInvalidationSet(addResult.storedValue->value.get())->ensureDescendants();
+ return toSiblingInvalidationSet(*invalidationSet).ensureDescendants();
- RefPtr<InvalidationSet> descendants = addResult.storedValue->value;
- RefPtr<InvalidationSet> siblings = SiblingInvalidationSet::create(toDescendantInvalidationSet(descendants.get()));
- addResult.storedValue->value = siblings;
- return *addResult.storedValue->value;
+ RefPtr<InvalidationSet> descendants = invalidationSet;
+ invalidationSet = SiblingInvalidationSet::create(toDescendantInvalidationSet(descendants.get()));
+ return *invalidationSet;
+}
+
+InvalidationSet& ensureInvalidationSet(HashMap<AtomicString, RefPtr<InvalidationSet>>& map, const AtomicString& key, InvalidationType type)
+{
+ RefPtr<InvalidationSet>& invalidationSet = map.add(key, nullptr).storedValue->value;
+ return storedInvalidationSet(invalidationSet, type);
+}
+
+InvalidationSet& ensureInvalidationSet(HashMap<CSSSelector::PseudoType, RefPtr<InvalidationSet>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>>& map, CSSSelector::PseudoType key, InvalidationType type)
+{
+ RefPtr<InvalidationSet>& invalidationSet = map.add(key, nullptr).storedValue->value;
+ return storedInvalidationSet(invalidationSet, type);
}
void extractInvalidationSets(InvalidationSet* invalidationSet, DescendantInvalidationSet*& descendants, SiblingInvalidationSet*& siblings)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698