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/RuleFeature.h" | |
9 #include "heap/Heap.h" | 8 #include "heap/Heap.h" |
10 | 9 |
11 namespace WebCore { | 10 namespace WebCore { |
12 | 11 |
12 class DescendantInvalidationSet; | |
13 class Document; | |
14 class Element; | |
15 | |
13 class StyleInvalidator { | 16 class StyleInvalidator { |
14 STACK_ALLOCATED(); | |
15 public: | 17 public: |
16 explicit StyleInvalidator(Document&); | 18 explicit StyleInvalidator(); |
17 void invalidate(); | 19 void invalidate(Document&); |
20 void scheduleInvalidation(PassRefPtr<DescendantInvalidationSet>, Element*); | |
esprehn
2014/03/31 18:20:39
by reference
chrishtr
2014/03/31 19:22:59
Done.
| |
21 | |
22 // Clears all style invalidation state for the passed node. | |
23 void clearStyleInvalidation(Node*); | |
esprehn
2014/03/31 18:20:39
by reference
chrishtr
2014/03/31 19:22:59
Done.
| |
24 | |
25 void clear(); | |
esprehn
2014/03/31 18:20:39
This needs a better name.
chrishtr
2014/03/31 19:22:59
Done.
| |
18 | 26 |
19 private: | 27 private: |
20 bool invalidate(Element&); | 28 bool invalidate(Element&); |
21 bool invalidateChildren(Element&); | 29 bool invalidateChildren(Element&); |
22 | 30 |
23 bool checkInvalidationSetsAgainstElement(Element&); | 31 bool checkInvalidationSetsAgainstElement(Element&); |
24 | 32 |
25 struct RecursionData { | 33 struct RecursionData { |
26 RecursionData() : m_foundInvalidationSet(false) { } | 34 RecursionData(); |
27 void pushInvalidationSet(const DescendantInvalidationSet&); | 35 void pushInvalidationSet(const DescendantInvalidationSet&); |
28 bool matchesCurrentInvalidationSets(Element&); | 36 bool matchesCurrentInvalidationSets(Element&); |
29 bool foundInvalidationSet() { return m_foundInvalidationSet; } | 37 bool foundInvalidationSet() { return m_foundInvalidationSet; } |
38 void clear(); | |
30 | 39 |
31 Vector<AtomicString> m_invalidationClasses; | 40 Vector<AtomicString> m_invalidationClasses; |
32 Vector<AtomicString> m_invalidationAttributes; | 41 Vector<AtomicString> m_invalidationAttributes; |
33 bool m_foundInvalidationSet; | 42 bool m_foundInvalidationSet; |
34 }; | 43 }; |
35 | 44 |
36 class RecursionCheckpoint { | 45 class RecursionCheckpoint { |
37 public: | 46 public: |
38 RecursionCheckpoint(RecursionData* data) | 47 RecursionCheckpoint(RecursionData* data) |
39 : m_prevClassLength(data->m_invalidationClasses.size()), | 48 : m_prevClassLength(data->m_invalidationClasses.size()), |
40 m_prevAttributeLength(data->m_invalidationAttributes.size()), | 49 m_prevAttributeLength(data->m_invalidationAttributes.size()), |
41 m_prevFoundInvalidationSet(data->m_foundInvalidationSet), | 50 m_prevFoundInvalidationSet(data->m_foundInvalidationSet), |
42 m_data(data) | 51 m_data(data) |
43 { } | 52 { } |
44 ~RecursionCheckpoint() | 53 ~RecursionCheckpoint() |
45 { | 54 { |
46 m_data->m_invalidationClasses.remove(m_prevClassLength, m_data->m_in validationClasses.size() - m_prevClassLength); | 55 m_data->m_invalidationClasses.remove(m_prevClassLength, m_data->m_in validationClasses.size() - m_prevClassLength); |
47 m_data->m_invalidationAttributes.remove(m_prevAttributeLength, m_dat a->m_invalidationAttributes.size() - m_prevAttributeLength); | 56 m_data->m_invalidationAttributes.remove(m_prevAttributeLength, m_dat a->m_invalidationAttributes.size() - m_prevAttributeLength); |
48 m_data->m_foundInvalidationSet = m_prevFoundInvalidationSet; | 57 m_data->m_foundInvalidationSet = m_prevFoundInvalidationSet; |
49 } | 58 } |
50 | 59 |
51 private: | 60 private: |
52 int m_prevClassLength; | 61 int m_prevClassLength; |
53 int m_prevAttributeLength; | 62 int m_prevAttributeLength; |
54 bool m_prevFoundInvalidationSet; | 63 bool m_prevFoundInvalidationSet; |
55 RecursionData* m_data; | 64 RecursionData* m_data; |
56 }; | 65 }; |
57 | 66 |
58 Document& m_document; | 67 typedef Vector<RefPtr<DescendantInvalidationSet> > InvalidationList; |
59 RuleFeatureSet::PendingInvalidationMap& m_pendingInvalidationMap; | 68 typedef HashMap<Element*, OwnPtr<InvalidationList> > PendingInvalidationMap; |
69 | |
70 InvalidationList& ensurePendingInvalidationList(Element*); | |
71 | |
72 PendingInvalidationMap m_pendingInvalidationMap; | |
60 RecursionData m_recursionData; | 73 RecursionData m_recursionData; |
61 }; | 74 }; |
62 | 75 |
63 } // namespace WebCore | 76 } // namespace WebCore |
64 | 77 |
65 #endif // StyleInvalidator_h | 78 #endif // StyleInvalidator_h |
OLD | NEW |