Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2060053002: Set paintingLayerNeedsRepaint() in layout tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set paintingLayerNeedsRepaint() in layout tree Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 7204d62640705d2b2e67fd960b83aebcbf2bb4e2..ee672c1f69960fff90313cf3dfe929ec5d649eea 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -1230,19 +1230,21 @@ void LayoutObject::invalidatePaintUsingContainer(const LayoutBoxModelObject& pai
paintInvalidationContainer.setBackingNeedsPaintInvalidationInRect(dirtyRect, invalidationReason, *this);
}
-void LayoutObject::invalidateDisplayItemClient(const DisplayItemClient& displayItemClient) const
+void LayoutObject::invalidateDisplayItemClient(const DisplayItemClient& displayItemClient)
{
- if (PaintLayer* paintingLayer = this->paintingLayer()) {
- paintingLayer->setNeedsRepaint();
+ setPaintingLayerNeedsRepaint();
-#if !ENABLE(ASSERT)
- // This is a fast path when we don't need to inform the GraphicsLayer about this paint invalidation.
- FrameView* frameView = this->frameView();
- if (!frameView || !frameView->isTrackingPaintInvalidations()) {
- displayItemClient.setDisplayItemsUncached();
- return;
- }
+ // TODO(wangxianzhu): Let FrameView instead of the paint invalidation container track object paint invalidations.
+#if !DCHECK_IS_ON()
+ // This is a fast path when we don't need to inform the GraphicsLayer about this paint invalidation.
+ FrameView* frameView = this->frameView();
+ if (!frameView || !frameView->isTrackingPaintInvalidations()) {
+ displayItemClient.setDisplayItemsUncached();
+ return;
+ }
#endif
+
+ if (PaintLayer* paintingLayer = this->paintingLayer()) {
// This is valid because we want to invalidate the client in the display item list of the current backing.
DisableCompositingQueryAsserts disabler;
if (const PaintLayer* paintInvalidationLayer = paintingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries())
@@ -1250,42 +1252,32 @@ void LayoutObject::invalidateDisplayItemClient(const DisplayItemClient& displayI
}
}
-void LayoutObject::setPaintingLayerNeedsRepaint() const
+void LayoutObject::setPaintingLayerNeedsRepaint()
{
- if (PaintLayer* paintingLayer = this->paintingLayer())
- paintingLayer->setNeedsRepaint();
+ m_bitfields.setPaintingLayerNeedsRepaint(true);
+ markAncestorsForPaintInvalidation();
}
-void LayoutObject::invalidateDisplayItemClients(const LayoutBoxModelObject& paintInvalidationContainer, PaintInvalidationReason invalidationReason) const
+void LayoutObject::invalidateDisplayItemClients(const LayoutBoxModelObject& paintInvalidationContainer, PaintInvalidationReason invalidationReason)
{
- // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needsRepaint is set.
- // Don't set the flag here because getting enclosingSelfPaintLayer has cost and the caller can use
- // various ways (e.g. PaintInvalidatinState::enclosingSelfPaintingLayer()) to reduce the cost.
- ASSERT(!paintingLayer() || paintingLayer()->needsRepaint());
+ setPaintingLayerNeedsRepaint();
paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, invalidationReason, this);
}
-void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const
-{
- paintInvalidationState.paintingLayer().setNeedsRepaint();
- invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason);
-}
-
-
bool LayoutObject::compositedScrollsWithRespectTo(const LayoutBoxModelObject& paintInvalidationContainer) const
{
return paintInvalidationContainer.usesCompositedScrolling() && this != &paintInvalidationContainer;
}
-const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const LayoutRect& dirtyRect) const
+void LayoutObject::invalidatePaintRectangle(const LayoutRect& dirtyRect)
{
RELEASE_ASSERT(isRooted());
if (dirtyRect.isEmpty())
- return nullptr;
+ return;
if (view()->document().printing())
- return nullptr; // Don't invalidate paints if we're printing.
+ return; // Don't invalidate paints if we're printing.
const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintInvalidation();
LayoutRect dirtyRectOnBacking = dirtyRect;
@@ -1298,20 +1290,7 @@ const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const
}
invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking, PaintInvalidationRectangle);
- return &paintInvalidationContainer;
-}
-
-void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const
-{
- setPaintingLayerNeedsRepaint();
- const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRectangleInternal(rect);
- if (paintInvalidationContainer)
- invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidationRectangle);
-}
-
-void LayoutObject::invalidatePaintRectangleNotInvalidatingDisplayItemClients(const LayoutRect& r) const
-{
- invalidatePaintRectangleInternal(r);
+ invalidateDisplayItemClients(paintInvalidationContainer, PaintInvalidationRectangle);
}
void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState)
@@ -1329,10 +1308,9 @@ void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv
newPaintInvalidationState.setForceSubtreeInvalidationCheckingWithinContainer();
PaintInvalidationReason reason = invalidatePaintIfNeeded(newPaintInvalidationState);
- clearPaintInvalidationFlags(newPaintInvalidationState);
-
newPaintInvalidationState.updateForChildren(reason);
invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState);
+ clearPaintInvalidationFlags(newPaintInvalidationState);
}
void LayoutObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState)
@@ -1414,7 +1392,7 @@ inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject
if (!fullInvalidation)
fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
if (shouldInvalidateSelection())
- invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationContainer, paintInvalidationState, PaintInvalidationSelection);
+ invalidateDisplayItemClients(paintInvalidationContainer, PaintInvalidationSelection);
}
PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState)
@@ -1478,7 +1456,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(paintInvalidationContainer, paintInvalidationState, invalidationReason);
+ invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason);
return invalidationReason;
}
@@ -1488,7 +1466,7 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid
else
fullyInvalidatePaint(paintInvalidationContainer, invalidationReason, oldBounds, newBounds);
- invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationContainer, paintInvalidationState, invalidationReason);
+ invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason);
return invalidationReason;
}
@@ -3480,9 +3458,12 @@ void LayoutObject::setMayNeedPaintInvalidationSubtree()
void LayoutObject::clearPaintInvalidationFlags(const PaintInvalidationState& paintInvalidationState)
{
- // paintInvalidationStateIsDirty should be kept in sync with the
+ // paintInvalidationFlagsAreDirty should be kept in sync with the
// booleans that are cleared below.
- ASSERT(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || paintInvalidationStateIsDirty());
+#if DCHECK_IS_ON()
+ DCHECK(!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() || paintInvalidationFlagsAreDirty());
+#endif
+
clearShouldDoFullPaintInvalidation();
m_bitfields.setChildShouldCheckForPaintInvalidation(false);
m_bitfields.setNeededLayoutBecauseOfChildren(false);
@@ -3490,6 +3471,15 @@ void LayoutObject::clearPaintInvalidationFlags(const PaintInvalidationState& pai
m_bitfields.setMayNeedPaintInvalidation(false);
m_bitfields.setMayNeedPaintInvalidationSubtree(false);
m_bitfields.setShouldInvalidateSelection(false);
+
+ if (m_bitfields.paintingLayerNeedsRepaint()) {
+ paintInvalidationState.paintingLayer().setNeedsRepaint();
+ m_bitfields.setPaintingLayerNeedsRepaint(false);
+ }
+
+#if DCHECK_IS_ON()
+ DCHECK(!paintInvalidationFlagsAreDirty());
+#endif
}
bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document)
@@ -3575,7 +3565,7 @@ void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectT
} // unnamed namespace
-void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendants(const LayoutBoxModelObject* paintInvalidationContainer, PaintInvalidationReason paintInvalidationReason) const
+void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendants(const LayoutBoxModelObject* paintInvalidationContainer, PaintInvalidationReason paintInvalidationReason)
{
// This is valid because we want to invalidate the client in the display item list of the current backing.
DisableCompositingQueryAsserts disabler;
@@ -3586,19 +3576,12 @@ void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant
}
traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [&paintInvalidationContainer, paintInvalidationReason](LayoutObject& object) {
- if (object.hasLayer())
- toLayoutBoxModelObject(object).layer()->setNeedsRepaint();
object.invalidateDisplayItemClients(*paintInvalidationContainer, paintInvalidationReason);
});
}
void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBoxModelObject& paintInvalidationContainer, PaintInvalidationReason reason)
{
- // It's caller's responsibility to ensure enclosingSelfPaintingLayer's needsRepaint is set.
- // Don't set the flag here because getting enclosingSelfPaintLayer has cost and the caller can use
- // various ways (e.g. PaintInvalidatinState::enclosingSelfPaintingLayer()) to reduce the cost.
- ASSERT(!paintingLayer() || paintingLayer()->needsRepaint());
-
// These disablers are valid because we want to use the current compositing/invalidation status.
DisablePaintInvalidationStateAsserts invalidationDisabler;
DisableCompositingQueryAsserts compositingDisabler;
@@ -3619,8 +3602,6 @@ void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
// Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer.
const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintInvalidation();
traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](LayoutObject& object) {
- if (object.hasLayer())
- toLayoutBoxModelObject(object).layer()->setNeedsRepaint();
object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationContainer, PaintInvalidationSubtree);
});
}
@@ -3632,23 +3613,15 @@ void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescen
setShouldDoFullPaintInvalidation(PaintInvalidationSubtree);
}
-void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(const LayoutBoxModelObject& paintInvalidationContainer)
+void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer)
{
invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationContainer, PaintInvalidationSubtree);
for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibling()) {
- if (child->hasLayer())
- toLayoutBoxModelObject(child)->layer()->setNeedsRepaint();
if (!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSelfPaintingLayer())
- child->invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(paintInvalidationContainer);
+ child->invalidatePaintIncludingNonSelfPaintingLayerDescendants(paintInvalidationContainer);
}
}
-void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer)
-{
- setPaintingLayerNeedsRepaint();
- invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(paintInvalidationContainer);
-}
-
void LayoutObject::setIsBackgroundAttachmentFixedObject(bool isBackgroundAttachmentFixedObject)
{
ASSERT(frameView());
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableBoxComponent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698