Chromium Code Reviews| 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 f9c613c511a1d71c54ad4f14d7160c8104822cc8..17275bf3002fac86401fcb5da8551bf695aa630e 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -624,6 +624,15 @@ PaintLayer* LayoutObject::enclosingLayer() const |
| return nullptr; |
| } |
| +PaintLayer* LayoutObject::paintingLayer() const |
| +{ |
| + for (const LayoutObject* current = this; current; current = current->isColumnSpanAll() ? current->spannerPlaceholder() : current->parent()) { |
|
mstensho (USE GERRIT)
2016/05/09 08:20:42
To make it look slightly less special, we could ju
Xianzhu
2016/05/09 17:14:20
Done.
|
| + if (current->hasLayer()) |
| + return toLayoutBoxModelObject(current)->layer()->enclosingSelfPaintingLayer(); |
| + } |
| + return nullptr; |
| +} |
| + |
| bool LayoutObject::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType scrollType, bool makeVisibleInVisualViewport) |
| { |
| LayoutBox* enclosingBox = this->enclosingBox(); |
| @@ -1103,8 +1112,10 @@ const LayoutBoxModelObject* LayoutObject::enclosingCompositedContainer() const |
| // FIXME: CompositingState is not necessarily up to date for many callers of this function. |
| DisableCompositingQueryAsserts disabler; |
| - if (PaintLayer* compositingLayer = enclosingLayer()->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) |
| - container = compositingLayer->layoutObject(); |
| + if (PaintLayer* paintingLayer = this->paintingLayer()) { |
| + if (PaintLayer* compositingLayer = paintingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) |
| + container = compositingLayer->layoutObject(); |
| + } |
| return container; |
| } |
| @@ -1233,30 +1244,26 @@ void LayoutObject::invalidatePaintUsingContainer(const LayoutBoxModelObject& pai |
| void LayoutObject::invalidateDisplayItemClient(const DisplayItemClient& displayItemClient) const |
| { |
| - if (PaintLayer* enclosingLayer = this->enclosingLayer()) { |
| + 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 = enclosingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) |
| + if (const PaintLayer* paintInvalidationLayer = paintingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries()) |
| paintInvalidationLayer->layoutObject()->invalidateDisplayItemClientOnBacking(displayItemClient, PaintInvalidationFull); |
| - enclosingLayer->setNeedsRepaint(); |
| + paintingLayer->setNeedsRepaint(); |
| } |
| } |
| +void LayoutObject::setPaintingLayerNeedsRepaint() const |
| +{ |
| + if (PaintLayer* paintingLayer = this->paintingLayer()) |
| + paintingLayer->setNeedsRepaint(); |
| +} |
| + |
| #if ENABLE(ASSERT) |
| -static void assertEnclosingSelfPaintingLayerHasSetNeedsRepaint(const LayoutObject& layoutObject) |
| +void LayoutObject::assertPaintingLayerHasSetNeedsRepaint() const |
| { |
| - PaintLayer* enclosingSelfPaintingLayer = nullptr; |
| - const LayoutObject* curr = &layoutObject; |
| - while (curr) { |
| - if (curr->hasLayer() && toLayoutBoxModelObject(curr)->hasSelfPaintingLayer()) { |
| - enclosingSelfPaintingLayer = toLayoutBoxModelObject(curr)->layer(); |
| - break; |
| - } |
| - // Multi-column spanner is painted by the layer of the multi-column container instead of |
| - // its enclosing layer (the layer of the multi-column flow thread). |
| - curr = curr->isColumnSpanAll() ? curr->containingBlock() : curr->parent(); |
| - } |
| - ASSERT(!enclosingSelfPaintingLayer || enclosingSelfPaintingLayer->needsRepaint()); |
| + PaintLayer* paintingLayer = this->paintingLayer(); |
| + ASSERT(!paintingLayer || paintingLayer->needsRepaint()); |
| } |
| #endif |
| @@ -1266,14 +1273,14 @@ void LayoutObject::invalidateDisplayItemClients(const LayoutBoxModelObject& pain |
| // 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. |
| #if ENABLE(ASSERT) |
| - assertEnclosingSelfPaintingLayerHasSetNeedsRepaint(*this); |
| + assertPaintingLayerHasSetNeedsRepaint(); |
|
mstensho (USE GERRIT)
2016/05/09 08:20:42
Might consider just doing ASSERT(!paintingLayer()
Xianzhu
2016/05/09 17:14:20
Acknowledged. Done.
|
| #endif |
| paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, invalidationReason); |
| } |
| void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const |
| { |
| - paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsRepaint(); |
| + paintInvalidationState.paintingLayer().setNeedsRepaint(); |
| invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason); |
| } |
| @@ -1296,8 +1303,7 @@ const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const |
| void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const |
| { |
| - if (PaintLayer* enclosingLayer = this->enclosingLayer()) |
| - enclosingLayer->setNeedsRepaint(); |
| + setPaintingLayerNeedsRepaint(); |
| const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRectangleInternal(rect); |
| if (paintInvalidationContainer) |
| invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidationRectangle); |
| @@ -1330,8 +1336,13 @@ void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv |
| void LayoutObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState) |
| { |
| - for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibling()) |
| + for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibling()) { |
| + // Column spanners are invalidated through their placeholders. |
| + // See LayoutMultiColumnSpannerPlaceholder::invalidatePaintOfSubtreesIfNeeded(). |
| + if (child->isColumnSpanAll()) |
| + continue; |
| child->invalidateTreeIfNeeded(childPaintInvalidationState); |
| + } |
| } |
| static PassOwnPtr<TracedValue> jsonObjectForOldAndNewRects(const LayoutRect& oldRect, const LayoutPoint& oldLocation, const LayoutRect& newRect, const LayoutPoint& newLocation) |
| @@ -1410,7 +1421,7 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid |
| ASSERT(&paintInvalidationState.currentObject() == this); |
| if (styleRef().hasOutline()) { |
| - PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*this); |
| + PaintLayer& layer = paintInvalidationState.paintingLayer(); |
| if (layer.layoutObject() != this) |
| layer.setNeedsPaintPhaseDescendantOutlines(); |
| } |
| @@ -3561,14 +3572,9 @@ void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendant |
| // This is valid because we want to invalidate the client in the display item list of the current backing. |
| DisableCompositingQueryAsserts disabler; |
| if (!paintInvalidationContainer) { |
| - // Not using enclosingCompositedContainer() directly because this object may be in an orphaned subtree. |
| - PaintLayer* enclosingLayer = this->enclosingLayer(); |
| - if (!enclosingLayer) |
| - return; |
| - const PaintLayer* paintInvalidationLayer = enclosingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries(); |
| - if (!paintInvalidationLayer) |
| + paintInvalidationContainer = enclosingCompositedContainer(); |
| + if (!paintInvalidationContainer) |
| return; |
| - paintInvalidationContainer = paintInvalidationLayer->layoutObject(); |
| } |
| traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [&paintInvalidationContainer, paintInvalidationReason](LayoutObject& object) { |
| @@ -3584,7 +3590,7 @@ void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBo |
| // 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. |
| #if ENABLE(ASSERT) |
| - assertEnclosingSelfPaintingLayerHasSetNeedsRepaint(*this); |
| + assertPaintingLayerHasSetNeedsRepaint(); |
| #endif |
| // These disablers are valid because we want to use the current compositing/invalidation status. |
| @@ -3637,8 +3643,7 @@ void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendantsIntern |
| void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer) |
| { |
| - if (PaintLayer* enclosingLayer = this->enclosingLayer()) |
| - enclosingLayer->setNeedsRepaint(); |
| + setPaintingLayerNeedsRepaint(); |
| invalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(paintInvalidationContainer); |
| } |