| 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/InvalidationLists.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 InvalidationSet; | |
| 14 class Document; | 14 class Document; |
| 15 class Element; | 15 class Element; |
| 16 class InvalidationSet; |
| 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<InvalidationSet>, Element&)
; | 25 void scheduleInvalidationSetsForElement(const InvalidationLists&, Element&); |
| 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 struct RecursionData { | 33 struct RecursionData { |
| 33 RecursionData() | 34 RecursionData() |
| 34 : m_invalidateCustomPseudo(false) | 35 : m_invalidateCustomPseudo(false) |
| 35 , m_wholeSubtreeInvalid(false) | 36 , m_wholeSubtreeInvalid(false) |
| 36 , m_treeBoundaryCrossing(false) | 37 , m_treeBoundaryCrossing(false) |
| 37 , m_insertionPointCrossing(false) | 38 , m_insertionPointCrossing(false) |
| 38 { } | 39 { } |
| 39 | 40 |
| 40 void pushInvalidationSet(const InvalidationSet&); | 41 void pushInvalidationSet(const InvalidationSet&); |
| 41 bool matchesCurrentInvalidationSets(Element&); | 42 bool matchesCurrentInvalidationSets(Element&) const; |
| 42 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } | 43 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } |
| 43 | 44 |
| 44 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } | 45 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } |
| 45 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } | 46 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } |
| 46 | 47 |
| 47 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 48 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
| 48 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 49 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
| 49 | 50 |
| 50 using InvalidationSets = Vector<const InvalidationSet*, 16>; | 51 using InvalidationSets = Vector<const InvalidationSet*, 16>; |
| 51 InvalidationSets m_invalidationSets; | 52 InvalidationSets m_invalidationSets; |
| 52 bool m_invalidateCustomPseudo; | 53 bool m_invalidateCustomPseudo; |
| 53 bool m_wholeSubtreeInvalid; | 54 bool m_wholeSubtreeInvalid; |
| 54 bool m_treeBoundaryCrossing; | 55 bool m_treeBoundaryCrossing; |
| 55 bool m_insertionPointCrossing; | 56 bool m_insertionPointCrossing; |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 bool invalidate(Element&, RecursionData&); | 59 class SiblingData { |
| 60 STACK_ALLOCATED(); |
| 61 public: |
| 62 SiblingData() |
| 63 : m_elementIndex(0) |
| 64 { } |
| 65 |
| 66 void pushInvalidationSet(const InvalidationSet&); |
| 67 bool matchCurrentInvalidationSets(Element&, RecursionData&); |
| 68 |
| 69 void advance() { m_elementIndex++; } |
| 70 |
| 71 struct Entry { |
| 72 Entry(const InvalidationSet* invalidationSet, unsigned invalidationL
imit) |
| 73 : m_invalidationSet(invalidationSet) |
| 74 , m_invalidationLimit(invalidationLimit) |
| 75 {} |
| 76 |
| 77 RawPtrWillBeMember<const InvalidationSet> m_invalidationSet; |
| 78 unsigned m_invalidationLimit; |
| 79 }; |
| 80 |
| 81 WillBeHeapVector<Entry, 16> m_invalidationEntries; |
| 82 unsigned m_elementIndex; |
| 83 }; |
| 84 |
| 85 bool invalidate(Element&, RecursionData&, SiblingData&); |
| 59 bool invalidateChildren(Element&, RecursionData&); | 86 bool invalidateChildren(Element&, RecursionData&); |
| 60 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); | 87 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&, SiblingDa
ta&); |
| 61 | 88 |
| 62 class RecursionCheckpoint { | 89 class RecursionCheckpoint { |
| 63 public: | 90 public: |
| 64 RecursionCheckpoint(RecursionData* data) | 91 RecursionCheckpoint(RecursionData* data) |
| 65 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) | 92 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) |
| 66 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) | 93 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) |
| 67 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) | 94 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) |
| 68 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) | 95 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) |
| 69 , m_insertionPointCrossing(data->m_insertionPointCrossing) | 96 , m_insertionPointCrossing(data->m_insertionPointCrossing) |
| 70 , m_data(data) | 97 , m_data(data) |
| 71 { } | 98 { } |
| 72 ~RecursionCheckpoint() | 99 ~RecursionCheckpoint() |
| 73 { | 100 { |
| 74 m_data->m_invalidationSets.remove(m_prevInvalidationSetsSize, m_data
->m_invalidationSets.size() - m_prevInvalidationSetsSize); | 101 m_data->m_invalidationSets.remove(m_prevInvalidationSetsSize, m_data
->m_invalidationSets.size() - m_prevInvalidationSetsSize); |
| 75 m_data->m_invalidateCustomPseudo = m_prevInvalidateCustomPseudo; | 102 m_data->m_invalidateCustomPseudo = m_prevInvalidateCustomPseudo; |
| 76 m_data->m_wholeSubtreeInvalid = m_prevWholeSubtreeInvalid; | 103 m_data->m_wholeSubtreeInvalid = m_prevWholeSubtreeInvalid; |
| 77 m_data->m_treeBoundaryCrossing = m_treeBoundaryCrossing; | 104 m_data->m_treeBoundaryCrossing = m_treeBoundaryCrossing; |
| 78 m_data->m_insertionPointCrossing = m_insertionPointCrossing; | 105 m_data->m_insertionPointCrossing = m_insertionPointCrossing; |
| 79 } | 106 } |
| 80 | 107 |
| 81 private: | 108 private: |
| 82 int m_prevInvalidationSetsSize; | 109 int m_prevInvalidationSetsSize; |
| 83 bool m_prevInvalidateCustomPseudo; | 110 bool m_prevInvalidateCustomPseudo; |
| 84 bool m_prevWholeSubtreeInvalid; | 111 bool m_prevWholeSubtreeInvalid; |
| 85 bool m_treeBoundaryCrossing; | 112 bool m_treeBoundaryCrossing; |
| 86 bool m_insertionPointCrossing; | 113 bool m_insertionPointCrossing; |
| 87 RecursionData* m_data; | 114 RecursionData* m_data; |
| 88 }; | 115 }; |
| 89 | 116 |
| 90 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<InvalidationSet
>>; | 117 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationLists>>; |
| 91 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; | |
| 92 | 118 |
| 93 InvalidationList& ensurePendingInvalidationList(Element&); | 119 InvalidationLists& ensurePendingInvalidationLists(Element&); |
| 94 | 120 |
| 95 PendingInvalidationMap m_pendingInvalidationMap; | 121 PendingInvalidationMap m_pendingInvalidationMap; |
| 96 }; | 122 }; |
| 97 | 123 |
| 98 } // namespace blink | 124 } // namespace blink |
| 99 | 125 |
| 100 #endif // StyleInvalidator_h | 126 #endif // StyleInvalidator_h |
| OLD | NEW |