Source/WebCore:
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2019 21:47:07 +0000 (21:47 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2019 21:47:07 +0000 (21:47 +0000)
REGRESSION (246538): Newyorker.com header scrolls on page

Revert parts of r246538 so that frame scrolling is reverted to using layer positions.
Overflow scroll will still scroll by changing boundsOrigin.

The bug was caused by confusion about insetClipLayer and scrollContainerLayer; macOS
positions the clip layer using FrameView::yPositionForInsetClipLayer(), so it's not just
a simple scroll container, and this change broke positioning for fixed position layers.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::insetClipLayerForFrameView):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::~RenderLayerCompositor):
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateScrollLayerPosition):
(WebCore::RenderLayerCompositor::updateScrollLayerClipping):
(WebCore::RenderLayerCompositor::frameViewDidScroll):
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
(WebCore::RenderLayerCompositor::ensureRootLayer):
(WebCore::RenderLayerCompositor::destroyRootLayer):
(WebCore::RenderLayerCompositor::updateScrollingNodeLayers):
(WebCore::RenderLayerCompositor::updateLayersForScrollPosition): Deleted.
(WebCore::RenderLayerCompositor::updateScrollContainerGeometry): Deleted.
* rendering/RenderLayerCompositor.h:

LayoutTests:
Revert parts of r246538 so that frame scrolling is reverted to using layer positions.
Overflow scroll will still scroll by changing boundsOrigin.

The bug was caused by confusion about insetClipLayer and scrollContainerLayer; macOS
positions the clip layer using FrameView::yPositionForInsetClipLayer(), so it's not just
a simple scroll container, and this change broke positioning for fixed position layers.

* compositing/iframes/scrolling-iframe-expected.txt:
* compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
* compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
* platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt:
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
* platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
* platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
* platform/mac-sierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
* platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
* platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
* scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246612 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/iframes/scrolling-iframe-expected.txt
LayoutTests/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt
LayoutTests/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt
LayoutTests/platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt
LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt
LayoutTests/platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt
LayoutTests/platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt
LayoutTests/platform/mac-sierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt
LayoutTests/platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt
LayoutTests/platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt
LayoutTests/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h

index 4c92da5..8754acb 100644 (file)
 
         * platform/gtk/TestExpectations:
 
+2019-06-19  Simon Fraser  <simon.fraser@apple.com>
+
+        Revert parts of r246538 so that frame scrolling is reverted to using layer positions.
+        Overflow scroll will still scroll by changing boundsOrigin.
+        
+        The bug was caused by confusion about insetClipLayer and scrollContainerLayer; macOS
+        positions the clip layer using FrameView::yPositionForInsetClipLayer(), so it's not just
+        a simple scroll container, and this change broke positioning for fixed position layers.
+
+        * compositing/iframes/scrolling-iframe-expected.txt:
+        * compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
+        * compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
+        * platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt:
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
+        * platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
+        * platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
+        * platform/mac-sierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
+        * platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
+        * platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
+        * scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
+
 2019-06-19  Russell Epstein  <russell_e@apple.com>
 
         webgpu/blend-color-triangle-strip.html is a flakey failure since introduction.
