| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/paint/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 LayoutRect PaintInvalidator::mapLocalRectToPaintInvalidationBacking( | 134 LayoutRect PaintInvalidator::mapLocalRectToPaintInvalidationBacking( |
| 135 const LayoutObject& object, | 135 const LayoutObject& object, |
| 136 const FloatRect& localRect, | 136 const FloatRect& localRect, |
| 137 const PaintInvalidatorContext& context) { | 137 const PaintInvalidatorContext& context) { |
| 138 return blink::mapLocalRectToPaintInvalidationBacking(m_geometryMapper, object, | 138 return blink::mapLocalRectToPaintInvalidationBacking(m_geometryMapper, object, |
| 139 localRect, context); | 139 localRect, context); |
| 140 } | 140 } |
| 141 | 141 |
| 142 LayoutRect PaintInvalidator::computePaintInvalidationRectInBacking( | 142 LayoutRect PaintInvalidator::computeVisualRectInBacking( |
| 143 const LayoutObject& object, | 143 const LayoutObject& object, |
| 144 const PaintInvalidatorContext& context) { | 144 const PaintInvalidatorContext& context) { |
| 145 FloatRect localRect; | 145 FloatRect localRect; |
| 146 if (object.isSVG() && !object.isSVGRoot()) | 146 if (object.isSVG() && !object.isSVGRoot()) |
| 147 localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(object); | 147 localRect = SVGLayoutSupport::localVisualRect(object); |
| 148 else | 148 else |
| 149 localRect = FloatRect(object.localOverflowRectForPaintInvalidation()); | 149 localRect = FloatRect(object.localVisualRect()); |
| 150 | 150 |
| 151 return mapLocalRectToPaintInvalidationBacking(object, localRect, context); | 151 return mapLocalRectToPaintInvalidationBacking(object, localRect, context); |
| 152 } | 152 } |
| 153 | 153 |
| 154 LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking( | 154 LayoutPoint PaintInvalidator::computeLocationFromPaintInvalidationBacking( |
| 155 const LayoutObject& object, | 155 const LayoutObject& object, |
| 156 const PaintInvalidatorContext& context) { | 156 const PaintInvalidatorContext& context) { |
| 157 FloatPoint point; | 157 FloatPoint point; |
| 158 if (object != context.paintInvalidationContainer) { | 158 if (object != context.paintInvalidationContainer) { |
| 159 point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); | 159 point.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 context.forcedSubtreeInvalidationFlags |= | 315 context.forcedSubtreeInvalidationFlags |= |
| 316 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | 316 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
| 317 | 317 |
| 318 // TODO(crbug.com/637313): This is temporary before we support filters in | 318 // TODO(crbug.com/637313): This is temporary before we support filters in |
| 319 // paint property tree. | 319 // paint property tree. |
| 320 // TODO(crbug.com/648274): This is a workaround for multi-column contents. | 320 // TODO(crbug.com/648274): This is a workaround for multi-column contents. |
| 321 if (object.hasFilterInducingProperty() || object.isLayoutFlowThread()) | 321 if (object.hasFilterInducingProperty() || object.isLayoutFlowThread()) |
| 322 context.forcedSubtreeInvalidationFlags |= | 322 context.forcedSubtreeInvalidationFlags |= |
| 323 PaintInvalidatorContext::ForcedSubtreeSlowPathRect; | 323 PaintInvalidatorContext::ForcedSubtreeSlowPathRect; |
| 324 | 324 |
| 325 context.oldBounds = object.previousPaintInvalidationRect(); | 325 context.oldVisualRect = object.previousVisualRect(); |
| 326 context.oldLocation = object.previousPositionFromPaintInvalidationBacking(); | 326 context.oldLocation = object.previousPositionFromPaintInvalidationBacking(); |
| 327 context.newBounds = computePaintInvalidationRectInBacking(object, context); | 327 context.newVisualRect = computeVisualRectInBacking(object, context); |
| 328 context.newLocation = | 328 context.newLocation = |
| 329 computeLocationFromPaintInvalidationBacking(object, context); | 329 computeLocationFromPaintInvalidationBacking(object, context); |
| 330 | 330 |
| 331 IntSize adjustment = object.scrollAdjustmentForPaintInvalidation( | 331 IntSize adjustment = object.scrollAdjustmentForPaintInvalidation( |
| 332 *context.paintInvalidationContainer); | 332 *context.paintInvalidationContainer); |
| 333 context.newLocation.move(adjustment); | 333 context.newLocation.move(adjustment); |
| 334 context.newBounds.move(adjustment); | 334 context.newVisualRect.move(adjustment); |
| 335 | 335 |
| 336 object.getMutableForPainting().setPreviousPaintInvalidationRect( | 336 object.getMutableForPainting().setPreviousVisualRect(context.newVisualRect); |
| 337 context.newBounds); | |
| 338 object.getMutableForPainting() | 337 object.getMutableForPainting() |
| 339 .setPreviousPositionFromPaintInvalidationBacking(context.newLocation); | 338 .setPreviousPositionFromPaintInvalidationBacking(context.newLocation); |
| 340 } | 339 } |
| 341 | 340 |
| 342 void PaintInvalidator::invalidatePaintIfNeeded( | 341 void PaintInvalidator::invalidatePaintIfNeeded( |
| 343 FrameView& frameView, | 342 FrameView& frameView, |
| 344 PaintInvalidatorContext& context) { | 343 PaintInvalidatorContext& context) { |
| 345 LayoutView* layoutView = frameView.layoutView(); | 344 LayoutView* layoutView = frameView.layoutView(); |
| 346 CHECK(layoutView); | 345 CHECK(layoutView); |
| 347 | 346 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), | 395 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), |
| 397 "PaintInvalidator::invalidatePaintIfNeeded()", "object", | 396 "PaintInvalidator::invalidatePaintIfNeeded()", "object", |
| 398 object.debugName().ascii()); | 397 object.debugName().ascii()); |
| 399 | 398 |
| 400 updateContext(object, context); | 399 updateContext(object, context); |
| 401 | 400 |
| 402 if (!object | 401 if (!object |
| 403 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()
&& | 402 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()
&& |
| 404 context.forcedSubtreeInvalidationFlags == | 403 context.forcedSubtreeInvalidationFlags == |
| 405 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate) { | 404 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate) { |
| 406 // We are done updating the paint invalidation rect. No other paint | 405 // We are done updating the visual rect. No other paint invalidation work to |
| 407 // invalidation work to do for this object. | 406 // do for this object. |
| 408 return; | 407 return; |
| 409 } | 408 } |
| 410 | 409 |
| 411 PaintInvalidationReason reason = object.invalidatePaintIfNeeded(context); | 410 PaintInvalidationReason reason = object.invalidatePaintIfNeeded(context); |
| 412 switch (reason) { | 411 switch (reason) { |
| 413 case PaintInvalidationDelayedFull: | 412 case PaintInvalidationDelayedFull: |
| 414 m_pendingDelayedPaintInvalidations.append(&object); | 413 m_pendingDelayedPaintInvalidations.append(&object); |
| 415 break; | 414 break; |
| 416 case PaintInvalidationSubtree: | 415 case PaintInvalidationSubtree: |
| 417 context.forcedSubtreeInvalidationFlags |= | 416 context.forcedSubtreeInvalidationFlags |= |
| (...skipping 14 matching lines...) Expand all Loading... |
| 432 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | 431 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
| 433 | 432 |
| 434 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we | 433 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we |
| 435 // detect paint offset change. | 434 // detect paint offset change. |
| 436 if (reason != PaintInvalidationNone && | 435 if (reason != PaintInvalidationNone && |
| 437 hasPercentageTransform(object.styleRef())) | 436 hasPercentageTransform(object.styleRef())) |
| 438 context.forcedSubtreeInvalidationFlags |= | 437 context.forcedSubtreeInvalidationFlags |= |
| 439 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | 438 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
| 440 | 439 |
| 441 // TODO(crbug.com/490725): This is a workaround for the bug, to force | 440 // TODO(crbug.com/490725): This is a workaround for the bug, to force |
| 442 // descendant to update paint invalidation rects on clipping change. | 441 // descendant to update visual rects on clipping change. |
| 443 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 442 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 444 context.oldBounds != context.newBounds | 443 context.oldVisualRect != context.newVisualRect |
| 445 // Note that isLayoutView() below becomes unnecessary after the launch of | 444 // Note that isLayoutView() below becomes unnecessary after the launch of |
| 446 // root layer scrolling. | 445 // root layer scrolling. |
| 447 && (object.hasOverflowClip() || object.isLayoutView()) && | 446 && (object.hasOverflowClip() || object.isLayoutView()) && |
| 448 !toLayoutBox(object).usesCompositedScrolling()) | 447 !toLayoutBox(object).usesCompositedScrolling()) |
| 449 context.forcedSubtreeInvalidationFlags |= | 448 context.forcedSubtreeInvalidationFlags |= |
| 450 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; | 449 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; |
| 451 | 450 |
| 452 object.getMutableForPainting().clearPaintInvalidationFlags(); | 451 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 453 } | 452 } |
| 454 | 453 |
| 455 void PaintInvalidator::processPendingDelayedPaintInvalidations() { | 454 void PaintInvalidator::processPendingDelayedPaintInvalidations() { |
| 456 for (auto target : m_pendingDelayedPaintInvalidations) | 455 for (auto target : m_pendingDelayedPaintInvalidations) |
| 457 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 456 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 458 PaintInvalidationDelayedFull); | 457 PaintInvalidationDelayedFull); |
| 459 } | 458 } |
| 460 | 459 |
| 461 } // namespace blink | 460 } // namespace blink |
| OLD | NEW |