| 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 "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "wtf/Noncopyable.h" | 9 #include "wtf/Noncopyable.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ~StyleInvalidator(); | 22 ~StyleInvalidator(); |
| 23 void invalidate(Document&); | 23 void invalidate(Document&); |
| 24 void scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInvalidationSet>,
Element&); | 24 void scheduleInvalidation(PassRefPtrWillBeRawPtr<DescendantInvalidationSet>,
Element&); |
| 25 void clearInvalidation(Element&); | 25 void clearInvalidation(Element&); |
| 26 | 26 |
| 27 void clearPendingInvalidations(); | 27 void clearPendingInvalidations(); |
| 28 | 28 |
| 29 DECLARE_TRACE(); | 29 DECLARE_TRACE(); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 struct RecursionData { | 32 class RecursionData { |
| 33 STACK_ALLOCATED(); |
| 34 public: |
| 33 RecursionData() | 35 RecursionData() |
| 34 : m_invalidateCustomPseudo(false) | 36 : m_invalidateCustomPseudo(false) |
| 35 , m_wholeSubtreeInvalid(false) | 37 , m_wholeSubtreeInvalid(false) |
| 36 , m_treeBoundaryCrossing(false) | 38 , m_treeBoundaryCrossing(false) |
| 37 , m_insertionPointCrossing(false) | 39 , m_insertionPointCrossing(false) |
| 38 { } | 40 { } |
| 39 | 41 |
| 40 void pushInvalidationSet(const DescendantInvalidationSet&); | 42 void pushInvalidationSet(const DescendantInvalidationSet&); |
| 41 bool matchesCurrentInvalidationSets(Element&); | 43 bool matchesCurrentInvalidationSets(Element&); |
| 42 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } | 44 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } |
| 43 | 45 |
| 44 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } | 46 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } |
| 45 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } | 47 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } |
| 46 | 48 |
| 47 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 49 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
| 48 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 50 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
| 49 | 51 |
| 50 using InvalidationSets = Vector<const DescendantInvalidationSet*, 16>; | 52 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; |
| 51 InvalidationSets m_invalidationSets; | 53 InvalidationSets m_invalidationSets; |
| 52 bool m_invalidateCustomPseudo; | 54 bool m_invalidateCustomPseudo; |
| 53 bool m_wholeSubtreeInvalid; | 55 bool m_wholeSubtreeInvalid; |
| 54 bool m_treeBoundaryCrossing; | 56 bool m_treeBoundaryCrossing; |
| 55 bool m_insertionPointCrossing; | 57 bool m_insertionPointCrossing; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 bool invalidate(Element&, RecursionData&); | 60 bool invalidate(Element&, RecursionData&); |
| 59 bool invalidateChildren(Element&, RecursionData&); | 61 bool invalidateChildren(Element&, RecursionData&); |
| 60 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); | 62 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); |
| 61 | 63 |
| 62 class RecursionCheckpoint { | 64 class RecursionCheckpoint { |
| 65 STACK_ALLOCATED(); |
| 63 public: | 66 public: |
| 64 RecursionCheckpoint(RecursionData* data) | 67 RecursionCheckpoint(RecursionData* data) |
| 65 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) | 68 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) |
| 66 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) | 69 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) |
| 67 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) | 70 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) |
| 68 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) | 71 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) |
| 69 , m_insertionPointCrossing(data->m_insertionPointCrossing) | 72 , m_insertionPointCrossing(data->m_insertionPointCrossing) |
| 70 , m_data(data) | 73 , m_data(data) |
| 71 { } | 74 { } |
| 72 ~RecursionCheckpoint() | 75 ~RecursionCheckpoint() |
| 73 { | 76 { |
| 74 m_data->m_invalidationSets.remove(m_prevInvalidationSetsSize, m_data
->m_invalidationSets.size() - m_prevInvalidationSetsSize); | 77 m_data->m_invalidationSets.remove(m_prevInvalidationSetsSize, m_data
->m_invalidationSets.size() - m_prevInvalidationSetsSize); |
| 75 m_data->m_invalidateCustomPseudo = m_prevInvalidateCustomPseudo; | 78 m_data->m_invalidateCustomPseudo = m_prevInvalidateCustomPseudo; |
| 76 m_data->m_wholeSubtreeInvalid = m_prevWholeSubtreeInvalid; | 79 m_data->m_wholeSubtreeInvalid = m_prevWholeSubtreeInvalid; |
| 77 m_data->m_treeBoundaryCrossing = m_treeBoundaryCrossing; | 80 m_data->m_treeBoundaryCrossing = m_treeBoundaryCrossing; |
| 78 m_data->m_insertionPointCrossing = m_insertionPointCrossing; | 81 m_data->m_insertionPointCrossing = m_insertionPointCrossing; |
| 79 } | 82 } |
| 80 | 83 |
| 81 private: | 84 private: |
| 82 int m_prevInvalidationSetsSize; | 85 int m_prevInvalidationSetsSize; |
| 83 bool m_prevInvalidateCustomPseudo; | 86 bool m_prevInvalidateCustomPseudo; |
| 84 bool m_prevWholeSubtreeInvalid; | 87 bool m_prevWholeSubtreeInvalid; |
| 85 bool m_treeBoundaryCrossing; | 88 bool m_treeBoundaryCrossing; |
| 86 bool m_insertionPointCrossing; | 89 bool m_insertionPointCrossing; |
| 90 // This is a stack reference and need not separate tracing. |
| 87 RecursionData* m_data; | 91 RecursionData* m_data; |
| 88 }; | 92 }; |
| 89 | 93 |
| 90 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<DescendantInval
idationSet>>; | 94 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<DescendantInval
idationSet>>; |
| 91 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; | 95 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; |
| 92 | 96 |
| 93 InvalidationList& ensurePendingInvalidationList(Element&); | 97 InvalidationList& ensurePendingInvalidationList(Element&); |
| 94 | 98 |
| 95 PendingInvalidationMap m_pendingInvalidationMap; | 99 PendingInvalidationMap m_pendingInvalidationMap; |
| 96 }; | 100 }; |
| 97 | 101 |
| 98 } // namespace blink | 102 } // namespace blink |
| 99 | 103 |
| 100 #endif // StyleInvalidator_h | 104 #endif // StyleInvalidator_h |
| OLD | NEW |