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/PendingInvalidations.h" | 8 #include "core/css/invalidation/PendingInvalidations.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
| 15 class ContainerNode; |
15 class Document; | 16 class Document; |
16 class Element; | 17 class Element; |
17 class HTMLSlotElement; | 18 class HTMLSlotElement; |
18 class InvalidationSet; | 19 class InvalidationSet; |
19 | 20 |
20 | 21 |
21 class StyleInvalidator { | 22 class StyleInvalidator { |
22 DISALLOW_NEW(); | 23 DISALLOW_NEW(); |
23 WTF_MAKE_NONCOPYABLE(StyleInvalidator); | 24 WTF_MAKE_NONCOPYABLE(StyleInvalidator); |
24 public: | 25 public: |
25 StyleInvalidator(); | 26 StyleInvalidator(); |
26 ~StyleInvalidator(); | 27 ~StyleInvalidator(); |
27 void invalidate(Document&); | 28 void invalidate(Document&); |
28 void scheduleInvalidationSetsForElement(const InvalidationLists&, Element&); | 29 void scheduleInvalidationSetsForElement(const InvalidationLists&, Element&); |
29 void clearInvalidation(Element&); | 30 void scheduleSiblingInvalidationsAsDescendants(const InvalidationLists&, Con
tainerNode& schedulingParent); |
| 31 void clearInvalidation(ContainerNode&); |
30 | 32 |
31 DECLARE_TRACE(); | 33 DECLARE_TRACE(); |
32 | 34 |
33 private: | 35 private: |
34 struct RecursionData { | 36 struct RecursionData { |
35 RecursionData() | 37 RecursionData() |
36 : m_invalidateCustomPseudo(false) | 38 : m_invalidateCustomPseudo(false) |
37 , m_wholeSubtreeInvalid(false) | 39 , m_wholeSubtreeInvalid(false) |
38 , m_treeBoundaryCrossing(false) | 40 , m_treeBoundaryCrossing(false) |
39 , m_insertionPointCrossing(false) | 41 , m_insertionPointCrossing(false) |
40 , m_invalidatesSlotted(false) | 42 , m_invalidatesSlotted(false) |
41 { } | 43 { } |
42 | 44 |
43 void pushInvalidationSet(const DescendantInvalidationSet&); | 45 void pushInvalidationSet(const InvalidationSet&); |
44 bool matchesCurrentInvalidationSets(Element&) const; | 46 bool matchesCurrentInvalidationSets(Element&) const; |
45 bool matchesCurrentInvalidationSetsAsSlotted(Element&) const; | 47 bool matchesCurrentInvalidationSetsAsSlotted(Element&) const; |
46 | 48 |
47 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } | 49 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } |
48 | 50 |
49 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } | 51 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } |
50 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } | 52 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } |
51 | 53 |
52 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 54 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
53 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 55 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
54 bool invalidatesSlotted() const { return m_invalidatesSlotted; } | 56 bool invalidatesSlotted() const { return m_invalidatesSlotted; } |
55 | 57 |
56 using DescendantInvalidationSets = Vector<const DescendantInvalidationSe
t*, 16>; | 58 using DescendantInvalidationSets = Vector<const InvalidationSet*, 16>; |
57 DescendantInvalidationSets m_invalidationSets; | 59 DescendantInvalidationSets m_invalidationSets; |
58 bool m_invalidateCustomPseudo; | 60 bool m_invalidateCustomPseudo; |
59 bool m_wholeSubtreeInvalid; | 61 bool m_wholeSubtreeInvalid; |
60 bool m_treeBoundaryCrossing; | 62 bool m_treeBoundaryCrossing; |
61 bool m_insertionPointCrossing; | 63 bool m_insertionPointCrossing; |
62 bool m_invalidatesSlotted; | 64 bool m_invalidatesSlotted; |
63 }; | 65 }; |
64 | 66 |
65 class SiblingData { | 67 class SiblingData { |
66 STACK_ALLOCATED(); | 68 STACK_ALLOCATED(); |
(...skipping 22 matching lines...) Expand all Loading... |
89 | 91 |
90 Vector<Entry, 16> m_invalidationEntries; | 92 Vector<Entry, 16> m_invalidationEntries; |
91 unsigned m_elementIndex; | 93 unsigned m_elementIndex; |
92 }; | 94 }; |
93 | 95 |
94 bool invalidate(Element&, RecursionData&, SiblingData&); | 96 bool invalidate(Element&, RecursionData&, SiblingData&); |
95 bool invalidateShadowRootChildren(Element&, RecursionData&); | 97 bool invalidateShadowRootChildren(Element&, RecursionData&); |
96 bool invalidateChildren(Element&, RecursionData&); | 98 bool invalidateChildren(Element&, RecursionData&); |
97 void invalidateSlotDistributedElements(HTMLSlotElement&, const RecursionData
&) const; | 99 void invalidateSlotDistributedElements(HTMLSlotElement&, const RecursionData
&) const; |
98 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&, SiblingDa
ta&); | 100 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&, SiblingDa
ta&); |
99 void pushInvalidationSetsForElement(Element&, RecursionData&, SiblingData&); | 101 void pushInvalidationSetsForContainerNode(ContainerNode&, RecursionData&, Si
blingData&); |
100 | 102 |
101 class RecursionCheckpoint { | 103 class RecursionCheckpoint { |
102 public: | 104 public: |
103 RecursionCheckpoint(RecursionData* data) | 105 RecursionCheckpoint(RecursionData* data) |
104 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) | 106 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) |
105 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) | 107 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) |
106 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) | 108 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) |
107 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) | 109 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) |
108 , m_insertionPointCrossing(data->m_insertionPointCrossing) | 110 , m_insertionPointCrossing(data->m_insertionPointCrossing) |
109 , m_invalidatesSlotted(data->m_invalidatesSlotted) | 111 , m_invalidatesSlotted(data->m_invalidatesSlotted) |
(...skipping 12 matching lines...) Expand all Loading... |
122 private: | 124 private: |
123 int m_prevInvalidationSetsSize; | 125 int m_prevInvalidationSetsSize; |
124 bool m_prevInvalidateCustomPseudo; | 126 bool m_prevInvalidateCustomPseudo; |
125 bool m_prevWholeSubtreeInvalid; | 127 bool m_prevWholeSubtreeInvalid; |
126 bool m_treeBoundaryCrossing; | 128 bool m_treeBoundaryCrossing; |
127 bool m_insertionPointCrossing; | 129 bool m_insertionPointCrossing; |
128 bool m_invalidatesSlotted; | 130 bool m_invalidatesSlotted; |
129 RecursionData* m_data; | 131 RecursionData* m_data; |
130 }; | 132 }; |
131 | 133 |
132 using PendingInvalidationMap = HeapHashMap<Member<Element>, std::unique_ptr<
PendingInvalidations>>; | 134 using PendingInvalidationMap = HeapHashMap<Member<ContainerNode>, std::uniqu
e_ptr<PendingInvalidations>>; |
133 | 135 |
134 PendingInvalidations& ensurePendingInvalidations(Element&); | 136 PendingInvalidations& ensurePendingInvalidations(ContainerNode&); |
135 | 137 |
136 PendingInvalidationMap m_pendingInvalidationMap; | 138 PendingInvalidationMap m_pendingInvalidationMap; |
137 }; | 139 }; |
138 | 140 |
139 } // namespace blink | 141 } // namespace blink |
140 | 142 |
141 #endif // StyleInvalidator_h | 143 #endif // StyleInvalidator_h |
OLD | NEW |