OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef InvalidationSet_h | 31 #ifndef InvalidationSet_h |
32 #define InvalidationSet_h | 32 #define InvalidationSet_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "platform/heap/Handle.h" | |
36 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
37 #include "wtf/HashSet.h" | 36 #include "wtf/HashSet.h" |
38 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
39 #include "wtf/RefPtr.h" | 38 #include "wtf/RefPtr.h" |
40 #include "wtf/text/AtomicStringHash.h" | 39 #include "wtf/text/AtomicStringHash.h" |
41 #include "wtf/text/StringHash.h" | 40 #include "wtf/text/StringHash.h" |
42 | 41 |
43 namespace blink { | 42 namespace blink { |
44 | 43 |
45 class Element; | 44 class Element; |
46 class TracedValue; | 45 class TracedValue; |
47 | 46 |
48 // Tracks data to determine which elements of a DOM subtree need to have style | 47 // Tracks data to determine which elements of a DOM subtree need to have style |
49 // recalculated. | 48 // recalculated. |
50 class CORE_EXPORT InvalidationSet final : public RefCountedWillBeGarbageCollecte
d<InvalidationSet> { | 49 class CORE_EXPORT InvalidationSet final : public RefCounted<InvalidationSet> { |
51 WTF_MAKE_NONCOPYABLE(InvalidationSet); | 50 WTF_MAKE_NONCOPYABLE(InvalidationSet); |
52 public: | 51 public: |
53 static PassRefPtrWillBeRawPtr<InvalidationSet> create() | 52 static PassRefPtr<InvalidationSet> create() |
54 { | 53 { |
55 return adoptRefWillBeNoop(new InvalidationSet); | 54 return adoptRef(new InvalidationSet); |
56 } | 55 } |
57 | 56 |
58 static void cacheTracingFlag(); | 57 static void cacheTracingFlag(); |
59 | 58 |
60 bool invalidatesElement(Element&) const; | 59 bool invalidatesElement(Element&) const; |
61 | 60 |
62 void combine(const InvalidationSet& other); | 61 void combine(const InvalidationSet& other); |
63 | 62 |
64 void addClass(const AtomicString& className); | 63 void addClass(const AtomicString& className); |
65 void addId(const AtomicString& id); | 64 void addId(const AtomicString& id); |
(...skipping 10 matching lines...) Expand all Loading... |
76 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 75 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
77 | 76 |
78 void setInsertionPointCrossing() { m_insertionPointCrossing = true; } | 77 void setInsertionPointCrossing() { m_insertionPointCrossing = true; } |
79 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 78 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
80 | 79 |
81 void setCustomPseudoInvalid() { m_customPseudoInvalid = true; } | 80 void setCustomPseudoInvalid() { m_customPseudoInvalid = true; } |
82 bool customPseudoInvalid() const { return m_customPseudoInvalid; } | 81 bool customPseudoInvalid() const { return m_customPseudoInvalid; } |
83 | 82 |
84 bool isEmpty() const { return !m_classes && !m_ids && !m_tagNames && !m_attr
ibutes && !m_customPseudoInvalid; } | 83 bool isEmpty() const { return !m_classes && !m_ids && !m_tagNames && !m_attr
ibutes && !m_customPseudoInvalid; } |
85 | 84 |
86 DECLARE_TRACE(); | |
87 | |
88 void toTracedValue(TracedValue*) const; | 85 void toTracedValue(TracedValue*) const; |
89 | 86 |
90 #ifndef NDEBUG | 87 #ifndef NDEBUG |
91 void show() const; | 88 void show() const; |
92 #endif | 89 #endif |
93 | 90 |
94 private: | 91 private: |
95 InvalidationSet(); | 92 InvalidationSet(); |
96 | 93 |
97 WillBeHeapHashSet<AtomicString>& ensureClassSet(); | 94 HashSet<AtomicString>& ensureClassSet(); |
98 WillBeHeapHashSet<AtomicString>& ensureIdSet(); | 95 HashSet<AtomicString>& ensureIdSet(); |
99 WillBeHeapHashSet<AtomicString>& ensureTagNameSet(); | 96 HashSet<AtomicString>& ensureTagNameSet(); |
100 WillBeHeapHashSet<AtomicString>& ensureAttributeSet(); | 97 HashSet<AtomicString>& ensureAttributeSet(); |
101 | 98 |
102 // FIXME: optimize this if it becomes a memory issue. | 99 // FIXME: optimize this if it becomes a memory issue. |
103 OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_classes; | 100 OwnPtr<HashSet<AtomicString>> m_classes; |
104 OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_ids; | 101 OwnPtr<HashSet<AtomicString>> m_ids; |
105 OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_tagNames; | 102 OwnPtr<HashSet<AtomicString>> m_tagNames; |
106 OwnPtrWillBeMember<WillBeHeapHashSet<AtomicString>> m_attributes; | 103 OwnPtr<HashSet<AtomicString>> m_attributes; |
107 | 104 |
108 // If true, all descendants might be invalidated, so a full subtree recalc i
s required. | 105 // If true, all descendants might be invalidated, so a full subtree recalc i
s required. |
109 unsigned m_allDescendantsMightBeInvalid : 1; | 106 unsigned m_allDescendantsMightBeInvalid : 1; |
110 | 107 |
111 // If true, the element itself is invalid. | 108 // If true, the element itself is invalid. |
112 unsigned m_invalidatesSelf : 1; | 109 unsigned m_invalidatesSelf : 1; |
113 | 110 |
114 // If true, all descendants which are custom pseudo elements must be invalid
ated. | 111 // If true, all descendants which are custom pseudo elements must be invalid
ated. |
115 unsigned m_customPseudoInvalid : 1; | 112 unsigned m_customPseudoInvalid : 1; |
116 | 113 |
117 // If true, the invalidation must traverse into ShadowRoots with this set. | 114 // If true, the invalidation must traverse into ShadowRoots with this set. |
118 unsigned m_treeBoundaryCrossing : 1; | 115 unsigned m_treeBoundaryCrossing : 1; |
119 | 116 |
120 // If true, insertion point descendants must be invalidated. | 117 // If true, insertion point descendants must be invalidated. |
121 unsigned m_insertionPointCrossing : 1; | 118 unsigned m_insertionPointCrossing : 1; |
122 }; | 119 }; |
123 | 120 |
124 } // namespace blink | 121 } // namespace blink |
125 | 122 |
126 #endif // InvalidationSet_h | 123 #endif // InvalidationSet_h |
OLD | NEW |