index 8b849e9..f1db514 100644 (file)
               (position 43.00 43.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 80.00 80.00)
                   (anchor 0.00 0.00)
                   (bounds 285.00 135.00)
                   (children 1
                     (GraphicsLayer
+                      (position -80.00 -80.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index 5351ea7..16ffe62 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index 3a3eda3..b3af98c 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index 3f7885c..843dff8 100644 (file)
@@ -16,7 +16,6 @@
               (position 43.00 43.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 80.00 80.00)
                   (anchor 0.00 0.00)
                   (bounds 300.00 150.00)
                   (children 1
index ee46486..e66d95f 100644 (file)
@@ -63,7 +63,6 @@
               (position 12.00 12.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 120.00)
                   (anchor 0.00 0.00)
                   (bounds 480.00 400.00)
                   (children 1
index a65205f..c9dbc60 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index 64541e7..9e549b3 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index e47d6a7..6a2086b 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (children 1
                         (GraphicsLayer
                           (anchor 0.00 0.00)
index c228385..734719a 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
                             (GraphicsLayer
                               (bounds 400.00 1016.00)
                               (drawsContent 1)
-                              (repaint rects
-                                (rect 0.00 0.00 400.00 1016.00)
-                                (rect 0.00 0.00 400.00 1016.00)
-                                (rect 8.00 8.00 384.00 1000.00)
-                                (rect 0.00 0.00 400.00 1016.00)
-                              )
                               (children 1
                                 (GraphicsLayer
                                   (position 8.00 8.00)
index 9e2ca6a..30d8391 100644 (file)
               (position 16.00 16.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 100.00)
                   (anchor 0.00 0.00)
                   (bounds 400.00 300.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -100.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index dd7e086..84560df 100644 (file)
               (position 12.00 12.00)
               (children 1
                 (GraphicsLayer
-                  (bounds origin 0.00 120.00)
                   (anchor 0.00 0.00)
                   (bounds 465.00 400.00)
                   (children 1
                     (GraphicsLayer
+                      (position 0.00 -120.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index d683c16..37e2317 100644 (file)
         (WebCore::RealtimeOutgoingVideoSourceCocoa::rotatePixelBuffer):
         (WebCore::computeRotatedWidthAndHeight): Deleted.
 
+2019-06-19  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (246538): Newyorker.com header scrolls on page
+        
+        Revert parts of r246538 so that frame scrolling is reverted to using layer positions.
+        Overflow scroll will still scroll by changing boundsOrigin.
+        
+        The bug was caused by confusion about insetClipLayer and scrollContainerLayer; macOS
+        positions the clip layer using FrameView::yPositionForInsetClipLayer(), so it's not just
+        a simple scroll container, and this change broke positioning for fixed position layers.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::insetClipLayerForFrameView):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::~RenderLayerCompositor):
+        (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
+        (WebCore::RenderLayerCompositor::updateScrollLayerPosition):
+        (WebCore::RenderLayerCompositor::updateScrollLayerClipping):
+        (WebCore::RenderLayerCompositor::frameViewDidScroll):
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+        (WebCore::RenderLayerCompositor::destroyRootLayer):
+        (WebCore::RenderLayerCompositor::updateScrollingNodeLayers):
+        (WebCore::RenderLayerCompositor::updateLayersForScrollPosition): Deleted.
+        (WebCore::RenderLayerCompositor::updateScrollContainerGeometry): Deleted.
+        * rendering/RenderLayerCompositor.h:
+
 2019-06-19  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE][GTK] Fix build with unified sources disabled
index 77fc583..ef065e3 100644 (file)
@@ -446,15 +446,25 @@ void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, co
 
 void AsyncScrollingCoordinator::reconcileScrollPosition(FrameView& frameView, ScrollingLayerPositionAction scrollingLayerPositionAction)
 {
+#if PLATFORM(IOS_FAMILY)
+    // Doing all scrolling like this (UIScrollView style) would simplify code.
     auto* scrollContainerLayer = scrollContainerLayerForFrameView(frameView);
     if (!scrollContainerLayer)
         return;
-
-    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
     if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
         scrollContainerLayer->setBoundsOrigin(frameView.scrollPosition());
     else
         scrollContainerLayer->syncBoundsOrigin(frameView.scrollPosition());
+#else
+    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
+    auto* scrolledContentsLayer = scrolledContentsLayerForFrameView(frameView);
+    if (!scrolledContentsLayer)
+        return;
+    if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
+        scrolledContentsLayer->setPosition(-frameView.scrollPosition());
+    else
+        scrolledContentsLayer->syncPosition(-frameView.scrollPosition());
+#endif
 }
 
 void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea& scrollableArea, ScrollbarOrientation orientation)
index c0685e2..9290b8b 100644 (file)
@@ -272,7 +272,7 @@ GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView
 GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView& frameView)
 {
     if (auto* renderView = frameView.frame().contentRenderer())
-        return renderView->compositor().scrollContainerLayer();
+        return renderView->compositor().clipLayer();
     return nullptr;
 }
 
index cf6d06d..899a4b0 100644 (file)
@@ -200,7 +200,7 @@ void ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged()
 void ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers()
 {
     // We use scroll position here because the root content layer is offset to account for scrollOrigin (see FrameView::positionForRootContentLayer).
-    [scrollContainerLayer() _web_setLayerBoundsOrigin:currentScrollPosition()];
+    scrolledContentsLayer().position = -currentScrollPosition();
 }
 
 void ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers()
index ab0d72c..f2978da 100644 (file)
@@ -301,6 +301,7 @@ RenderLayerCompositor::~RenderLayerCompositor()
     // Take care that the owned GraphicsLayers are deleted first as their destructors may call back here.
     GraphicsLayer::unparentAndClear(m_rootContentsLayer);
     
+    GraphicsLayer::unparentAndClear(m_clipLayer);
     GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
     GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
 
@@ -1968,7 +1969,7 @@ void RenderLayerCompositor::frameViewDidChangeSize()
         layer->setNeedsCompositingGeometryUpdate();
 
     if (m_scrolledContentsLayer) {
-        updateScrollContainerGeometry();
+        updateScrollLayerClipping();
         frameViewDidScroll();
         updateOverflowControlsLayers();
 
@@ -1988,26 +1989,29 @@ bool RenderLayerCompositor::hasCoordinatedScrolling() const
     return scrollingCoordinator && scrollingCoordinator->coordinatesScrollingForFrameView(m_renderView.frameView());
 }
 
-void RenderLayerCompositor::updateLayersForScrollPosition()
+void RenderLayerCompositor::updateScrollLayerPosition()
 {
     ASSERT(!hasCoordinatedScrolling());
-    ASSERT(m_scrollContainerLayer);
+    ASSERT(m_scrolledContentsLayer);
 
     auto& frameView = m_renderView.frameView();
-    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
-    m_scrollContainerLayer->setBoundsOrigin(frameView.scrollPosition());
+    IntPoint scrollPosition = frameView.scrollPosition();
+
+    // We use scroll position here because the root content layer is offset to account for scrollOrigin (see FrameView::positionForRootContentLayer).
+    m_scrolledContentsLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
 
     if (auto* fixedBackgroundLayer = fixedRootBackgroundLayer())
         fixedBackgroundLayer->setPosition(frameView.scrollPositionForFixedPosition());
 }
 
-void RenderLayerCompositor::updateScrollContainerGeometry()
+void RenderLayerCompositor::updateScrollLayerClipping()
 {
-    if (!m_scrollContainerLayer)
+    auto* layerForClipping = this->layerForClipping();
+    if (!layerForClipping)
         return;
 
-    m_scrollContainerLayer->setSize(m_renderView.frameView().sizeForVisibleContent());
-    m_scrollContainerLayer->setPosition(positionForClipLayer());
+    layerForClipping->setSize(m_renderView.frameView().sizeForVisibleContent());
+    layerForClipping->setPosition(positionForClipLayer());
 }
 
 FloatPoint RenderLayerCompositor::positionForClipLayer() const
@@ -2032,7 +2036,7 @@ void RenderLayerCompositor::frameViewDidScroll()
         return;
     }
 
-    updateLayersForScrollPosition();
+    updateScrollLayerPosition();
 }
 
 void RenderLayerCompositor::frameViewDidAddOrRemoveScrollbars()
@@ -2249,10 +2253,10 @@ void RenderLayerCompositor::updateRootLayerPosition()
     if (m_rootContentsLayer) {
         m_rootContentsLayer->setSize(m_renderView.frameView().contentsSize());
         m_rootContentsLayer->setPosition(m_renderView.frameView().positionForRootContentLayer());
-        m_rootContentsLayer->setAnchorPoint({ });
+        m_rootContentsLayer->setAnchorPoint(FloatPoint3D());
     }
 
-    updateScrollContainerGeometry();
+    updateScrollLayerClipping();
 
 #if ENABLE(RUBBER_BANDING)
     if (m_contentShadowLayer && m_rootContentsLayer) {
@@ -3679,7 +3683,7 @@ void RenderLayerCompositor::updateOverflowControlsLayers()
 
             // We want the overhang areas layer to be positioned below the frame contents,
             // so insert it below the clip layer.
-            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, m_scrollContainerLayer.get());
+            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, layerForClipping());
         }
     } else
         GraphicsLayer::unparentAndClear(m_layerForOverhangAreas);
@@ -3769,7 +3773,7 @@ void RenderLayerCompositor::ensureRootLayer()
         m_rootContentsLayer->setName("content root");
         IntRect overflowRect = snappedIntRect(m_renderView.layoutOverflowRect());
         m_rootContentsLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.maxY()));
-        m_rootContentsLayer->setPosition({ });
+        m_rootContentsLayer->setPosition(FloatPoint());
 
 #if PLATFORM(IOS_FAMILY)
         // Page scale is applied above this on iOS, so we'll just say that our root layer applies it.
@@ -3785,35 +3789,54 @@ void RenderLayerCompositor::ensureRootLayer()
     if (requiresScrollLayer(expectedAttachment)) {
         if (!m_overflowControlsHostLayer) {
             ASSERT(!m_scrolledContentsLayer);
+            ASSERT(!m_clipLayer);
 
             // Create a layer to host the clipping layer and the overflow controls layers.
             m_overflowControlsHostLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
             m_overflowControlsHostLayer->setName("overflow controls host");
 
-            m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrollContainer);
-            m_scrollContainerLayer->setName("scroll container");
-            m_scrollContainerLayer->setMasksToBounds(true);
-            m_scrollContainerLayer->setAnchorPoint({ });
-
             m_scrolledContentsLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrolledContents);
             m_scrolledContentsLayer->setName("scrolled contents");
             m_scrolledContentsLayer->setAnchorPoint({ });
 
-            m_overflowControlsHostLayer->addChild(*m_scrollContainerLayer);
-            m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
+#if PLATFORM(IOS_FAMILY)
+            if (m_renderView.settings().asyncFrameScrollingEnabled()) {
+                m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrollContainer);
+
+                m_scrollContainerLayer->setName("scroll container");
+                m_scrollContainerLayer->setMasksToBounds(true);
+                m_scrollContainerLayer->setAnchorPoint({ });
+
+                m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
+                m_overflowControlsHostLayer->addChild(*m_scrollContainerLayer);
+            }
+#endif
+            // FIXME: m_scrollContainerLayer and m_clipLayer have similar roles here, but m_clipLayer has some special positioning to
+            // account for clipping and top content inset (see FrameView::yPositionForInsetClipLayer()).
+            if (!m_scrollContainerLayer) {
+                m_clipLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
+                m_clipLayer->setName("frame clipping");
+                m_clipLayer->setMasksToBounds(true);
+                m_clipLayer->setAnchorPoint({ });
+
+                m_clipLayer->addChild(*m_scrolledContentsLayer);
+                m_overflowControlsHostLayer->addChild(*m_clipLayer);
+            }
+
             m_scrolledContentsLayer->addChild(*m_rootContentsLayer);
 
-            updateScrollContainerGeometry();
+            updateScrollLayerClipping();
             updateOverflowControlsLayers();
 
             if (hasCoordinatedScrolling())
                 scheduleLayerFlush(true);
             else
-                updateLayersForScrollPosition();
+                updateScrollLayerPosition();
         }
     } else {
         if (m_overflowControlsHostLayer) {
             GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
+            GraphicsLayer::unparentAndClear(m_clipLayer);
             GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
             GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
         }
@@ -3860,6 +3883,7 @@ void RenderLayerCompositor::destroyRootLayer()
 
     if (m_overflowControlsHostLayer) {
         GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
+        GraphicsLayer::unparentAndClear(m_clipLayer);
         GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
         GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     }
@@ -4299,7 +4323,7 @@ void RenderLayerCompositor::updateScrollingNodeLayers(ScrollingNodeID nodeID, Re
         FrameView& frameView = m_renderView.frameView();
         scrollingCoordinator.setNodeLayers(nodeID, { nullptr,
             scrollContainerLayer(), scrolledContentsLayer(),
-            fixedRootBackgroundLayer(), nullptr, rootContentsLayer(),
+            fixedRootBackgroundLayer(), clipLayer(), rootContentsLayer(),
             frameView.layerForHorizontalScrollbar(), frameView.layerForVerticalScrollbar() });
     } else {
         auto& backing = *layer.backing();
index fe8d75c..9134779 100644 (file)
@@ -246,8 +246,11 @@ public:
 
     GraphicsLayer* scrollContainerLayer() const { return m_scrollContainerLayer.get(); }
     GraphicsLayer* scrolledContentsLayer() const { return m_scrolledContentsLayer.get(); }
+    GraphicsLayer* clipLayer() const { return m_clipLayer.get(); }
     GraphicsLayer* rootContentsLayer() const { return m_rootContentsLayer.get(); }
 
+    GraphicsLayer* layerForClipping() const {  return m_clipLayer ? m_clipLayer.get() : m_scrollContainerLayer.get();  }
+
 #if ENABLE(RUBBER_BANDING)
     GraphicsLayer* headerLayer() const { return m_layerForHeader.get(); }
     GraphicsLayer* footerLayer() const { return m_layerForFooter.get(); }
@@ -437,8 +440,8 @@ private:
 
     void updateOverflowControlsLayers();
 
-    void updateLayersForScrollPosition();
-    void updateScrollContainerGeometry();
+    void updateScrollLayerPosition();
+    void updateScrollLayerClipping();
 
     FloatPoint positionForClipLayer() const;
 
@@ -571,6 +574,7 @@ private:
     RefPtr<GraphicsLayer> m_rootContentsLayer;
 
     // Enclosing clipping layer for iframe content
+    RefPtr<GraphicsLayer> m_clipLayer;
     RefPtr<GraphicsLayer> m_scrollContainerLayer;
     RefPtr<GraphicsLayer> m_scrolledContentsLayer;