Chromium Code Reviews

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

Issue 1317533002: Sibling invalidation sets (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: Source/core/css/invalidation/InvalidationSet.h
diff --git a/Source/core/css/invalidation/DescendantInvalidationSet.h b/Source/core/css/invalidation/InvalidationSet.h
similarity index 74%
rename from Source/core/css/invalidation/DescendantInvalidationSet.h
rename to Source/core/css/invalidation/InvalidationSet.h
index 507d58fec0ccda9d635f4a0367c3707304469caf..7a0824eb6c3692bee52577f2749a786bb9f3b131 100644
--- a/Source/core/css/invalidation/DescendantInvalidationSet.h
+++ b/Source/core/css/invalidation/InvalidationSet.h
@@ -28,8 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DescendantInvalidationSet_h
-#define DescendantInvalidationSet_h
+#ifndef InvalidationSet_h
+#define InvalidationSet_h
#include "core/CoreExport.h"
#include "platform/heap/Handle.h"
@@ -47,25 +47,32 @@ class TracedValue;
// Tracks data to determine which elements of a DOM subtree need to have style
// recalculated.
esprehn 2015/09/10 08:54:53 comment needs updating?
Eric Willigers 2015/09/15 05:39:17 Done.
-class CORE_EXPORT DescendantInvalidationSet final : public RefCountedWillBeGarbageCollected<DescendantInvalidationSet> {
- WTF_MAKE_NONCOPYABLE(DescendantInvalidationSet);
+class CORE_EXPORT InvalidationSet final : public RefCountedWillBeGarbageCollected<InvalidationSet> {
rune 2015/09/10 13:54:50 Could we do the DescendantInvalidationSet -> Inval
Eric Willigers 2015/09/14 07:20:24 Done.
+ WTF_MAKE_NONCOPYABLE(InvalidationSet);
public:
- static PassRefPtrWillBeRawPtr<DescendantInvalidationSet> create()
+ static PassRefPtrWillBeRawPtr<InvalidationSet> create()
{
- return adoptRefWillBeNoop(new DescendantInvalidationSet);
+ return adoptRefWillBeNoop(new InvalidationSet);
}
static void cacheTracingFlag();
bool invalidatesElement(Element&) const;
- void combine(const DescendantInvalidationSet& other);
+ void combine(const InvalidationSet& other);
void addClass(const AtomicString& className);
void addId(const AtomicString& id);
void addTagName(const AtomicString& tagName);
void addAttribute(const AtomicString& attributeLocalName);
+ const InvalidationSet* descendants() const { return m_descendantInvalidationSet.get(); }
+
+ InvalidationSet& ensureInvalidationSet();
Timothy Loh 2015/09/10 06:09:40 awkward name
Eric Willigers 2015/09/14 07:20:24 Renamed to ensureDescendantInvalidationSet
+
+ void setAppliesDirectly() { m_appliesDirectly = true; }
+ bool appliesDirectly() const { return m_appliesDirectly; }
+
void setWholeSubtreeInvalid();
bool wholeSubtreeInvalid() const { return m_allDescendantsMightBeInvalid; }
@@ -78,6 +85,9 @@ public:
void setCustomPseudoInvalid() { m_customPseudoInvalid = true; }
bool customPseudoInvalid() const { return m_customPseudoInvalid; }
+ unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSelectors; }
+ void setMaxDirectAdjacentSelectors(unsigned value) { m_maxDirectAdjacentSelectors = std::max(value, m_maxDirectAdjacentSelectors); }
+
bool isEmpty() const { return !m_classes && !m_ids && !m_tagNames && !m_attributes && !m_customPseudoInvalid; }
DECLARE_TRACE();
@@ -89,7 +99,7 @@ public:
#endif
private:
- DescendantInvalidationSet();
+ InvalidationSet();
WillBeHeapHashSet<AtomicString>& ensureClassSet();
WillBeHeapHashSet<AtomicString>& ensureIdSet();
@@ -102,6 +112,15 @@ private:
OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_tagNames;
OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_attributes;
+ // Only for sibling invalidation sets, indicates the maximum possible number of siblings affected.
+ unsigned m_maxDirectAdjacentSelectors;
+
+ // Only for sibling invalidation sets, indicates the descendants of siblings.
+ RefPtrWillBeMember<InvalidationSet> m_descendantInvalidationSet;
+
+ // Indicates the sibling/descendant itself is invalid.
+ unsigned m_appliesDirectly : 1;
esprehn 2015/09/10 08:54:53 I'm not a fan of special cases like this where it
rune 2015/09/10 13:54:50 This is an optimization for the case where a featu
+
// If true, all descendants might be invalidated, so a full subtree recalc is required.
unsigned m_allDescendantsMightBeInvalid : 1;
@@ -113,8 +132,12 @@ private:
// If true, insertion point descendants must be invalidated.
unsigned m_insertionPointCrossing : 1;
+
+ friend class RuleFeatureSetTest;
};
+using InvalidationSetVector = WillBeHeapVector<RefPtrWillBeMember<InvalidationSet>, 8>;
+
} // namespace blink
-#endif // DescendantInvalidationSet_h
+#endif // InvalidationSet_h

Powered by Google App Engine