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 #include "core/css/invalidation/StyleInvalidator.h" | 5 #include "core/css/invalidation/StyleInvalidator.h" |
6 | 6 |
7 #include "core/css/invalidation/InvalidationSet.h" | 7 #include "core/css/invalidation/InvalidationSet.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/dom/ElementTraversal.h" | 10 #include "core/dom/ElementTraversal.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 for (auto& invalidationSet : invalidationLists.descendants) { | 81 for (auto& invalidationSet : invalidationLists.descendants) { |
82 ASSERT(!invalidationSet->wholeSubtreeInvalid()); | 82 ASSERT(!invalidationSet->wholeSubtreeInvalid()); |
83 if (invalidationSet->isEmpty()) | 83 if (invalidationSet->isEmpty()) |
84 continue; | 84 continue; |
85 if (pendingInvalidations.descendants().contains(invalidationSet)) | 85 if (pendingInvalidations.descendants().contains(invalidationSet)) |
86 continue; | 86 continue; |
87 pendingInvalidations.descendants().append(invalidationSet); | 87 pendingInvalidations.descendants().append(invalidationSet); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
| 91 void StyleInvalidator::rescheduleSiblingInvalidationSetsForRemovedElement(Elemen
t& elementFrom, Element& elementTo, bool invalidateElementTo) |
| 92 { |
| 93 PendingInvalidations* pendingInvalidationsFrom = m_pendingInvalidationMap.ge
t(&elementFrom); |
| 94 if (!pendingInvalidationsFrom || pendingInvalidationsFrom->siblings().isEmpt
y()) |
| 95 return; |
| 96 |
| 97 scheduleDescendantsFromSiblingSets(elementTo, pendingInvalidationsFrom->sibl
ings()); |
| 98 ensurePendingInvalidations(elementTo).siblings().appendVector(pendingInvalid
ationsFrom->siblings()); |
| 99 elementTo.setNeedsStyleInvalidation(); |
| 100 } |
| 101 |
| 102 void StyleInvalidator::scheduleDescendantsFromSiblingSets(Element& element, cons
t InvalidationSetVector& siblingSets) |
| 103 { |
| 104 bool needsStyleInvalidation = false; |
| 105 PendingInvalidations& pendingInvalidations = ensurePendingInvalidations(elem
ent); |
| 106 for (const auto& invalidationSet : siblingSets) { |
| 107 if (!invalidationSet->invalidatesElement(element)) |
| 108 continue; |
| 109 |
| 110 if (invalidationSet->invalidatesSelf()) |
| 111 element.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::StyleInvalidator)); |
| 112 |
| 113 DescendantInvalidationSet* descendants = toSiblingInvalidationSet(*inval
idationSet).siblingDescendants(); |
| 114 if (!descendants) |
| 115 continue; |
| 116 |
| 117 if (descendants->wholeSubtreeInvalid()) { |
| 118 element.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::StyleInvalidator)); |
| 119 continue; |
| 120 } |
| 121 if (descendants->isEmpty()) |
| 122 continue; |
| 123 |
| 124 pendingInvalidations.descendants().append(descendants); |
| 125 needsStyleInvalidation = true; |
| 126 } |
| 127 if (needsStyleInvalidation) |
| 128 element.setNeedsStyleInvalidation(); |
| 129 } |
| 130 |
91 void StyleInvalidator::clearInvalidation(Element& element) | 131 void StyleInvalidator::clearInvalidation(Element& element) |
92 { | 132 { |
93 if (!element.needsStyleInvalidation()) | 133 if (!element.needsStyleInvalidation()) |
94 return; | 134 return; |
95 m_pendingInvalidationMap.remove(&element); | 135 m_pendingInvalidationMap.remove(&element); |
96 element.clearNeedsStyleInvalidation(); | 136 element.clearNeedsStyleInvalidation(); |
97 } | 137 } |
98 | 138 |
99 PendingInvalidations& StyleInvalidator::ensurePendingInvalidations(Element& elem
ent) | 139 PendingInvalidations& StyleInvalidator::ensurePendingInvalidations(Element& elem
ent) |
100 { | 140 { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 distributedNode->setNeedsStyleRecalc(LocalStyleChange, StyleChangeRe
asonForTracing::create(StyleChangeReason::StyleInvalidator)); | 367 distributedNode->setNeedsStyleRecalc(LocalStyleChange, StyleChangeRe
asonForTracing::create(StyleChangeReason::StyleInvalidator)); |
328 } | 368 } |
329 } | 369 } |
330 | 370 |
331 DEFINE_TRACE(StyleInvalidator) | 371 DEFINE_TRACE(StyleInvalidator) |
332 { | 372 { |
333 visitor->trace(m_pendingInvalidationMap); | 373 visitor->trace(m_pendingInvalidationMap); |
334 } | 374 } |
335 | 375 |
336 } // namespace blink | 376 } // namespace blink |
OLD | NEW |