| 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/InvalidationListData.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 DescendantInvalidationSet; | 14 class DescendantInvalidationSet; |
| 14 class Document; | 15 class Document; |
| 15 class Element; | 16 class Element; |
| 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<DescendantInvalidationSet>,
Element&); | 25 void scheduleInvalidationSetsForElement(const InvalidationSetVector& descend
ant, const InvalidationSetVector& sibling, 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: |
| 33 |
| 32 class RecursionData { | 34 class RecursionData { |
| 33 STACK_ALLOCATED(); | 35 STACK_ALLOCATED(); |
| 34 public: | 36 public: |
| 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 { } | 42 { } |
| 41 | 43 |
| 42 void pushInvalidationSet(const DescendantInvalidationSet&); | 44 void pushInvalidationSet(const DescendantInvalidationSet&); |
| 43 bool matchesCurrentInvalidationSets(Element&); | 45 bool matchesCurrentInvalidationSets(Element&) const; |
| 44 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } | 46 bool hasInvalidationSets() const { return !wholeSubtreeInvalid() && m_in
validationSets.size(); } |
| 45 | 47 |
| 46 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } | 48 bool wholeSubtreeInvalid() const { return m_wholeSubtreeInvalid; } |
| 47 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } | 49 void setWholeSubtreeInvalid() { m_wholeSubtreeInvalid = true; } |
| 48 | 50 |
| 49 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } | 51 bool treeBoundaryCrossing() const { return m_treeBoundaryCrossing; } |
| 50 bool insertionPointCrossing() const { return m_insertionPointCrossing; } | 52 bool insertionPointCrossing() const { return m_insertionPointCrossing; } |
| 51 | 53 |
| 52 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; | 54 using InvalidationSets = WillBeHeapVector<RawPtrWillBeMember<const Desce
ndantInvalidationSet>, 16>; |
| 53 InvalidationSets m_invalidationSets; | 55 InvalidationSets m_invalidationSets; |
| 54 bool m_invalidateCustomPseudo; | 56 bool m_invalidateCustomPseudo; |
| 55 bool m_wholeSubtreeInvalid; | 57 bool m_wholeSubtreeInvalid; |
| 56 bool m_treeBoundaryCrossing; | 58 bool m_treeBoundaryCrossing; |
| 57 bool m_insertionPointCrossing; | 59 bool m_insertionPointCrossing; |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 bool invalidate(Element&, RecursionData&); | 62 class SiblingData { |
| 63 STACK_ALLOCATED(); |
| 64 public: |
| 65 SiblingData() |
| 66 : m_elementIndex(0) |
| 67 { } |
| 68 |
| 69 void pushInvalidationSet(const DescendantInvalidationSet&); |
| 70 bool matchCurrentInvalidationSets(Element&, RecursionData&, bool); |
| 71 |
| 72 void advance() { m_elementIndex++; } |
| 73 |
| 74 struct Entry { |
| 75 RawPtrWillBeMember<const DescendantInvalidationSet> invalidationSet; |
| 76 unsigned invalidationLimit; |
| 77 }; |
| 78 |
| 79 WillBeHeapVector<Entry, 16> m_invalidationEntries; |
| 80 unsigned m_elementIndex; |
| 81 }; |
| 82 |
| 83 bool invalidate(Element&, RecursionData&, SiblingData&); |
| 61 bool invalidateChildren(Element&, RecursionData&); | 84 bool invalidateChildren(Element&, RecursionData&); |
| 62 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&); | 85 bool checkInvalidationSetsAgainstElement(Element&, RecursionData&, SiblingDa
ta&); |
| 63 | 86 |
| 64 class RecursionCheckpoint { | 87 class RecursionCheckpoint { |
| 65 STACK_ALLOCATED(); | 88 STACK_ALLOCATED(); |
| 66 public: | 89 public: |
| 67 RecursionCheckpoint(RecursionData* data) | 90 RecursionCheckpoint(RecursionData* data) |
| 68 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) | 91 : m_prevInvalidationSetsSize(data->m_invalidationSets.size()) |
| 69 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) | 92 , m_prevInvalidateCustomPseudo(data->m_invalidateCustomPseudo) |
| 70 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) | 93 , m_prevWholeSubtreeInvalid(data->m_wholeSubtreeInvalid) |
| 71 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) | 94 , m_treeBoundaryCrossing(data->m_treeBoundaryCrossing) |
| 72 , m_insertionPointCrossing(data->m_insertionPointCrossing) | 95 , m_insertionPointCrossing(data->m_insertionPointCrossing) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 private: | 107 private: |
| 85 int m_prevInvalidationSetsSize; | 108 int m_prevInvalidationSetsSize; |
| 86 bool m_prevInvalidateCustomPseudo; | 109 bool m_prevInvalidateCustomPseudo; |
| 87 bool m_prevWholeSubtreeInvalid; | 110 bool m_prevWholeSubtreeInvalid; |
| 88 bool m_treeBoundaryCrossing; | 111 bool m_treeBoundaryCrossing; |
| 89 bool m_insertionPointCrossing; | 112 bool m_insertionPointCrossing; |
| 90 // This is a stack reference and need not separate tracing. | 113 // This is a stack reference and need not separate tracing. |
| 91 RecursionData* m_data; | 114 RecursionData* m_data; |
| 92 }; | 115 }; |
| 93 | 116 |
| 94 using InvalidationList = WillBeHeapVector<RefPtrWillBeMember<DescendantInval
idationSet>>; | 117 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, RefPtrWillBeMember<InvalidationListData>>; |
| 95 using PendingInvalidationMap = WillBeHeapHashMap<RawPtrWillBeMember<Element>
, OwnPtrWillBeMember<InvalidationList>>; | |
| 96 | 118 |
| 97 InvalidationList& ensurePendingInvalidationList(Element&); | 119 InvalidationListData& ensurePendingInvalidationListData(Element&); |
| 98 | 120 |
| 99 PendingInvalidationMap m_pendingInvalidationMap; | 121 PendingInvalidationMap m_pendingInvalidationMap; |
| 100 }; | 122 }; |
| 101 | 123 |
| 102 } // namespace blink | 124 } // namespace blink |
| 103 | 125 |
| 104 #endif // StyleInvalidator_h | 126 #endif // StyleInvalidator_h |
| OLD | NEW |