Index: Source/core/layout/LayoutObject.cpp |
diff --git a/Source/core/layout/LayoutObject.cpp b/Source/core/layout/LayoutObject.cpp |
index 330908c1373a39287787cecc3288ad5f4e1e4e70..b77a062f89d9d694bd70ee39b113cef197595cf0 100644 |
--- a/Source/core/layout/LayoutObject.cpp |
+++ b/Source/core/layout/LayoutObject.cpp |
@@ -673,6 +673,9 @@ LayoutFlowThread* LayoutObject::locateFlowThreadContainingBlock() const |
return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this); |
} |
+// TODO: May remove this for slimming paint v2 because if the object paints |
+// nothing, then repainting is fast and invalidation of it won't generate any |
+// rastarization invalidation. |
bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
{ |
if (!m_bitfields.neededLayoutBecauseOfChildren()) |
@@ -1044,6 +1047,11 @@ const LayoutBoxModelObject& LayoutObject::containerForPaintInvalidationOnRootedT |
const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const |
{ |
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
+ // Get the LayoutView of the top level frame. This is temporary before we remove blink compositing. |
+ return adjustCompositedContainerForSpecialAncestors(nullptr); |
+ } |
+ |
LayoutBoxModelObject* container = nullptr; |
// FIXME: CompositingState is not necessarily up to date for many callers of this function. |
DisableCompositingQueryAsserts disabler; |
@@ -1204,7 +1212,7 @@ void LayoutObject::invalidateDisplayItemClients(const LayoutBoxModelObject& pain |
void LayoutObject::setNeedsRepaint() |
{ |
ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
- ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintInvalidation); |
+ ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintForSlimmingPaintV2); |
if (!selfNeedsRepaint()) { |
m_bitfields.setSelfNeedsRepaint(true); |
@@ -1215,7 +1223,7 @@ void LayoutObject::setNeedsRepaint() |
void LayoutObject::setChildNeedsRepaint() |
{ |
ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
- ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintInvalidation); |
+ ASSERT(document().lifecycle().state() <= DocumentLifecycle::InPaintForSlimmingPaintV2); |
if (!childNeedsRepaint()) { |
m_bitfields.setChildNeedsRepaint(true); |
@@ -1443,6 +1451,37 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS |
return invalidationReason; |
} |
+PaintInvalidationReason LayoutObject::invalidatePaintIfNeededForSlimmingPaintV2(const LayoutPoint& newPaintOffset) |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ if (!selfShouldCheckForPaintInvalidation()) |
+ return PaintInvalidationNone; |
+ |
+ LayoutPoint oldPaintOffset = m_previousPaintOffset; |
+ m_previousPaintOffset = newPaintOffset; |
+ |
+ const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintInvalidationOnRootedTree(); // This is fast for slimming paint v2. |
+ PaintInvalidationReason invalidationReason = paintInvalidationReason(paintInvalidationContainer, LayoutRect(), oldPaintOffset, LayoutRect(), newPaintOffset); |
+ |
+ bool boxDecorationBackgroundObscured = boxDecorationBackgroundIsKnownToBeObscured(); |
+ if (!isFullPaintInvalidationReason(invalidationReason) && boxDecorationBackgroundObscured != m_bitfields.lastBoxDecorationBackgroundObscured()) |
+ invalidationReason = PaintInvalidationBackgroundObscurationChange; |
+ m_bitfields.setLastBoxDecorationBackgroundObscured(boxDecorationBackgroundObscured); |
+ |
+ TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), "LayoutObject::invalidatePaintIfNeededForSlimmingPaintV2()", |
+ "object", this->debugName().ascii(), |
+ // TODO: Update the function to reflect new meanings. |
+ "", jsonObjectForOldAndNewRects(LayoutRect(), oldPaintOffset, LayoutRect(), newPaintOffset)); |
+ |
+ if (invalidationReason == PaintInvalidationNone) |
+ return invalidationReason; |
+ |
+ invalidateDisplayItemClients(paintInvalidationContainer); |
+ |
+ clearSelfPaintInvalidationFlags(); |
+ return invalidationReason; |
+} |
+ |
PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutBoxModelObject& paintInvalidationContainer, |
const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalidationBacking, |
const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalidationBacking) const |
@@ -3232,6 +3271,11 @@ inline void LayoutObject::markContainerChainForPaintInvalidation() |
void LayoutObject::setShouldInvalidateSelection() |
{ |
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
+ setShouldDoFullPaintInvalidation(PaintInvalidationSelection); |
+ return; |
+ } |
+ |
if (!canUpdateSelectionOnRootLineBoxes()) |
return; |
@@ -3273,8 +3317,13 @@ void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai |
// paintInvalidationStateIsDirty should be kept in sync with the |
// booleans that are cleared below. |
ASSERT(paintInvalidationState.ancestorHadPaintInvalidationForLocationChange() || paintInvalidationStateIsDirty()); |
- clearShouldDoFullPaintInvalidation(); |
m_bitfields.setChildShouldCheckForPaintInvalidation(false); |
+ clearSelfPaintInvalidationFlags(); |
+} |
+ |
+void LayoutObject::clearSelfPaintInvalidationFlags() |
+{ |
+ clearShouldDoFullPaintInvalidation(); |
m_bitfields.setNeededLayoutBecauseOfChildren(false); |
m_bitfields.setShouldInvalidateOverflowForPaint(false); |
m_bitfields.setMayNeedPaintInvalidation(false); |