| 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 1a84b2d5a8b0059f7a2addd3513d932459a2d982..ddb466c545a8755cddafc38a42366d04cdba2cd8 100644
|
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
|
| @@ -3298,11 +3298,14 @@
|
|
|
| namespace {
|
|
|
| -// TODO(trchen): Use std::function<void, LayoutObject&> when available.
|
| -template <typename LayoutObjectTraversalFunctor>
|
| +// TODO(trchen): Use std::function<void, LayoutObject&> and lambda when available.
|
| +class LayoutObjectTraversalFunctor {
|
| +public:
|
| + virtual void operator()(LayoutObject&) const = 0;
|
| +};
|
| +
|
| void traverseNonCompositingDescendants(LayoutObject&, const LayoutObjectTraversalFunctor&);
|
|
|
| -template <typename LayoutObjectTraversalFunctor>
|
| void findNonCompositedDescendantLayerToTraverse(LayoutObject& object, const LayoutObjectTraversalFunctor& functor)
|
| {
|
| LayoutObject* descendant = object.nextInPreOrder(&object);
|
| @@ -3333,7 +3336,6 @@
|
| }
|
| }
|
|
|
| -template <typename LayoutObjectTraversalFunctor>
|
| void traverseNonCompositingDescendants(LayoutObject& object, const LayoutObjectTraversalFunctor& functor)
|
| {
|
| functor(object);
|
| @@ -3358,24 +3360,37 @@
|
|
|
| } // unnamed namespace
|
|
|
| -void LayoutObject::invalidateDisplayItemClientsIncludingNonCompositingDescendants(const LayoutBoxModelObject* paintInvalidationContainer, PaintInvalidationReason paintInvalidationReason, const LayoutRect* paintInvalidationRect) const
|
| -{
|
| +void LayoutObject::invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutObject& object) const
|
| +{
|
| + // Not using enclosingCompositedContainer() directly because this object may be in an orphaned subtree.
|
| + PaintLayer* enclosingLayer = this->enclosingLayer();
|
| + if (!enclosingLayer)
|
| + return;
|
| +
|
| + // TODO(wangxianzhu): This is a workaround for invalidation of detached custom scrollbar parts which can't find
|
| + // their own enclosing layers. May remove this when fixing crbug.com/547119 for scrollbars.
|
| + enclosingLayer->setNeedsRepaint();
|
| +
|
| // 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)
|
| - return;
|
| - paintInvalidationContainer = paintInvalidationLayer->layoutObject();
|
| - }
|
| -
|
| - traverseNonCompositingDescendants(const_cast<LayoutObject&>(*this), [&paintInvalidationContainer, paintInvalidationReason, paintInvalidationRect](LayoutObject& object) {
|
| - object.invalidateDisplayItemClients(*paintInvalidationContainer, paintInvalidationReason, paintInvalidationRect);
|
| - });
|
| + const PaintLayer* paintInvalidationLayer = enclosingLayer->enclosingLayerForPaintInvalidationCrossingFrameBoundaries();
|
| + if (!paintInvalidationLayer)
|
| + return;
|
| +
|
| + class Functor : public LayoutObjectTraversalFunctor {
|
| + public:
|
| + explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { }
|
| + void operator()(LayoutObject& object) const override
|
| + {
|
| + // TODO(wangxianzhu): Ensure correct bounds for the client will be or has been passed to PaintController. crbug.com/547119.
|
| + object.invalidateDisplayItemClients(m_paintInvalidationContainer, PaintInvalidationFull, nullptr);
|
| + }
|
| + private:
|
| + const LayoutBoxModelObject& m_paintInvalidationContainer;
|
| + };
|
| +
|
| + const LayoutBoxModelObject& paintInvalidationContainer = *paintInvalidationLayer->layoutObject();
|
| + traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor(paintInvalidationContainer));
|
| }
|
|
|
| void LayoutObject::invalidatePaintOfPreviousPaintInvalidationRect(const LayoutBoxModelObject& paintInvalidationContainer, PaintInvalidationReason reason)
|
| @@ -3401,21 +3416,36 @@
|
|
|
| void LayoutObject::invalidatePaintIncludingNonCompositingDescendants()
|
| {
|
| + class Functor : public LayoutObjectTraversalFunctor {
|
| + public:
|
| + explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer) : m_paintInvalidationContainer(paintInvalidationContainer) { }
|
| + void operator()(LayoutObject& object) const override
|
| + {
|
| + object.invalidatePaintOfPreviousPaintInvalidationRect(m_paintInvalidationContainer, PaintInvalidationLayer);
|
| + }
|
| + private:
|
| + const LayoutBoxModelObject& m_paintInvalidationContainer;
|
| + };
|
| +
|
| // Since we're only painting non-composited layers, we know that they all share the same paintInvalidationContainer.
|
| const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintInvalidationOnRootedTree();
|
| - traverseNonCompositingDescendants(*this, [&paintInvalidationContainer](LayoutObject& object) {
|
| - object.invalidatePaintOfPreviousPaintInvalidationRect(paintInvalidationContainer, PaintInvalidationLayer);
|
| - });
|
| + traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer));
|
| }
|
|
|
| // FIXME: If we had a flag to force invalidations in a whole subtree, we could get rid of this function (crbug.com/410097).
|
| void LayoutObject::setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants()
|
| {
|
| + class Functor : public LayoutObjectTraversalFunctor {
|
| + public:
|
| + void operator()(LayoutObject& object) const override
|
| + {
|
| + object.setShouldDoFullPaintInvalidation();
|
| + }
|
| + };
|
| +
|
| // Need to access the current compositing status.
|
| DisableCompositingQueryAsserts disabler;
|
| - traverseNonCompositingDescendants(*this, [](LayoutObject& object) {
|
| - object.setShouldDoFullPaintInvalidation();
|
| - });
|
| + traverseNonCompositingDescendants(*this, Functor());
|
| }
|
|
|
| void LayoutObject::invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBoxModelObject& paintInvalidationContainer)
|
|
|