| 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 25 matching lines...) Expand all Loading... |
| 36 PaintInvalidationState::PaintInvalidationState( | 36 PaintInvalidationState::PaintInvalidationState( |
| 37 const LayoutView& layoutView, | 37 const LayoutView& layoutView, |
| 38 Vector<const LayoutObject*>& pendingDelayedPaintInvalidations) | 38 Vector<const LayoutObject*>& pendingDelayedPaintInvalidations) |
| 39 : m_currentObject(layoutView), | 39 : m_currentObject(layoutView), |
| 40 m_forcedSubtreeInvalidationFlags(0), | 40 m_forcedSubtreeInvalidationFlags(0), |
| 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_scrollAdjustment( |
| 47 m_paintInvalidationContainer->scrollAdjustmentForPaintInvalidation()), |
| 46 m_paintInvalidationContainerForStackedContents( | 48 m_paintInvalidationContainerForStackedContents( |
| 47 m_paintInvalidationContainer), | 49 m_paintInvalidationContainer), |
| 48 m_containerForAbsolutePosition(layoutView), | 50 m_containerForAbsolutePosition(layoutView), |
| 49 m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations), | 51 m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations), |
| 50 m_paintingLayer(*layoutView.layer()) | 52 m_paintingLayer(*layoutView.layer()) |
| 51 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 53 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 52 , | 54 , |
| 53 m_canCheckFastPathSlowPathEquality(layoutView == | 55 m_canCheckFastPathSlowPathEquality(layoutView == |
| 54 m_paintInvalidationContainer) | 56 m_paintInvalidationContainer) |
| 55 #endif | 57 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 78 m_clippedForAbsolutePosition(parentState.m_clippedForAbsolutePosition), | 80 m_clippedForAbsolutePosition(parentState.m_clippedForAbsolutePosition), |
| 79 m_clipRect(parentState.m_clipRect), | 81 m_clipRect(parentState.m_clipRect), |
| 80 m_clipRectForAbsolutePosition(parentState.m_clipRectForAbsolutePosition), | 82 m_clipRectForAbsolutePosition(parentState.m_clipRectForAbsolutePosition), |
| 81 m_paintOffset(parentState.m_paintOffset), | 83 m_paintOffset(parentState.m_paintOffset), |
| 82 m_paintOffsetForAbsolutePosition( | 84 m_paintOffsetForAbsolutePosition( |
| 83 parentState.m_paintOffsetForAbsolutePosition), | 85 parentState.m_paintOffsetForAbsolutePosition), |
| 84 m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled), | 86 m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled), |
| 85 m_cachedOffsetsForAbsolutePositionEnabled( | 87 m_cachedOffsetsForAbsolutePositionEnabled( |
| 86 parentState.m_cachedOffsetsForAbsolutePositionEnabled), | 88 parentState.m_cachedOffsetsForAbsolutePositionEnabled), |
| 87 m_paintInvalidationContainer(parentState.m_paintInvalidationContainer), | 89 m_paintInvalidationContainer(parentState.m_paintInvalidationContainer), |
| 90 m_scrollAdjustment(parentState.m_scrollAdjustment), |
| 88 m_paintInvalidationContainerForStackedContents( | 91 m_paintInvalidationContainerForStackedContents( |
| 89 parentState.m_paintInvalidationContainerForStackedContents), | 92 parentState.m_paintInvalidationContainerForStackedContents), |
| 90 m_containerForAbsolutePosition( | 93 m_containerForAbsolutePosition( |
| 91 currentObject.canContainAbsolutePositionObjects() | 94 currentObject.canContainAbsolutePositionObjects() |
| 92 ? currentObject | 95 ? currentObject |
| 93 : parentState.m_containerForAbsolutePosition), | 96 : parentState.m_containerForAbsolutePosition), |
| 94 m_svgTransform(parentState.m_svgTransform), | 97 m_svgTransform(parentState.m_svgTransform), |
| 95 m_pendingDelayedPaintInvalidations( | 98 m_pendingDelayedPaintInvalidations( |
| 96 parentState.m_pendingDelayedPaintInvalidations), | 99 parentState.m_pendingDelayedPaintInvalidations), |
| 97 m_paintingLayer(parentState.childPaintingLayer(currentObject)) | 100 m_paintingLayer(parentState.childPaintingLayer(currentObject)) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 113 #if DCHECK_IS_ON() | 116 #if DCHECK_IS_ON() |
| 114 m_didUpdateForChildren = parentState.m_didUpdateForChildren; | 117 m_didUpdateForChildren = parentState.m_didUpdateForChildren; |
| 115 #endif | 118 #endif |
| 116 return; | 119 return; |
| 117 } | 120 } |
| 118 | 121 |
| 119 #if DCHECK_IS_ON() | 122 #if DCHECK_IS_ON() |
| 120 DCHECK(parentState.m_didUpdateForChildren); | 123 DCHECK(parentState.m_didUpdateForChildren); |
| 121 #endif | 124 #endif |
| 122 | 125 |
| 126 const auto* oldPaintInvalidationContainer = m_paintInvalidationContainer; |
| 123 if (currentObject.isPaintInvalidationContainer()) { | 127 if (currentObject.isPaintInvalidationContainer()) { |
| 124 m_paintInvalidationContainer = toLayoutBoxModelObject(¤tObject); | 128 m_paintInvalidationContainer = toLayoutBoxModelObject(¤tObject); |
| 125 if (currentObject.styleRef().isStackingContext()) | 129 if (currentObject.styleRef().isStackingContext()) |
| 126 m_paintInvalidationContainerForStackedContents = | 130 m_paintInvalidationContainerForStackedContents = |
| 127 toLayoutBoxModelObject(¤tObject); | 131 toLayoutBoxModelObject(¤tObject); |
| 128 } else if (currentObject.isLayoutView()) { | 132 } else if (currentObject.isLayoutView()) { |
| 129 // m_paintInvalidationContainerForStackedContents is only for stacked | 133 // m_paintInvalidationContainerForStackedContents is only for stacked |
| 130 // descendants in its own frame, because it doesn't establish stacking | 134 // descendants in its own frame, because it doesn't establish stacking |
| 131 // context for stacked contents in sub-frames. Contents stacked in the root | 135 // context for stacked contents in sub-frames. Contents stacked in the root |
| 132 // stacking context in this frame should use this frame's | 136 // stacking context in this frame should use this frame's |
| (...skipping 27 matching lines...) Expand all Loading... |
| 160 // path and enable fast path for descendants if possible; or | 164 // path and enable fast path for descendants if possible; or |
| 161 // - Track offset between the two paintInvalidationContainers. | 165 // - Track offset between the two paintInvalidationContainers. |
| 162 m_cachedOffsetsEnabled = false; | 166 m_cachedOffsetsEnabled = false; |
| 163 if (m_forcedSubtreeInvalidationFlags & | 167 if (m_forcedSubtreeInvalidationFlags & |
| 164 PaintInvalidatorContext:: | 168 PaintInvalidatorContext:: |
| 165 ForcedSubtreeFullInvalidationForStackedContents) | 169 ForcedSubtreeFullInvalidationForStackedContents) |
| 166 m_forcedSubtreeInvalidationFlags |= | 170 m_forcedSubtreeInvalidationFlags |= |
| 167 PaintInvalidatorContext::ForcedSubtreeFullInvalidation; | 171 PaintInvalidatorContext::ForcedSubtreeFullInvalidation; |
| 168 } | 172 } |
| 169 | 173 |
| 174 if (m_paintInvalidationContainer != oldPaintInvalidationContainer) { |
| 175 m_scrollAdjustment = |
| 176 m_paintInvalidationContainer->scrollAdjustmentForPaintInvalidation(); |
| 177 } else { |
| 178 DCHECK( |
| 179 m_scrollAdjustment == |
| 180 m_paintInvalidationContainer->scrollAdjustmentForPaintInvalidation()); |
| 181 } |
| 182 |
| 170 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) | 183 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) |
| 171 return; | 184 return; |
| 172 | 185 |
| 173 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer) | 186 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer) |
| 174 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject); | 187 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject); |
| 175 | 188 |
| 176 if (currentObject.isSVG()) { | 189 if (currentObject.isSVG()) { |
| 177 if (currentObject.isSVGRoot()) { | 190 if (currentObject.isSVGRoot()) { |
| 178 m_svgTransform = | 191 m_svgTransform = |
| 179 toLayoutSVGRoot(currentObject).localToBorderBoxTransform(); | 192 toLayoutSVGRoot(currentObject).localToBorderBoxTransform(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 point += FloatPoint(m_paintOffset); | 448 point += FloatPoint(m_paintOffset); |
| 436 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 449 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 437 DCHECK(point == | 450 DCHECK(point == |
| 438 slowLocalOriginToAncestorPoint( | 451 slowLocalOriginToAncestorPoint( |
| 439 m_currentObject, m_paintInvalidationContainer, FloatPoint())); | 452 m_currentObject, m_paintInvalidationContainer, FloatPoint())); |
| 440 #endif | 453 #endif |
| 441 } else { | 454 } else { |
| 442 point = slowLocalToAncestorPoint( | 455 point = slowLocalToAncestorPoint( |
| 443 m_currentObject, *m_paintInvalidationContainer, FloatPoint()); | 456 m_currentObject, *m_paintInvalidationContainer, FloatPoint()); |
| 444 } | 457 } |
| 458 |
| 459 point.move(m_scrollAdjustment); |
| 445 } | 460 } |
| 446 | 461 |
| 447 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 462 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 448 *m_paintInvalidationContainer, point); | 463 *m_paintInvalidationContainer, point); |
| 449 | 464 |
| 450 point.move(m_currentObject.scrollAdjustmentForPaintInvalidation( | |
| 451 *m_paintInvalidationContainer)); | |
| 452 | |
| 453 return LayoutPoint(point); | 465 return LayoutPoint(point); |
| 454 } | 466 } |
| 455 | 467 |
| 456 LayoutRect PaintInvalidationState::computeVisualRectInBacking() const { | 468 LayoutRect PaintInvalidationState::computeVisualRectInBacking() const { |
| 457 #if DCHECK_IS_ON() | 469 #if DCHECK_IS_ON() |
| 458 DCHECK(!m_didUpdateForChildren); | 470 DCHECK(!m_didUpdateForChildren); |
| 459 #endif | 471 #endif |
| 460 | 472 |
| 461 if (m_currentObject.isSVGChild()) | 473 if (m_currentObject.isSVGChild()) |
| 462 return computeVisualRectInBackingForSVG(); | 474 return computeVisualRectInBackingForSVG(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 486 // and slow path (for things above the SVGRoot). | 498 // and slow path (for things above the SVGRoot). |
| 487 rect = SVGLayoutSupport::visualRectInAncestorSpace( | 499 rect = SVGLayoutSupport::visualRectInAncestorSpace( |
| 488 m_currentObject, *m_paintInvalidationContainer); | 500 m_currentObject, *m_paintInvalidationContainer); |
| 489 } | 501 } |
| 490 | 502 |
| 491 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 503 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
| 492 *m_paintInvalidationContainer, rect); | 504 *m_paintInvalidationContainer, rect); |
| 493 | 505 |
| 494 m_currentObject.adjustVisualRectForRasterEffects(rect); | 506 m_currentObject.adjustVisualRectForRasterEffects(rect); |
| 495 | 507 |
| 496 rect.move(m_currentObject.scrollAdjustmentForPaintInvalidation( | 508 if (m_currentObject != m_paintInvalidationContainer) |
| 497 *m_paintInvalidationContainer)); | 509 rect.move(m_scrollAdjustment); |
| 498 | 510 |
| 499 return rect; | 511 return rect; |
| 500 } | 512 } |
| 501 | 513 |
| 502 static void slowMapToVisualRectInAncestorSpace( | 514 static void slowMapToVisualRectInAncestorSpace( |
| 503 const LayoutObject& object, | 515 const LayoutObject& object, |
| 504 const LayoutBoxModelObject& ancestor, | 516 const LayoutBoxModelObject& ancestor, |
| 505 LayoutRect& rect) { | 517 LayoutRect& rect) { |
| 506 // TODO(wkorman): The flip below is required because visual rects are | 518 // TODO(wkorman): The flip below is required because visual rects are |
| 507 // currently in "physical coordinates with flipped block-flow direction" | 519 // currently in "physical coordinates with flipped block-flow direction" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 556 |
| 545 void PaintInvalidationState::mapLocalRectToVisualRectInBacking( | 557 void PaintInvalidationState::mapLocalRectToVisualRectInBacking( |
| 546 LayoutRect& rect) const { | 558 LayoutRect& rect) const { |
| 547 mapLocalRectToPaintInvalidationContainer(rect); | 559 mapLocalRectToPaintInvalidationContainer(rect); |
| 548 | 560 |
| 549 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 561 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
| 550 *m_paintInvalidationContainer, rect); | 562 *m_paintInvalidationContainer, rect); |
| 551 | 563 |
| 552 m_currentObject.adjustVisualRectForRasterEffects(rect); | 564 m_currentObject.adjustVisualRectForRasterEffects(rect); |
| 553 | 565 |
| 554 rect.move(m_currentObject.scrollAdjustmentForPaintInvalidation( | 566 if (m_currentObject != m_paintInvalidationContainer) |
| 555 *m_paintInvalidationContainer)); | 567 rect.move(m_scrollAdjustment); |
| 556 } | 568 } |
| 557 | 569 |
| 558 void PaintInvalidationState::addClipRectRelativeToPaintOffset( | 570 void PaintInvalidationState::addClipRectRelativeToPaintOffset( |
| 559 const LayoutRect& localClipRect) { | 571 const LayoutRect& localClipRect) { |
| 560 LayoutRect clipRect = localClipRect; | 572 LayoutRect clipRect = localClipRect; |
| 561 clipRect.move(m_paintOffset); | 573 clipRect.move(m_paintOffset); |
| 562 if (m_clipped) { | 574 if (m_clipped) { |
| 563 m_clipRect.intersect(clipRect); | 575 m_clipRect.intersect(clipRect); |
| 564 } else { | 576 } else { |
| 565 m_clipRect = clipRect; | 577 m_clipRect = clipRect; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 } | 658 } |
| 647 | 659 |
| 648 void PaintInvalidatorContextAdapter::mapLocalRectToVisualRectInBacking( | 660 void PaintInvalidatorContextAdapter::mapLocalRectToVisualRectInBacking( |
| 649 const LayoutObject& object, | 661 const LayoutObject& object, |
| 650 LayoutRect& rect) const { | 662 LayoutRect& rect) const { |
| 651 DCHECK(&object == &m_paintInvalidationState.currentObject()); | 663 DCHECK(&object == &m_paintInvalidationState.currentObject()); |
| 652 m_paintInvalidationState.mapLocalRectToVisualRectInBacking(rect); | 664 m_paintInvalidationState.mapLocalRectToVisualRectInBacking(rect); |
| 653 } | 665 } |
| 654 | 666 |
| 655 } // namespace blink | 667 } // namespace blink |
| OLD | NEW |