OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef StyleInvalidator_h | 5 #ifndef StyleInvalidator_h |
6 #define StyleInvalidator_h | 6 #define StyleInvalidator_h |
7 | 7 |
| 8 #include "core/css/invalidation/InvalidationData.h" |
8 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
9 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 class DescendantInvalidationSet; | 14 class DescendantInvalidationSet; |
14 class Document; | 15 class Document; |
15 class Element; | 16 class Element; |
16 | 17 |
17 class StyleInvalidator { | 18 class StyleInvalidator { |
18 DISALLOW_ALLOCATION(); | 19 DISALLOW_ALLOCATION(); |
19 WTF_MAKE_NONCOPYABLE(StyleInvalidator); | 20 WTF_MAKE_NONCOPYABLE(StyleInvalidator); |
20 public: | 21 public: |
21 StyleInvalidator(); | 22 StyleInvalidator(); |
22 ~StyleInvalidator(); | 23 ~StyleInvalidator(); |
23 void invalidate(Document&); | 24 void invalidate(Document&); |
24 void scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInvalidationSet>,
Element&); | 25 void scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInvalidationSet>,
Element&, InvalidateType); |
25 void clearInvalidation(Element&); | 26 void clearInvalidation(Element&); |
26 | 27 |
27 void clearPendingInvalidations(); | 28 void clearPendingInvalidations(); |
28 | 29 |
29 DECLARE_TRACE(); | 30 DECLARE_TRACE(); |
30 | 31 |
31 private: | 32 private: |
32 class RecursionData { | 33 class RecursionData { |
33 STACK_ALLOCATED(); | 34 STACK_ALLOCATED(); |
34 public: | 35 public: |
35 RecursionData() | 36 RecursionData() |
36 : m_invalidateCustomPseudo(false) | 37 : m_invalidateCustomPseudo(false) |
37 , m_wholeSubtreeInvalid(false) | 38 , m_wholeSubtreeInvalid(false) |
38 , m_treeBoundaryCrossing(false) | 39 , m_treeBoundaryCrossing(false) |
39 , m_insertionPointCrossing(false) | 40 , m_insertionPointCrossing(false) |
40 { } | 41 { } |
41 | 42 |
42 void pushInvalidationSet(const DescendantInvalidationSet&); | 43 void pushInvalidationSet(const DescendantInvalidationSet&); |
43 bool matchesCurrentInvalidationSets(Element&); | 44 bool matchesCurrentInvalidationSets(Element&) const; |
44 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } | 45 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } |
45 | 46 |
46 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } | 47 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } |
47 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } | 48 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } |
48 | 49 |
49 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 50 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
50 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 51 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
51 | 52 |
52 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; | 53 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; |
53 InvalidationSets m_invalidationSets; | 54 InvalidationSets m_invalidationSets; |
54 bool m_invalidateCustomPseudo; | 55 bool m_invalidateCustomPseudo; |
55 bool m_wholeSubtreeInvalid; | 56 bool m_wholeSubtreeInvalid; |
56 bool m_treeBoundaryCrossing; | 57 bool m_treeBoundaryCrossing; |
57 bool m_insertionPointCrossing; | 58 bool m_insertionPointCrossing; |
58 }; | 59 }; |
59 | 60 |
60 bool invalidate(Element&, RecursionData&); | 61 class SiblingData { |
| 62 STACK_ALLOCATED(); |
| 63 public: |
| 64 SiblingData() |
| 65 : m_elementIndex(0) |
| 66 { } |
| 67 |
| 68 void pushInvalidationSet(const DescendantInvalidationSet&); |
| 69 bool matchesCurrentInvalidationSets(Element&); |
| 70 |
| 71 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; |
| 72 InvalidationSets m_invalidationSets; |
| 73 Vector<unsigned> m_invalidationLimits; |
| 74 unsigned m_elementIndex; |
| 75 }; |
| 76 |
| 77 bool invalidate(Element&, RecursionData&, SiblingData&); |
61 bool invalidateChildren(Element&, RecursionData&); | 78 bool invalidateChildren(Element&, RecursionData&); |
62 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); | 79 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); |
63 | 80 |
64 class RecursionCheckpoint { | 81 class RecursionCheckpoint { |
65 STACK_ALLOCATED(); | 82 STACK_ALLOCATED(); |
66 public: | 83 public: |
67 RecursionCheckpoint(RecursionData* data) | 84 RecursionCheckpoint(RecursionData* data) |
68 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) | 85 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) |
69 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) | 86 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) |
70 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) | 87 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) |
(...skipping 16 matching lines...) Expand all Loading... |
87 bool m_prevWholeSubtreeInvalid; | 104 bool m_prevWholeSubtreeInvalid; |
88 bool m_treeBoundaryCrossing; | 105 bool m_treeBoundaryCrossing; |
89 bool m_insertionPointCrossing; | 106 bool m_insertionPointCrossing; |
90 // This is a stack reference and need not separate tracing. | 107 // This is a stack reference and need not separate tracing. |
91 RecursionData* m_data; | 108 RecursionData* m_data; |
92 }; | 109 }; |
93 | 110 |
94 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<DescendantInval
idationSet>>; | 111 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<DescendantInval
idationSet>>; |
95 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; | 112 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; |
96 | 113 |
97 InvalidationList& ensurePendingInvalidationList(Element&); | 114 InvalidationList& ensurePendingInvalidationList(Element&, InvalidateType); |
98 | 115 |
99 PendingInvalidationMap m_pendingInvalidationMap; | 116 PendingInvalidationMap m_pendingInvalidationMap[InvalidateTypeCount]; |
100 }; | 117 }; |
101 | 118 |
102 } // namespace blink | 119 } // namespace blink |
103 | 120 |
104 #endif // StyleInvalidator_h | 121 #endif // StyleInvalidator_h |
OLD | NEW |