| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 bool StyleInvalidator::SiblingData::matchCurrentInvalidationSets( | 219 bool StyleInvalidator::SiblingData::matchCurrentInvalidationSets( |
| 220 Element& element, | 220 Element& element, |
| 221 RecursionData& recursionData) { | 221 RecursionData& recursionData) { |
| 222 bool thisElementNeedsStyleRecalc = false; | 222 bool thisElementNeedsStyleRecalc = false; |
| 223 DCHECK(!recursionData.wholeSubtreeInvalid()); | 223 DCHECK(!recursionData.wholeSubtreeInvalid()); |
| 224 | 224 |
| 225 unsigned index = 0; | 225 unsigned index = 0; |
| 226 while (index < m_invalidationEntries.size()) { | 226 while (index < m_invalidationEntries.size()) { |
| 227 if (m_elementIndex > m_invalidationEntries[index].m_invalidationLimit) { | 227 if (m_elementIndex > m_invalidationEntries[index].m_invalidationLimit) { |
| 228 // m_invalidationEntries[index] only applies to earlier siblings. Remove i
t. | 228 // m_invalidationEntries[index] only applies to earlier siblings. Remove |
| 229 // it. |
| 229 m_invalidationEntries[index] = m_invalidationEntries.last(); | 230 m_invalidationEntries[index] = m_invalidationEntries.last(); |
| 230 m_invalidationEntries.removeLast(); | 231 m_invalidationEntries.removeLast(); |
| 231 continue; | 232 continue; |
| 232 } | 233 } |
| 233 | 234 |
| 234 const SiblingInvalidationSet& invalidationSet = | 235 const SiblingInvalidationSet& invalidationSet = |
| 235 *m_invalidationEntries[index].m_invalidationSet; | 236 *m_invalidationEntries[index].m_invalidationSet; |
| 236 ++index; | 237 ++index; |
| 237 if (!invalidationSet.invalidatesElement(element)) | 238 if (!invalidationSet.invalidatesElement(element)) |
| 238 continue; | 239 continue; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 element.childNeedsStyleInvalidation()) | 368 element.childNeedsStyleInvalidation()) |
| 368 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData); | 369 someChildrenNeedStyleRecalc = invalidateChildren(element, recursionData); |
| 369 | 370 |
| 370 if (thisElementNeedsStyleRecalc) { | 371 if (thisElementNeedsStyleRecalc) { |
| 371 DCHECK(!recursionData.wholeSubtreeInvalid()); | 372 DCHECK(!recursionData.wholeSubtreeInvalid()); |
| 372 element.setNeedsStyleRecalc(LocalStyleChange, | 373 element.setNeedsStyleRecalc(LocalStyleChange, |
| 373 StyleChangeReasonForTracing::create( | 374 StyleChangeReasonForTracing::create( |
| 374 StyleChangeReason::StyleInvalidator)); | 375 StyleChangeReason::StyleInvalidator)); |
| 375 } else if (recursionData.hasInvalidationSets() && | 376 } else if (recursionData.hasInvalidationSets() && |
| 376 someChildrenNeedStyleRecalc) { | 377 someChildrenNeedStyleRecalc) { |
| 377 // Clone the ComputedStyle in order to preserve correct style sharing, if po
ssible. Otherwise recalc style. | 378 // Clone the ComputedStyle in order to preserve correct style sharing, if |
| 379 // possible. Otherwise recalc style. |
| 378 if (LayoutObject* layoutObject = element.layoutObject()) { | 380 if (LayoutObject* layoutObject = element.layoutObject()) { |
| 379 layoutObject->setStyleInternal( | 381 layoutObject->setStyleInternal( |
| 380 ComputedStyle::clone(layoutObject->styleRef())); | 382 ComputedStyle::clone(layoutObject->styleRef())); |
| 381 } else { | 383 } else { |
| 382 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED( | 384 TRACE_STYLE_INVALIDATOR_INVALIDATION_IF_ENABLED( |
| 383 element, PreventStyleSharingForParent); | 385 element, PreventStyleSharingForParent); |
| 384 element.setNeedsStyleRecalc(LocalStyleChange, | 386 element.setNeedsStyleRecalc(LocalStyleChange, |
| 385 StyleChangeReasonForTracing::create( | 387 StyleChangeReasonForTracing::create( |
| 386 StyleChangeReason::StyleInvalidator)); | 388 StyleChangeReason::StyleInvalidator)); |
| 387 } | 389 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 411 continue; | 413 continue; |
| 412 if (recursionData.matchesCurrentInvalidationSetsAsSlotted( | 414 if (recursionData.matchesCurrentInvalidationSetsAsSlotted( |
| 413 toElement(*distributedNode))) | 415 toElement(*distributedNode))) |
| 414 distributedNode->setNeedsStyleRecalc( | 416 distributedNode->setNeedsStyleRecalc( |
| 415 LocalStyleChange, StyleChangeReasonForTracing::create( | 417 LocalStyleChange, StyleChangeReasonForTracing::create( |
| 416 StyleChangeReason::StyleInvalidator)); | 418 StyleChangeReason::StyleInvalidator)); |
| 417 } | 419 } |
| 418 } | 420 } |
| 419 | 421 |
| 420 } // namespace blink | 422 } // namespace blink |
| OLD | NEW |