| 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/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 m_clipped(false), | 41 m_clipped(false), |
| 42 m_clippedForAbsolutePosition(false), | 42 m_clippedForAbsolutePosition(false), |
| 43 m_cachedOffsetsEnabled(true), | 43 m_cachedOffsetsEnabled(true), |
| 44 m_cachedOffsetsForAbsolutePositionEnabled(true), | 44 m_cachedOffsetsForAbsolutePositionEnabled(true), |
| 45 m_paintInvalidationContainer(&layoutView.containerForPaintInvalidation()), | 45 m_paintInvalidationContainer(&layoutView.containerForPaintInvalidation()), |
| 46 m_paintInvalidationContainerForStackedContents( | 46 m_paintInvalidationContainerForStackedContents( |
| 47 m_paintInvalidationContainer), | 47 m_paintInvalidationContainer), |
| 48 m_containerForAbsolutePosition(layoutView), | 48 m_containerForAbsolutePosition(layoutView), |
| 49 m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations), | 49 m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations), |
| 50 m_paintingLayer(*layoutView.layer()) | 50 m_paintingLayer(*layoutView.layer()) |
| 51 #if ENABLE(ASSERT) | |
| 52 , | |
| 53 m_didUpdateForChildren(false) | |
| 54 #endif | |
| 55 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 51 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 56 , | 52 , |
| 57 m_canCheckFastPathSlowPathEquality(layoutView == | 53 m_canCheckFastPathSlowPathEquality(layoutView == |
| 58 m_paintInvalidationContainer) | 54 m_paintInvalidationContainer) |
| 59 #endif | 55 #endif |
| 60 { | 56 { |
| 61 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); | 57 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); |
| 62 | 58 |
| 63 if (!supportsCachedOffsets(layoutView)) { | 59 if (!supportsCachedOffsets(layoutView)) { |
| 64 m_cachedOffsetsEnabled = false; | 60 m_cachedOffsetsEnabled = false; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 92 m_paintInvalidationContainerForStackedContents( | 88 m_paintInvalidationContainerForStackedContents( |
| 93 parentState.m_paintInvalidationContainerForStackedContents), | 89 parentState.m_paintInvalidationContainerForStackedContents), |
| 94 m_containerForAbsolutePosition( | 90 m_containerForAbsolutePosition( |
| 95 currentObject.canContainAbsolutePositionObjects() | 91 currentObject.canContainAbsolutePositionObjects() |
| 96 ? currentObject | 92 ? currentObject |
| 97 : parentState.m_containerForAbsolutePosition), | 93 : parentState.m_containerForAbsolutePosition), |
| 98 m_svgTransform(parentState.m_svgTransform), | 94 m_svgTransform(parentState.m_svgTransform), |
| 99 m_pendingDelayedPaintInvalidations( | 95 m_pendingDelayedPaintInvalidations( |
| 100 parentState.m_pendingDelayedPaintInvalidations), | 96 parentState.m_pendingDelayedPaintInvalidations), |
| 101 m_paintingLayer(parentState.childPaintingLayer(currentObject)) | 97 m_paintingLayer(parentState.childPaintingLayer(currentObject)) |
| 102 #if ENABLE(ASSERT) | |
| 103 , | |
| 104 m_didUpdateForChildren(false) | |
| 105 #endif | |
| 106 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 98 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 107 , | 99 , |
| 108 m_canCheckFastPathSlowPathEquality( | 100 m_canCheckFastPathSlowPathEquality( |
| 109 parentState.m_canCheckFastPathSlowPathEquality) | 101 parentState.m_canCheckFastPathSlowPathEquality) |
| 110 #endif | 102 #endif |
| 111 { | 103 { |
| 112 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); | 104 DCHECK(!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); |
| 113 DCHECK(&m_paintingLayer == currentObject.paintingLayer()); | 105 DCHECK(&m_paintingLayer == currentObject.paintingLayer()); |
| 114 | 106 |
| 115 if (currentObject == parentState.m_currentObject) { | 107 if (currentObject == parentState.m_currentObject) { |
| 116 // Sometimes we create a new PaintInvalidationState from parentState on the same | 108 // Sometimes we create a new PaintInvalidationState from parentState on the same |
| 117 // object (e.g. LayoutView, and the HorriblySlowRectMapping cases in | 109 // object (e.g. LayoutView, and the HorriblySlowRectMapping cases in |
| 118 // LayoutBlock::invalidatePaintOfSubtreesIfNeeded()). | 110 // LayoutBlock::invalidatePaintOfSubtreesIfNeeded()). |
| 119 // TODO(wangxianzhu): Avoid this for | 111 // TODO(wangxianzhu): Avoid this for |
| 120 // RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(). | 112 // RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(). |
| 121 #if ENABLE(ASSERT) | 113 #if DCHECK_IS_ON() |
| 122 m_didUpdateForChildren = parentState.m_didUpdateForChildren; | 114 m_didUpdateForChildren = parentState.m_didUpdateForChildren; |
| 123 #endif | 115 #endif |
| 124 return; | 116 return; |
| 125 } | 117 } |
| 126 | 118 |
| 127 #if ENABLE(ASSERT) | 119 #if DCHECK_IS_ON() |
| 128 DCHECK(parentState.m_didUpdateForChildren); | 120 DCHECK(parentState.m_didUpdateForChildren); |
| 129 #endif | 121 #endif |
| 130 | 122 |
| 131 if (currentObject.isPaintInvalidationContainer()) { | 123 if (currentObject.isPaintInvalidationContainer()) { |
| 132 m_paintInvalidationContainer = toLayoutBoxModelObject(¤tObject); | 124 m_paintInvalidationContainer = toLayoutBoxModelObject(¤tObject); |
| 133 if (currentObject.styleRef().isStackingContext()) | 125 if (currentObject.styleRef().isStackingContext()) |
| 134 m_paintInvalidationContainerForStackedContents = | 126 m_paintInvalidationContainerForStackedContents = |
| 135 toLayoutBoxModelObject(¤tObject); | 127 toLayoutBoxModelObject(¤tObject); |
| 136 } else if (currentObject.isLayoutView()) { | 128 } else if (currentObject.isLayoutView()) { |
| 137 // m_paintInvalidationContainerForStackedContents is only for stacked | 129 // m_paintInvalidationContainerForStackedContents is only for stacked |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (m_currentObject.isBox()) | 298 if (m_currentObject.isBox()) |
| 307 m_paintOffset += toLayoutBox(m_currentObject).locationOffset(); | 299 m_paintOffset += toLayoutBox(m_currentObject).locationOffset(); |
| 308 | 300 |
| 309 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer()) | 301 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer()) |
| 310 m_paintOffset += toLayoutBoxModelObject(m_currentObject) | 302 m_paintOffset += toLayoutBoxModelObject(m_currentObject) |
| 311 .layer() | 303 .layer() |
| 312 ->offsetForInFlowPosition(); | 304 ->offsetForInFlowPosition(); |
| 313 } | 305 } |
| 314 | 306 |
| 315 void PaintInvalidationState::updateForChildren(PaintInvalidationReason reason) { | 307 void PaintInvalidationState::updateForChildren(PaintInvalidationReason reason) { |
| 316 #if ENABLE(ASSERT) | 308 #if DCHECK_IS_ON() |
| 317 DCHECK(!m_didUpdateForChildren); | 309 DCHECK(!m_didUpdateForChildren); |
| 318 m_didUpdateForChildren = true; | 310 m_didUpdateForChildren = true; |
| 319 #endif | 311 #endif |
| 320 | 312 |
| 321 switch (reason) { | 313 switch (reason) { |
| 322 case PaintInvalidationDelayedFull: | 314 case PaintInvalidationDelayedFull: |
| 323 m_pendingDelayedPaintInvalidations.push_back(&m_currentObject); | 315 m_pendingDelayedPaintInvalidations.push_back(&m_currentObject); |
| 324 break; | 316 break; |
| 325 case PaintInvalidationSubtree: | 317 case PaintInvalidationSubtree: |
| 326 m_forcedSubtreeInvalidationFlags |= | 318 m_forcedSubtreeInvalidationFlags |= |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 if (ancestor.isBox()) { | 411 if (ancestor.isBox()) { |
| 420 const LayoutBox* box = toLayoutBox(&ancestor); | 412 const LayoutBox* box = toLayoutBox(&ancestor); |
| 421 if (box->hasOverflowClip()) | 413 if (box->hasOverflowClip()) |
| 422 result.move(box->scrolledContentOffset()); | 414 result.move(box->scrolledContentOffset()); |
| 423 } | 415 } |
| 424 return result; | 416 return result; |
| 425 } | 417 } |
| 426 | 418 |
| 427 LayoutPoint PaintInvalidationState::computeLocationInBacking( | 419 LayoutPoint PaintInvalidationState::computeLocationInBacking( |
| 428 const LayoutPoint& visualRectLocation) const { | 420 const LayoutPoint& visualRectLocation) const { |
| 429 #if ENABLE(ASSERT) | 421 #if DCHECK_IS_ON() |
| 430 DCHECK(!m_didUpdateForChildren); | 422 DCHECK(!m_didUpdateForChildren); |
| 431 #endif | 423 #endif |
| 432 | 424 |
| 433 // Use visual rect location for LayoutTexts because it suffices to check | 425 // Use visual rect location for LayoutTexts because it suffices to check |
| 434 // visual rect change for layout caused invalidation. | 426 // visual rect change for layout caused invalidation. |
| 435 if (m_currentObject.isText()) | 427 if (m_currentObject.isText()) |
| 436 return visualRectLocation; | 428 return visualRectLocation; |
| 437 | 429 |
| 438 FloatPoint point; | 430 FloatPoint point; |
| 439 if (m_paintInvalidationContainer != &m_currentObject) { | 431 if (m_paintInvalidationContainer != &m_currentObject) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 452 } | 444 } |
| 453 } | 445 } |
| 454 | 446 |
| 455 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 447 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 456 *m_paintInvalidationContainer, point); | 448 *m_paintInvalidationContainer, point); |
| 457 | 449 |
| 458 return LayoutPoint(point); | 450 return LayoutPoint(point); |
| 459 } | 451 } |
| 460 | 452 |
| 461 LayoutRect PaintInvalidationState::computeVisualRectInBacking() const { | 453 LayoutRect PaintInvalidationState::computeVisualRectInBacking() const { |
| 462 #if ENABLE(ASSERT) | 454 #if DCHECK_IS_ON() |
| 463 DCHECK(!m_didUpdateForChildren); | 455 DCHECK(!m_didUpdateForChildren); |
| 464 #endif | 456 #endif |
| 465 | 457 |
| 466 if (m_currentObject.isSVGChild()) | 458 if (m_currentObject.isSVGChild()) |
| 467 return computeVisualRectInBackingForSVG(); | 459 return computeVisualRectInBackingForSVG(); |
| 468 | 460 |
| 469 LayoutRect rect = m_currentObject.localVisualRect(); | 461 LayoutRect rect = m_currentObject.localVisualRect(); |
| 470 mapLocalRectToPaintInvalidationBacking(rect); | 462 mapLocalRectToPaintInvalidationBacking(rect); |
| 471 return rect; | 463 return rect; |
| 472 } | 464 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 504 |
| 513 if (object.isLayoutView()) | 505 if (object.isLayoutView()) |
| 514 toLayoutView(object).mapToVisualRectInAncestorSpace( | 506 toLayoutView(object).mapToVisualRectInAncestorSpace( |
| 515 &ancestor, rect, InputIsInFrameCoordinates, DefaultVisualRectFlags); | 507 &ancestor, rect, InputIsInFrameCoordinates, DefaultVisualRectFlags); |
| 516 else | 508 else |
| 517 object.mapToVisualRectInAncestorSpace(&ancestor, rect); | 509 object.mapToVisualRectInAncestorSpace(&ancestor, rect); |
| 518 } | 510 } |
| 519 | 511 |
| 520 void PaintInvalidationState::mapLocalRectToPaintInvalidationContainer( | 512 void PaintInvalidationState::mapLocalRectToPaintInvalidationContainer( |
| 521 LayoutRect& rect) const { | 513 LayoutRect& rect) const { |
| 522 #if ENABLE(ASSERT) | 514 #if DCHECK_IS_ON() |
| 523 DCHECK(!m_didUpdateForChildren); | 515 DCHECK(!m_didUpdateForChildren); |
| 524 #endif | 516 #endif |
| 525 | 517 |
| 526 if (m_cachedOffsetsEnabled) { | 518 if (m_cachedOffsetsEnabled) { |
| 527 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 519 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 528 LayoutRect slowPathRect(rect); | 520 LayoutRect slowPathRect(rect); |
| 529 slowMapToVisualRectInAncestorSpace( | 521 slowMapToVisualRectInAncestorSpace( |
| 530 m_currentObject, *m_paintInvalidationContainer, slowPathRect); | 522 m_currentObject, *m_paintInvalidationContainer, slowPathRect); |
| 531 #endif | 523 #endif |
| 532 rect.move(m_paintOffset); | 524 rect.move(m_paintOffset); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 } | 632 } |
| 641 | 633 |
| 642 void PaintInvalidatorContextAdapter::mapLocalRectToPaintInvalidationBacking( | 634 void PaintInvalidatorContextAdapter::mapLocalRectToPaintInvalidationBacking( |
| 643 const LayoutObject& object, | 635 const LayoutObject& object, |
| 644 LayoutRect& rect) const { | 636 LayoutRect& rect) const { |
| 645 DCHECK(&object == &m_paintInvalidationState.currentObject()); | 637 DCHECK(&object == &m_paintInvalidationState.currentObject()); |
| 646 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect); | 638 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect); |
| 647 } | 639 } |
| 648 | 640 |
| 649 } // namespace blink | 641 } // namespace blink |
| OLD | NEW |