Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| index 63956fde1c12d32cd755584d38f2a55bc3fadd64..8b9914626f65fd36b44d47d3c578db36150ff0e3 100644 |
| --- a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| +++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| @@ -52,6 +52,7 @@ |
| #include "core/page/ChromeClient.h" |
| #include "core/page/Page.h" |
| #include "core/page/scrolling/ScrollingCoordinator.h" |
| +#include "core/page/scrolling/TopDocumentRootScrollerController.h" |
| #include "core/paint/FramePainter.h" |
| #include "core/paint/ObjectPaintInvalidator.h" |
| #include "core/paint/TransformRecorder.h" |
| @@ -252,6 +253,7 @@ void PaintLayerCompositor::updateIfNeededRecursiveInternal() |
| scrollableArea->updateCompositorScrollAnimations(); |
| } |
| + m_layoutView.document().rootScrollerController()->didUpdateCompositing(); |
| #if ENABLE(ASSERT) |
| ASSERT(lifecycle().state() == DocumentLifecycle::CompositingClean); |
| assertNoUnresolvedDirtyBits(); |
| @@ -419,6 +421,8 @@ void PaintLayerCompositor::updateIfNeeded() |
| } |
| } |
| + updateClippingOnCompositorLayers(); |
| + |
| GraphicsLayerUpdater updater; |
| updater.update(*updateRoot, layersNeedingPaintInvalidation); |
| @@ -461,6 +465,37 @@ void PaintLayerCompositor::updateIfNeeded() |
| InspectorInstrumentation::layerTreeDidChange(m_layoutView.frame()); |
| } |
| +void PaintLayerCompositor::updateClippingOnCompositorLayers() |
|
chrishtr
2016/09/09 18:21:16
Ditto for unittesting of this method.
bokan
2016/09/10 00:05:54
I couldn't find unit tests for PaintLayer or Paint
|
| +{ |
| + bool shouldClip = !rootLayer()->hasRootScrollerAsDescendant(); |
| + if (m_rootContentLayer) { |
| + // FIXME: with rootLayerScrolls, we probably don't even need |
| + // m_rootContentLayer? |
| + m_rootContentLayer->setMasksToBounds( |
| + !RuntimeEnabledFeatures::rootLayerScrollingEnabled() && shouldClip); |
| + } |
| + |
| + // TODO(bokan): Temporary hack-cast to TDRSC until the follow-up patch |
| + // lands and we can get a pointer to a TopDocumentRootScrollerController |
| + // legitimately. |
| + TopDocumentRootScrollerController* globalRootScrollerController = |
| + (TopDocumentRootScrollerController*)m_layoutView.document().topDocument().rootScrollerController(); |
| + |
| + Element* documentElement = m_layoutView.document().documentElement(); |
| + bool frameIsRootScroller = documentElement && documentElement->isSameNode( |
| + globalRootScrollerController->globalRootScroller()); |
| + |
| + // We normally clip iframes' (but not the root frame) overflow controls |
| + // host and container layers but if the root scroller is the iframe itself |
| + // we want it to behave like the root frame. |
| + shouldClip &= !frameIsRootScroller && !m_layoutView.frame()->isLocalRoot(); |
| + |
| + if (m_containerLayer) |
| + m_containerLayer->setMasksToBounds(shouldClip); |
| + if (m_overflowControlsHostLayer) |
| + m_overflowControlsHostLayer->setMasksToBounds(shouldClip); |
| +} |
| + |
| static void restartAnimationOnCompositor(const LayoutObject& layoutObject) |
| { |
| Node* node = layoutObject.node(); |
| @@ -1024,28 +1059,17 @@ void PaintLayerCompositor::ensureRootLayer() |
| m_rootContentLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.maxY())); |
| m_rootContentLayer->setPosition(FloatPoint()); |
| m_rootContentLayer->setOwnerNodeId(DOMNodeIds::idForNode(m_layoutView.node())); |
| - |
| - // FIXME: with rootLayerScrolls, we probably don't even need m_rootContentLayer? |
| - if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| - // Need to clip to prevent transformed content showing outside this frame |
| - m_rootContentLayer->setMasksToBounds(true); |
| - } |
| } |
| if (!m_overflowControlsHostLayer) { |
| ASSERT(!m_scrollLayer); |
| ASSERT(!m_containerLayer); |
| - // Create a layer to host the clipping layer and the overflow controls layers. |
| + // Create a layer to host the clipping layer and the overflow controls |
| + // layers. Whether these layers mask the content below is determined |
| + // in updateClippingOnCompositorLayers. |
| m_overflowControlsHostLayer = GraphicsLayer::create(this); |
| - |
| - // Clip iframe's overflow controls layer. |
| - bool containerMasksToBounds = !m_layoutView.frame()->isLocalRoot(); |
| - m_overflowControlsHostLayer->setMasksToBounds(containerMasksToBounds); |
| - |
| - // Create a clipping layer if this is an iframe or settings require to clip. |
| m_containerLayer = GraphicsLayer::create(this); |
| - m_containerLayer->setMasksToBounds(containerMasksToBounds); |
| m_scrollLayer = GraphicsLayer::create(this); |
| if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) |