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

Unified Diff: Source/core/css/analyzer/DescendantInvalidationSet.h

Issue 129633003: Add a first pass of a class descendant invalidator, and a containing RuleSetAnalyzer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed extra line. Created 6 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
Index: Source/core/css/analyzer/DescendantInvalidationSet.h
diff --git a/Source/core/rendering/style/StyleVariableData.h b/Source/core/css/analyzer/DescendantInvalidationSet.h
similarity index 55%
copy from Source/core/rendering/style/StyleVariableData.h
copy to Source/core/css/analyzer/DescendantInvalidationSet.h
index 23429f19c2e3058532656a3c0e130e97a09339af..4c82e0eba45c355de3f592329882415566194400 100644
--- a/Source/core/rendering/style/StyleVariableData.h
+++ b/Source/core/css/analyzer/DescendantInvalidationSet.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2014 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,37 +28,52 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#ifndef StyleVariableData_h
-#define StyleVariableData_h
+#ifndef DescendantInvalidationSet_h
+#define DescendantInvalidationSet_h
#include "wtf/Forward.h"
-#include "wtf/HashMap.h"
+#include "wtf/HashSet.h"
#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
#include "wtf/text/AtomicStringHash.h"
namespace WebCore {
-class CursorList;
-class QuotesData;
-class ShadowData;
+class Element;
-class StyleVariableData : public RefCounted<StyleVariableData> {
+// Tracks data to determine which elements of a DOM subtree ened to have style
esprehn 2014/01/14 21:32:56 s/ened/need/
chrishtr 2014/01/14 23:33:00 Done.
+// recalculated.
+class DescendantInvalidationSet : public RefCounted<DescendantInvalidationSet> {
public:
- static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVariableData()); }
- PassRefPtr<StyleVariableData> copy() const { return adoptRef(new StyleVariableData(*this)); }
+ static PassRefPtr<DescendantInvalidationSet> create()
+ {
+ return adoptRef(new DescendantInvalidationSet);
+ }
+
+ // Marks the appropriate subtree of this elemennt (including the element itself if appropriate) for style recalc
+ // based on the information available.
+ void invalidateElementSubtree(Element*);
+
+ void combine(const DescendantInvalidationSet& other);
- bool operator==(const StyleVariableData& other) const { return other.m_data == m_data; }
- bool operator!=(const StyleVariableData& other) const { return !(*this == other); }
+ void addClass(const AtomicString& className);
+ void addId(const AtomicString& id);
+ void addTagName(const AtomicString& tagName);
- void setVariable(const AtomicString& name, const String& value) { m_data.set(name, value); }
+ void setWholeSubtreeInvalid() { allDescendantsMightBeInvalid = true; };
- HashMap<AtomicString, String> m_data;
private:
- explicit StyleVariableData() : RefCounted<StyleVariableData>() { }
- StyleVariableData(const StyleVariableData& other) : RefCounted<StyleVariableData>(), m_data(HashMap<AtomicString, String>(other.m_data)) { }
+ DescendantInvalidationSet();
+
+ bool invalidateElementSubtreeInternal(Element*);
+ // If true, all descendants might be invalidated, so a full subtree recalc is required.
+ bool allDescendantsMightBeInvalid;
esprehn 2014/01/14 21:32:56 m_ missing
+
+ HashSet<AtomicString> m_classes;
+ HashSet<AtomicString> m_ids;
+ HashSet<AtomicString> m_tagNames;
esprehn 2014/01/14 21:32:56 HashSets are pretty big in terms of memory usage,
chrishtr 2014/01/14 23:33:00 Done.
};
} // namespace WebCore
-#endif /* StyleVariableData_h */
+#endif // DescendantInvalidationSet_h

Powered by Google App Engine
This is Rietveld 408576698