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

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

Issue 1480973002: CSS Invalidation: Avoid virtual functions in InvalidationSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no protected destructor Created 5 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 | « 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 3a922578091629e909d550cd1c2a5b741f410fad..f6010ee4023ae5e8b2fafaa91a667def100f770a 100644
--- a/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
+++ b/third_party/WebKit/Source/core/css/invalidation/InvalidationSet.h
@@ -58,10 +58,8 @@ class CORE_EXPORT InvalidationSet : public RefCounted<InvalidationSet> {
WTF_MAKE_NONCOPYABLE(InvalidationSet);
USING_FAST_MALLOC_WITH_TYPE_NAME(blink::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();
@@ -100,12 +98,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();
@@ -117,6 +124,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;
@@ -140,15 +149,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 {
@@ -158,8 +166,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