diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 6dde37d6cae9b5..ccf99cbd05f9c5 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -929,6 +929,97 @@ crbug.com/619060 imported/wpt/pointerevents/pointerevent_pointerleave_after_poin
crbug.com/619060 imported/wpt/pointerevents/pointerevent_pointerleave_after_pointerup_nohover-manual.html [ Skip ]
crbug.com/619060 imported/wpt/pointerevents/pointerevent_pointerleave_touch-manual.html [ Skip ]
+crbug.com/451090 compositing/squashing/remove-squashed-layer-plus-move.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/abspos-shift-image-incorrect-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/align-content-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/align-content-distribution-change-grid.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/align-content-position-change-grid.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/align-self-change-grid.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/align-self-overflow-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/background-generated.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/background-resize-height.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/background-shorthand-with-gradient-and-height-changes.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/background-size-auto-with-gradient-and-height-changes.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/block-shift-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/border-radius-repaint-2.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/box-inline-resize.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/box-shadow-dynamic.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/clipped-overflow-visible-subtree.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/clipped-relative.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/content-into-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/crbug-371640-2.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/crbug-371640-3.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/crbug-371640-4.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/crbug-371640.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/dynamic-table-vertical-alignment-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/erase-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/fixed-and-absolute-position-scrolled.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/float-move-during-layout.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/float-overflow-right.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/float-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/intermediate-layout-position.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-content-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-content-distribution-change-grid.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-content-position-change-grid.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-content-position-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-self-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/justify-self-overflow-change.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/layout-state-only-positioned.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/offset-change-wrong-invalidation-with-float.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/outline-child-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/overflow-into-content.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/paint-invalidation-with-reparent-across-frame-boundaries.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/percent-size-image-resize-container.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/positioned-document-element.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/positioned-great-grandparent-change-location.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/positioned-list-offset-change-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/reflection-repaint-test.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/relative-margin-change-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/repaint-descandant-on-ancestor-layer-move.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/repaint-resized-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/repaint-table-row-in-composited-document.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/replaced-clipped-positioned-not-wrong-incremental-repainting.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/resize-child-within-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/scrollbar-damage-and-full-viewport-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/selection-after-remove.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/selection-change-in-iframe-with-relative-parent.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/selection-clear.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/shift-relative-positioned-container-with-image-addition.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/shift-relative-positioned-container-with-image-removal.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/table-cell-move.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/table-section-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/table-section-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/table-shrink-row-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/text-selection-rect-in-overflow.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/text-selection-rect-in-overflow-2.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/transform-disable-layoutstate.html [ NeedsRebaseline ]
+crbug.com/451090 fast/repaint/window-resize-vertical-writing-mode.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/border-collapsing/cached-change-cell-border-width.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/border-collapsing/cached-change-col-border-width.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/border-collapsing/cached-change-row-border-width.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/border-collapsing/cached-change-tbody-border-width.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/resize-table-repaint-percent-size-cell.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/resize-table-repaint-vertical-align-cell.html [ NeedsRebaseline ]
+crbug.com/451090 fast/table/resize-table-row-repaint.html [ NeedsRebaseline ]
+crbug.com/451090 paint/selection/invalidation-rect-includes-newline-for-rtl.html [ NeedsRebaseline ]
+crbug.com/451090 paint/selection/invalidation-rect-with-br-includes-newline.html [ NeedsRebaseline ]
+crbug.com/451090 svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-1.html [ NeedsRebaseline ]
+crbug.com/451090 svg/as-object/deep-nested-embedded-svg-size-changes-no-layout-triggers-2.html [ NeedsRebaseline ]
+crbug.com/451090 svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-1.html [ NeedsRebaseline ]
+crbug.com/451090 svg/as-object/nested-embedded-svg-size-changes-no-layout-triggers-2.html [ NeedsRebaseline ]
+crbug.com/451090 svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml [ NeedsRebaseline ]
+crbug.com/451090 svg/custom/resource-client-removal.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/filters/filter-refresh.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/filter-child-repaint.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/image-with-clip-path.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/inner-svg-change-viewPort-relative.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/paintorder-filtered.svg [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/text-pattern-update-2.html [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/text-pattern-update.html [ NeedsRebaseline ]
+crbug.com/451090 svg/repaint/tspan-pattern-update.html [ NeedsRebaseline ]
+crbug.com/451090 svg/text/text-rescale.html [ NeedsRebaseline ]
+crbug.com/451090 svg/text/text-viewbox-rescale.html [ NeedsManualRebaseline ]
+
crbug.com/627341 imported/wpt/pointerevents/pointerevent_suppress_compat_events_on_click.html [ Skip ]
crbug.com/627341 imported/wpt/pointerevents/pointerevent_suppress_compat_events_on_drag_mouse.html [ Skip ]
crbug.com/627341 imported/wpt/pointerevents/pointerevent_touch-action-inherit_child-auto-child-none_touch-manual.html [ Skip ]
@@ -1111,7 +1202,8 @@ crbug.com/619103 paint/invalidation/invalidate-after-composited-scroll-of-window
crbug.com/619103 paint/invalidation/animated-gif.html [ Pass Failure ]
crbug.com/619103 paint/invalidation/animated-gif-background.html [ Pass Failure ]
crbug.com/619103 paint/invalidation/animated-gif-background-offscreen.html [ Pass Failure ]
-crbug.com/619103 [ Win ] svg/text/text-viewbox-rescale.html [ Pass Failure ]
+# TODO(wangxianzhu): Restore the following line after manual rebaseline.
+# crbug.com/619103 [ Win ] svg/text/text-viewbox-rescale.html [ Pass Failure ]
crbug.com/619103 paint/overflow/interest-rect-change-scroll-down.html [ Failure ]
crbug.com/619103 paint/selection/text-selection-newline-mixed-ltr-rtl.html [ Failure ]
crbug.com/619103 paint/selection/text-selection-newline-rtl-double-linebreak.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change-expected.html b/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change-expected.html
index a951ac9744b2a2..b137506e66049d 100644
--- a/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change-expected.html
+++ b/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change-expected.html
@@ -6,11 +6,12 @@
.child {
height: 20px;
width: 20px;
+ background-color: green;
}
-
+
diff --git a/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change.html b/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change.html
index fa22c893f25f18..b42165f451b964 100644
--- a/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change.html
+++ b/third_party/WebKit/LayoutTests/css3/flexbox/repaint-on-margin-change.html
@@ -14,11 +14,12 @@
.child {
height: 20px;
width: 20px;
+ background-color: green;
}
-
+
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
index 578b4b782c6ce6..a2547141b85282 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
@@ -341,6 +341,7 @@ class CORE_EXPORT LayoutBlockFlow : public LayoutBlock {
void addOutlineRects(Vector
&, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot) const override;
+ bool paintedOutputOfObjectHasNoEffect() const override;
PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&) override;
Node* nodeForHitTest() const final;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
index c0e08b00978960..6d210be8a57ddd 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -2062,6 +2062,15 @@ void LayoutBlockFlow::setShouldDoFullPaintInvalidationForFirstLine()
firstRootBox->setShouldDoFullPaintInvalidationRecursively();
}
+bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffect() const
+{
+ // LayoutBlockFlow is in charge of paint invalidation of the first line.
+ if (firstLineBox())
+ return false;
+
+ return LayoutBlock::paintedOutputOfObjectHasNoEffect();
+}
+
PaintInvalidationReason LayoutBlockFlow::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState)
{
if (containsFloats())
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 89b23b078658cc..7a739571095415 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -2034,6 +2034,28 @@ bool LayoutBox::needsForcedBreakBefore(EBreak previousBreakAfterValue) const
return isForcedFragmentainerBreakValue(classABreakPointValue(previousBreakAfterValue));
}
+bool LayoutBox::paintedOutputOfObjectHasNoEffect() const
+{
+ // In case scrollbars got repositioned (which will typically happen if the box got
+ // resized), we cannot skip invalidation.
+ if (hasNonCompositedScrollbars())
+ return false;
+
+ // Cannot skip paint invalidation if the box has real things to paint.
+ if (getSelectionState() != SelectionNone || hasBoxDecorationBackground() || styleRef().hasVisualOverflowingEffect())
+ return false;
+
+ // If the box has clip, we need issue a paint invalidation to cover the changed part of
+ // children because of change of clip when the box got resized. In theory the children
+ // should invalidate themselves when ancestor clip changes, but for now this is missing
+ // and ensuring it may hurt performance.
+ // TODO(wangxianzhu): Paint invalidation for clip change will be different in spv2.
+ if (hasClipRelatedProperty() || hasControlClip())
+ return false;
+
+ return true;
+}
+
LayoutRect LayoutBox::localOverflowRectForPaintInvalidation() const
{
if (style()->visibility() != VISIBLE)
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.h b/third_party/WebKit/Source/core/layout/LayoutBox.h
index e2046769f81c09..d7aab382c1a1a2 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.h
@@ -695,6 +695,7 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject {
// break, we also need to know the break-after value of the previous in-flow sibling.
bool needsForcedBreakBefore(EBreak previousBreakAfterValue) const;
+ bool paintedOutputOfObjectHasNoEffect() const override;
LayoutRect localOverflowRectForPaintInvalidation() const override;
bool mapToVisualRectInAncestorSpace(const LayoutBoxModelObject* ancestor, LayoutRect&, VisualRectFlags = DefaultVisualRectFlags) const override;
virtual void invalidatePaintForOverhangingFloats(bool paintAllDescendants);
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 78d02a87c11a1c..fbabc29e7b06f7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -684,28 +684,6 @@ LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const
return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this);
}
-bool LayoutObject::skipInvalidationWhenLaidOutChildren() const
-{
- if (!m_bitfields.neededLayoutBecauseOfChildren())
- return false;
-
- // SVG layoutObjects need to be invalidated when their children are laid out.
- // LayoutBlocks with line boxes are responsible to invalidate them so we can't ignore them.
- if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox()))
- return false;
-
- // In case scrollbars got repositioned (which will typically happen if the layout object got
- // resized), we cannot skip invalidation.
- if (hasNonCompositedScrollbars())
- return false;
-
- // We can't detect whether a plugin has box effects, so disable this optimization for that case.
- if (isEmbeddedObject())
- return false;
-
- return !hasBoxEffect();
-}
-
static inline bool objectIsRelayoutBoundary(const LayoutObject* object)
{
// FIXME: In future it may be possible to broaden these conditions in order to improve performance.
@@ -1330,7 +1308,6 @@ void LayoutObject::setPreviousSelectionRectForPaintInvalidation(const LayoutRect
selectionPaintInvalidationMap->set(this, selectionRect);
}
-// TODO(wangxianzhu): Remove this for slimming paint v2 because we won't care about paint invalidation rects.
inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason)
{
// Update selection rect when we are doing full invalidation (in case that the object is moved, composite status changed, etc.)
@@ -1354,11 +1331,10 @@ inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject
setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
- // TODO(wangxianzhu): Combine the following two conditions when removing LayoutView::doingFullPaintInvalidation().
- if (!fullInvalidation)
+ if (!fullInvalidation) {
fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
- if (shouldInvalidateSelection())
invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationState, PaintInvalidationSelection);
+ }
}
PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState)
@@ -1423,7 +1399,7 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid
// invalidation is issued. See crbug.com/508383 and crbug.com/515977.
// This is a workaround to force display items to update paint offset.
if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && paintInvalidationState.forcedSubtreeInvalidationCheckingWithinContainer())
- invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationState, invalidationReason);
+ invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationState, PaintInvalidationLocationChange);
return invalidationReason;
}
@@ -1447,6 +1423,9 @@ PaintInvalidationReason LayoutObject::getPaintInvalidationReason(const PaintInva
if (shouldDoFullPaintInvalidation())
return m_bitfields.fullPaintInvalidationReason();
+ if (paintedOutputOfObjectHasNoEffect())
+ return PaintInvalidationNone;
+
// The outline may change shape because of position change of descendants. For simplicity,
// just force full paint invalidation if this object is marked for checking paint invalidation
// for any reason.
@@ -1465,13 +1444,6 @@ PaintInvalidationReason LayoutObject::getPaintInvalidationReason(const PaintInva
if (newBounds.location() != oldBounds.location())
return PaintInvalidationBoundsChange;
- // This covers the case where we mark containing blocks for layout
- // and they change size but don't have anything to paint. This is
- // a pretty common case for as we add / remove children
- // (and the default background is done by FrameView).
- if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && skipInvalidationWhenLaidOutChildren())
- return PaintInvalidationNone;
-
// If the size is zero on one of our bounds then we know we're going to have
// to do a full invalidation of either old bounds or new bounds. If we fall
// into the incremental invalidation we'll issue two invalidations instead
@@ -3458,7 +3430,6 @@ void LayoutObject::clearPaintInvalidationFlags(const PaintInvalidationState& pai
ASSERT(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || paintInvalidationStateIsDirty());
clearShouldDoFullPaintInvalidation();
m_bitfields.setChildShouldCheckForPaintInvalidation(false);
- m_bitfields.setNeededLayoutBecauseOfChildren(false);
m_bitfields.setMayNeedPaintInvalidation(false);
m_bitfields.setMayNeedPaintInvalidationSubtree(false);
m_bitfields.setShouldInvalidateSelection(false);
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index 7a88a692403159..96447e76aa17aa 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -354,12 +354,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
#endif
- // Correct version of !layoutObjectHasNoBoxEffectObsolete().
- bool hasBoxEffect() const
- {
- return hasBoxDecorationBackground() || style()->hasVisualOverflowingEffect();
- }
-
// LayoutObject tree manipulation
//////////////////////////////////////////
virtual bool canHaveChildren() const { return virtualChildren(); }
@@ -444,8 +438,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
// or from Parent element.
PassRefPtr getUncachedPseudoStyleFromParentOrShadowHost() const;
- bool skipInvalidationWhenLaidOutChildren() const;
-
public:
#ifndef NDEBUG
void showTreeForThis() const;
@@ -694,8 +686,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
bool boxDecorationBackgroundIsKnownToBeObscured() const;
bool hasBackground() const { return style()->hasBackground(); }
- bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNeedsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayout(); }
-
bool needsLayout() const
{
return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
@@ -1131,6 +1121,12 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
void invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer);
void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
+ // Returns true if the object will not generate any effective painted output.
+ // It's used to skip unforced paint invalidation (which is when shouldDoFullPaintInvalidation
+ // is false, but mayNeedPaintInvalidation or childShouldCheckForPaintInvalidation is true) to
+ // avoid unnecessary paint invalidations of empty areas covered by such objects.
+ virtual bool paintedOutputOfObjectHasNoEffect() const { return false; }
+
// Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
// coordinate space. This method deals with outlines and overflow.
virtual LayoutRect absoluteClippedOverflowRect() const;
@@ -1555,7 +1551,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
#if ENABLE(ASSERT)
virtual bool paintInvalidationStateIsDirty() const
{
- return m_bitfields.neededLayoutBecauseOfChildren() || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState();
+ return shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState();
}
#endif
@@ -1748,7 +1744,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
, m_mayNeedPaintInvalidation(false)
, m_mayNeedPaintInvalidationSubtree(false)
, m_shouldInvalidateSelection(false)
- , m_neededLayoutBecauseOfChildren(false)
, m_floating(false)
, m_isAnonymous(!node)
, m_isText(false)
@@ -1782,7 +1777,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
{
}
- // 32 bits have been used in the first word, and 17 in the second.
+ // 32 bits have been used in the first word, and 16 in the second.
// Self needs layout means that this layout object is marked for a full layout.
// This is the default layout but it is expensive as it recomputes everything.
@@ -1833,8 +1828,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, public DisplayIte
ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCheckForPaintInvalidation);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidationSubtree, MayNeedPaintInvalidationSubtree);
- ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelection); // TODO(wangxianzhu): Remove for slimming paint v2.
- ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseOfChildren); // TODO(wangxianzhu): Remove for slimming paint v2.
+ ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelection);
// This boolean is the cached value of 'float'
// (see ComputedStyle::isFloating).
@@ -2051,7 +2045,6 @@ inline void LayoutObject::clearNeedsLayout()
// Set flags for later stages/cycles.
setEverHadLayout();
setMayNeedPaintInvalidation();
- m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren());
// Clear needsLayout flags.
setSelfNeedsLayout(false);
diff --git a/third_party/WebKit/Source/core/layout/LayoutReplaced.h b/third_party/WebKit/Source/core/layout/LayoutReplaced.h
index 492bf53c724189..190d429857d56f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutReplaced.h
+++ b/third_party/WebKit/Source/core/layout/LayoutReplaced.h
@@ -72,6 +72,9 @@ class CORE_EXPORT LayoutReplaced : public LayoutBox {
void paint(const PaintInfo&, const LayoutPoint&) const override;
+ // Replaced objects often have contents to paint.
+ bool paintedOutputOfObjectHasNoEffect() const final { return false; }
+
struct IntrinsicSizingInfo {
STACK_ALLOCATED();
IntrinsicSizingInfo() : hasWidth(true), hasHeight(true) {}
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp
index a1f5a977f9e3d3..ae252caf1836b7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutView.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutView.cpp
@@ -571,13 +571,6 @@ void LayoutView::invalidatePaintForSelection()
continue;
o->setShouldInvalidateSelection();
-
- // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well.
- for (LayoutBlock* block = o->containingBlock(); block && !block->isLayoutView(); block = block->containingBlock()) {
- if (!processedBlocks.add(block).isNewEntry)
- break;
- block->setShouldInvalidateSelection();
- }
}
}
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.cpp
index d7bf42b25575be..03facf1c306af0 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.cpp
@@ -44,16 +44,6 @@ void LayoutSVGHiddenContainer::layout()
clearNeedsLayout();
}
-void LayoutSVGHiddenContainer::paint(const PaintInfo&, const LayoutPoint&) const
-{
- // This subtree does not paint.
-}
-
-void LayoutSVGHiddenContainer::absoluteQuads(Vector&) const
-{
- // This subtree does not take up space or paint
-}
-
bool LayoutSVGHiddenContainer::nodeAtFloatPoint(HitTestResult&, const FloatPoint&, HitTestAction)
{
return false;
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.h
index 629f7b4f2196f3..542087ebd76d1a 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.h
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGHiddenContainer.h
@@ -40,10 +40,12 @@ class LayoutSVGHiddenContainer : public LayoutSVGContainer {
bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGHiddenContainer || LayoutSVGContainer::isOfType(type); }
private:
- void paint(const PaintInfo&, const LayoutPoint&) const final;
+ // LayoutSVGHiddenContainer paints nothing.
+ void paint(const PaintInfo&, const LayoutPoint&) const final { }
+ bool paintedOutputOfObjectHasNoEffect() const final { return true; }
LayoutRect absoluteClippedOverflowRect() const final { return LayoutRect(); }
FloatRect paintInvalidationRectInLocalSVGCoordinates() const final { return FloatRect(); }
- void absoluteQuads(Vector&) const final;
+ void absoluteQuads(Vector&) const final { }
bool nodeAtFloatPoint(HitTestResult&, const FloatPoint& pointInParent, HitTestAction) final;
};