| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return; | 105 return; |
| 106 | 106 |
| 107 PendingInvalidations& pendingInvalidations = | 107 PendingInvalidations& pendingInvalidations = |
| 108 ensurePendingInvalidations(schedulingParent); | 108 ensurePendingInvalidations(schedulingParent); |
| 109 | 109 |
| 110 schedulingParent.setNeedsStyleInvalidation(); | 110 schedulingParent.setNeedsStyleInvalidation(); |
| 111 | 111 |
| 112 for (auto& invalidationSet : invalidationLists.siblings) { | 112 for (auto& invalidationSet : invalidationLists.siblings) { |
| 113 if (invalidationSet->wholeSubtreeInvalid()) { | 113 if (invalidationSet->wholeSubtreeInvalid()) { |
| 114 schedulingParent.setNeedsStyleRecalc( | 114 schedulingParent.setNeedsStyleRecalc( |
| 115 SubtreeStyleChange, StyleChangeReasonForTracing::create( | 115 SubtreeStyleChange, |
| 116 StyleChangeReason::StyleInvalidator)); | 116 StyleChangeReasonForTracing::create( |
| 117 StyleChangeReason::StyleInvalidator)); |
| 117 return; | 118 return; |
| 118 } | 119 } |
| 119 if (invalidationSet->invalidatesSelf() && | 120 if (invalidationSet->invalidatesSelf() && |
| 120 !pendingInvalidations.descendants().contains(invalidationSet)) | 121 !pendingInvalidations.descendants().contains(invalidationSet)) |
| 121 pendingInvalidations.descendants().push_back(invalidationSet); | 122 pendingInvalidations.descendants().push_back(invalidationSet); |
| 122 | 123 |
| 123 if (DescendantInvalidationSet* descendants = | 124 if (DescendantInvalidationSet* descendants = |
| 124 toSiblingInvalidationSet(*invalidationSet).siblingDescendants()) { | 125 toSiblingInvalidationSet(*invalidationSet).siblingDescendants()) { |
| 125 if (descendants->wholeSubtreeInvalid()) { | 126 if (descendants->wholeSubtreeInvalid()) { |
| 126 schedulingParent.setNeedsStyleRecalc( | 127 schedulingParent.setNeedsStyleRecalc( |
| 127 SubtreeStyleChange, StyleChangeReasonForTracing::create( | 128 SubtreeStyleChange, |
| 128 StyleChangeReason::StyleInvalidator)); | 129 StyleChangeReasonForTracing::create( |
| 130 StyleChangeReason::StyleInvalidator)); |
| 129 return; | 131 return; |
| 130 } | 132 } |
| 131 if (!pendingInvalidations.descendants().contains(descendants)) | 133 if (!pendingInvalidations.descendants().contains(descendants)) |
| 132 pendingInvalidations.descendants().push_back(descendants); | 134 pendingInvalidations.descendants().push_back(descendants); |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 | 138 |
| 137 void StyleInvalidator::rescheduleSiblingInvalidationsAsDescendants( | 139 void StyleInvalidator::rescheduleSiblingInvalidationsAsDescendants( |
| 138 Element& element) { | 140 Element& element) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (node.getStyleChangeType() >= SubtreeStyleChange) | 294 if (node.getStyleChangeType() >= SubtreeStyleChange) |
| 293 return; | 295 return; |
| 294 | 296 |
| 295 if (!pendingInvalidations->descendants().isEmpty()) { | 297 if (!pendingInvalidations->descendants().isEmpty()) { |
| 296 for (const auto& invalidationSet : pendingInvalidations->descendants()) | 298 for (const auto& invalidationSet : pendingInvalidations->descendants()) |
| 297 recursionData.pushInvalidationSet(*invalidationSet); | 299 recursionData.pushInvalidationSet(*invalidationSet); |
| 298 if (UNLIKELY(*s_tracingEnabled)) { | 300 if (UNLIKELY(*s_tracingEnabled)) { |
| 299 TRACE_EVENT_INSTANT1( | 301 TRACE_EVENT_INSTANT1( |
| 300 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), | 302 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"), |
| 301 "StyleInvalidatorInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, | 303 "StyleInvalidatorInvalidationTracking", TRACE_EVENT_SCOPE_THREAD, |
| 302 "data", InspectorStyleInvalidatorInvalidateEvent::invalidationList( | 304 "data", |
| 303 node, pendingInvalidations->descendants())); | 305 InspectorStyleInvalidatorInvalidateEvent::invalidationList( |
| 306 node, pendingInvalidations->descendants())); |
| 304 } | 307 } |
| 305 } | 308 } |
| 306 } | 309 } |
| 307 | 310 |
| 308 ALWAYS_INLINE bool StyleInvalidator::checkInvalidationSetsAgainstElement( | 311 ALWAYS_INLINE bool StyleInvalidator::checkInvalidationSetsAgainstElement( |
| 309 Element& element, | 312 Element& element, |
| 310 RecursionData& recursionData, | 313 RecursionData& recursionData, |
| 311 SiblingData& siblingData) { | 314 SiblingData& siblingData) { |
| 312 if (recursionData.wholeSubtreeInvalid()) | 315 if (recursionData.wholeSubtreeInvalid()) |
| 313 return false; | 316 return false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 HTMLSlotElement& slot, | 427 HTMLSlotElement& slot, |
| 425 const RecursionData& recursionData) const { | 428 const RecursionData& recursionData) const { |
| 426 for (auto& distributedNode : slot.getDistributedNodes()) { | 429 for (auto& distributedNode : slot.getDistributedNodes()) { |
| 427 if (distributedNode->needsStyleRecalc()) | 430 if (distributedNode->needsStyleRecalc()) |
| 428 continue; | 431 continue; |
| 429 if (!distributedNode->isElementNode()) | 432 if (!distributedNode->isElementNode()) |
| 430 continue; | 433 continue; |
| 431 if (recursionData.matchesCurrentInvalidationSetsAsSlotted( | 434 if (recursionData.matchesCurrentInvalidationSetsAsSlotted( |
| 432 toElement(*distributedNode))) | 435 toElement(*distributedNode))) |
| 433 distributedNode->setNeedsStyleRecalc( | 436 distributedNode->setNeedsStyleRecalc( |
| 434 LocalStyleChange, StyleChangeReasonForTracing::create( | 437 LocalStyleChange, |
| 435 StyleChangeReason::StyleInvalidator)); | 438 StyleChangeReasonForTracing::create( |
| 439 StyleChangeReason::StyleInvalidator)); |
| 436 } | 440 } |
| 437 } | 441 } |
| 438 | 442 |
| 439 } // namespace blink | 443 } // namespace blink |
| OLD | NEW |