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