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 229fe43c32a97c2e6219e9c39137e22552472d26..fae9536ffe05741f0be678b32e314de5fbcf39f6 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() |
+{ |
+ 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(); |
@@ -739,6 +774,11 @@ GraphicsLayer* PaintLayerCompositor::containerLayer() const |
return m_containerLayer.get(); |
} |
+GraphicsLayer* PaintLayerCompositor::rootContentLayer() const |
+{ |
+ return m_rootContentLayer.get(); |
+} |
+ |
void PaintLayerCompositor::setIsInWindow(bool isInWindow) |
{ |
if (!staleInCompositingMode()) |
@@ -1024,28 +1064,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()) |