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

Unified Diff: third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h

Issue 1580503004: CSS Invalidation: Avoid virtual functions in InvalidationSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 4 years, 11 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 | third_party/WebKit/Source/core/css/invalidation/InvalidationSet.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
diff --git a/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h b/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
index 44ae6c66c56df90f365a8880388e4e7809e278ad..fc086a94dacb1d8b81a0194555e385da99e5f4b9 100644
--- a/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
+++ b/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
@@ -56,10 +56,8 @@ enum InvalidationType {
class CORE_EXPORT InvalidationSet : public RefCounted<InvalidationSet> {
WTF_MAKE_NONCOPYABLE(InvalidationSet);
public:
- virtual ~InvalidationSet() {}
-
- virtual bool isDescendantInvalidationSet() const { return false; }
- virtual bool isSiblingInvalidationSet() const { return false; }
+ bool isDescendantInvalidationSet() const { return m_type == InvalidateDescendants; }
+ bool isSiblingInvalidationSet() const { return m_type == InvalidateSiblings; }
static void cacheTracingFlag();
@@ -98,12 +96,21 @@ public:
const HashSet<AtomicString>& tagNameSetForTesting() const { ASSERT(m_tagNames); return *m_tagNames; }
const HashSet<AtomicString>& attributeSetForTesting() const { ASSERT(m_attributes); return *m_attributes; }
+ void deref()
+ {
+ if (!derefBase())
+ return;
+ destroy();
+ }
+
protected:
- InvalidationSet();
+ InvalidationSet(InvalidationType);
void combine(const InvalidationSet& other);
private:
+ void destroy();
+
HashSet<AtomicString>& ensureClassSet();
HashSet<AtomicString>& ensureIdSet();
HashSet<AtomicString>& ensureTagNameSet();
@@ -115,6 +122,8 @@ private:
OwnPtr<HashSet<AtomicString>> m_tagNames;
OwnPtr<HashSet<AtomicString>> m_attributes;
+ unsigned m_type : 1;
+
// If true, all descendants might be invalidated, so a full subtree recalc is required.
unsigned m_allDescendantsMightBeInvalid : 1;
@@ -138,15 +147,14 @@ public:
return adoptRef(new DescendantInvalidationSet);
}
- bool isDescendantInvalidationSet() const final { return true; }
-
void combine(const DescendantInvalidationSet& other)
{
InvalidationSet::combine(other);
}
private:
- DescendantInvalidationSet() {}
+ DescendantInvalidationSet()
+ : InvalidationSet(InvalidateDescendants) {}
};
class CORE_EXPORT SiblingInvalidationSet final : public InvalidationSet {
@@ -156,8 +164,6 @@ public:
return adoptRef(new SiblingInvalidationSet);
}
- bool isSiblingInvalidationSet() const final { return true; }
-
void combine(const SiblingInvalidationSet& other);
DescendantInvalidationSet& descendants() { return *m_descendantInvalidationSet; }
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/invalidation/InvalidationSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698