Index: third_party/WebKit/Source/core/paint/PaintInvalidator.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp |
index 53706edb310dded7ec14855f7707cb77bc7b31b6..d2c45c496e4f6573abd8baccc2e7b34eec33a511 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidator.cpp |
@@ -273,11 +273,9 @@ class ScopedUndoFrameViewContentClipAndScroll { |
} // namespace |
-void PaintInvalidator::updateContext(const LayoutObject& object, |
- PaintInvalidatorContext& context) { |
- Optional<ScopedUndoFrameViewContentClipAndScroll> |
- undoFrameViewContentClipAndScroll; |
- |
+void PaintInvalidator::updatePaintInvalidationContainer( |
+ const LayoutObject& object, |
+ PaintInvalidatorContext& context) { |
if (object.isPaintInvalidationContainer()) { |
context.paintInvalidationContainer = toLayoutBoxModelObject(&object); |
if (object.styleRef().isStackingContext()) |
@@ -291,9 +289,6 @@ void PaintInvalidator::updateContext(const LayoutObject& object, |
// this frame's paintInvalidationContainer. |
context.paintInvalidationContainerForStackedContents = |
context.paintInvalidationContainer; |
- if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
- undoFrameViewContentClipAndScroll.emplace( |
- *toLayoutView(object).frameView(), context); |
} else if (object.isFloatingWithNonContainingBlockParent()) { |
context.paintInvalidationContainer = |
&object.containerForPaintInvalidation(); |
@@ -334,10 +329,18 @@ void PaintInvalidator::updateContext(const LayoutObject& object, |
DCHECK(context.paintInvalidationContainer == |
object.containerForPaintInvalidation()); |
DCHECK(context.paintingLayer == object.paintingLayer()); |
+} |
- if (object.mayNeedPaintInvalidationSubtree()) |
- context.forcedSubtreeInvalidationFlags |= |
- PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
+void PaintInvalidator::updateVisualRect(const LayoutObject& object, |
+ PaintInvalidatorContext& context) { |
+ Optional<ScopedUndoFrameViewContentClipAndScroll> |
+ undoFrameViewContentClipAndScroll; |
+ |
+ if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
+ object.isLayoutView() && !object.isPaintInvalidationContainer()) { |
+ undoFrameViewContentClipAndScroll.emplace(*toLayoutView(object).frameView(), |
+ context); |
+ } |
// TODO(crbug.com/637313): Use GeometryMapper which now supports filter |
// geometry effects, after skia optimizes filter's mapRect operation. |
@@ -395,6 +398,10 @@ void PaintInvalidator::invalidatePaintIfNeeded( |
void PaintInvalidator::invalidatePaintIfNeeded( |
const LayoutObject& object, |
PaintInvalidatorContext& context) { |
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), |
+ "PaintInvalidator::invalidatePaintIfNeeded()", "object", |
+ object.debugName().ascii()); |
+ |
object.getMutableForPainting().ensureIsReadyForPaintInvalidation(); |
// The paint offset should already be updated through |
@@ -402,25 +409,24 @@ void PaintInvalidator::invalidatePaintIfNeeded( |
DCHECK(context.treeBuilderContext.current.paintOffset == |
object.paintOffset()); |
- if (!context.forcedSubtreeInvalidationFlags && |
- !object |
- .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) |
- return; |
- |
updatePaintingLayer(object, context); |
if (object.document().printing() && |
!RuntimeEnabledFeatures::printBrowserEnabled()) |
return; // Don't invalidate paints if we're printing. |
- TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), |
- "PaintInvalidator::invalidatePaintIfNeeded()", "object", |
- object.debugName().ascii()); |
+ updatePaintInvalidationContainer(object, context); |
- updateContext(object, context); |
+ bool objectShouldCheckForPaintInvalidation = |
+ object |
+ .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); |
+ if (!context.forcedSubtreeInvalidationFlags && |
+ !objectShouldCheckForPaintInvalidation) |
+ return; |
- if (!object |
- .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && |
+ updateVisualRect(object, context); |
+ |
+ if (!objectShouldCheckForPaintInvalidation && |
context.forcedSubtreeInvalidationFlags == |
PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate) { |
// We are done updating the visual rect. No other paint invalidation work to |
@@ -447,21 +453,15 @@ void PaintInvalidator::invalidatePaintIfNeeded( |
break; |
} |
- if (context.oldLocation != context.newLocation) { |
+ if (object.mayNeedPaintInvalidationSubtree()) { |
context.forcedSubtreeInvalidationFlags |= |
PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
} |
- // TODO(crbug.com/490725): This is a workaround for the bug, to force |
- // descendant to update visual rects on clipping change. |
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
- context.oldVisualRect != context.newVisualRect |
- // Note that isLayoutView() below becomes unnecessary after the launch of |
- // root layer scrolling. |
- && (object.hasOverflowClip() || object.isLayoutView()) && |
- !toLayoutBox(object).usesCompositedScrolling()) |
+ if (context.oldLocation != context.newLocation) { |
context.forcedSubtreeInvalidationFlags |= |
- PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; |
+ PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
+ } |
} |
void PaintInvalidator::processPendingDelayedPaintInvalidations() { |