Convert macOS to scroll by changing layer boundsOrigin
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2019 15:16:33 +0000 (15:16 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jun 2019 15:16:33 +0000 (15:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198917

Reviewed by Antti Koivisto.

Source/WebCore:

macOS did frame and overflow scrolling by changing the position of the scrolled
contents layer. iOS scrolls by changing the boundsOrigin of the scrollContainer layer
(which it has to, to match how UIScrollView works).

The iOS approach removes the need for an extra layer whose only role is for
scroll positioning, so migrate macOS to the same approach. A later patch can remove
m_scrolledContentsLayer.

We can remove RenderLayerCompositor::m_clipLayer since m_scrollContainerLayer has exactly
the same role now.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::insetClipLayerForFrameView):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
* page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
(WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):
* platform/graphics/cocoa/WebCoreCALayerExtras.h:
* platform/graphics/cocoa/WebCoreCALayerExtras.mm:
(-[CALayer _web_setLayerBoundsOrigin:]):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGeometry):
(WebCore::RenderLayerBacking::setLocationOfScrolledContents):
(WebCore::RenderLayerBacking::updateScrollOffset):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::~RenderLayerCompositor):
(WebCore::RenderLayerCompositor::flushPendingLayerChanges):
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateLayersForScrollPosition):
(WebCore::RenderLayerCompositor::updateScrollContainerGeometry):
(WebCore::RenderLayerCompositor::frameViewDidScroll):
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
(WebCore::RenderLayerCompositor::ensureRootLayer):
(WebCore::RenderLayerCompositor::destroyRootLayer):
(WebCore::RenderLayerCompositor::updateScrollingNodeLayers):
(WebCore::RenderLayerCompositor::updateScrollLayerPosition): Deleted.
(WebCore::RenderLayerCompositor::updateScrollLayerClipping): Deleted.
* rendering/RenderLayerCompositor.h:

Source/WebKit:

Remove unreached and confusing code.

* UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers):

LayoutTests:

* compositing/iframes/scrolling-iframe-expected.txt:
* compositing/overflow/textarea-scroll-touch-expected.txt:
* compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
* compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
* compositing/repaint/scroller-with-foreground-layer-repaints-expected.txt:
* compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
* scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/iframes/scrolling-iframe-expected.txt
LayoutTests/compositing/overflow/textarea-scroll-touch-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/compositing/repaint/scroller-with-foreground-layer-repaints-expected.txt
LayoutTests/compositing/rtl/rtl-scrolling-with-transformed-descendants-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
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt
LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-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/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.h
Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm

index d1e54ad..a4c3b4a 100644 (file)
@@ -1,3 +1,18 @@
+2019-06-18  Simon Fraser  <simon.fraser@apple.com>
+
+        Convert macOS to scroll by changing layer boundsOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=198917
+
+        Reviewed by Antti Koivisto.
+
+        * compositing/iframes/scrolling-iframe-expected.txt:
+        * compositing/overflow/textarea-scroll-touch-expected.txt:
+        * compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
+        * compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
+        * compositing/repaint/scroller-with-foreground-layer-repaints-expected.txt:
+        * compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
+        * scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
+
 2019-06-18  Zan Dobersek  <zdobersek@igalia.com>
 
         [WebGL] Extensions3DOpenGLES::bindVertexArrayOES() should allow zero array object
index f1db514..8b849e9 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 ab91eee..30f5427 100644 (file)
             (GraphicsLayer
               (offsetFromRenderer width=1 height=1)
               (position 1.00 1.00)
+              (bounds origin 0.00 50.00)
               (bounds 189.00 124.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=1 height=1)
                   (scrollOffset (0,50))
-                  (position 0.00 -50.00)
                   (anchor 0.00 0.00)
                   (bounds 189.00 270.00)
                   (drawsContent 1)
             (GraphicsLayer
               (offsetFromRenderer width=1 height=1)
               (position 1.00 1.00)
+              (bounds origin 0.00 50.00)
               (bounds 189.00 124.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=1 height=1)
                   (scrollOffset (0,50))
-                  (position 0.00 -50.00)
                   (anchor 0.00 0.00)
                   (bounds 189.00 270.00)
                   (drawsContent 1)
index 16ffe62..5351ea7 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 b3af98c..3a3eda3 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 871c0c6..6e4c878 100644 (file)
@@ -20,12 +20,12 @@ Scrolled contents
             (GraphicsLayer
               (offsetFromRenderer width=1 height=1)
               (position 1.00 1.00)
+              (bounds origin 0.00 200.00)
               (bounds 305.00 305.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=1 height=1)
                   (scrollOffset (0,200))
-                  (position 0.00 -200.00)
                   (anchor 0.00 0.00)
                   (bounds 305.00 1020.00)
                   (drawsContent 1)
index c70ede2..78d6316 100644 (file)
             (GraphicsLayer
               (offsetFromRenderer width=2 height=2)
               (position 2.00 2.00)
+              (bounds origin 366.00 0.00)
               (bounds 400.00 204.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=2 height=2)
                   (scrollOffset (366,0))
-                  (position -366.00 0.00)
                   (anchor 0.00 0.00)
                   (bounds 766.00 204.00)
                   (drawsContent 1)
index 843dff8..3f7885c 100644 (file)
@@ -16,6 +16,7 @@
               (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 e66d95f..ee46486 100644 (file)
@@ -63,6 +63,7 @@
               (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 c9dbc60..a65205f 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 9e549b3..64541e7 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 6a2086b..e47d6a7 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 734719a..c228385 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 30d8391..9e2ca6a 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 84560df..dd7e086 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 d7f26ac..472a9fb 100644 (file)
             (GraphicsLayer
               (offsetFromRenderer width=1 height=1)
               (position 1.00 1.00)
+              (bounds origin 0.00 1800.00)
               (bounds 385.00 512.00)
-              (visible rect 0.00, 0.00 385.00 x 512.00)
-              (coverage rect 0.00, 0.00 385.00 x 512.00)
+              (visible rect 0.00, 1800.00 385.00 x 512.00)
+              (coverage rect 0.00, 1800.00 385.00 x 512.00)
               (intersects coverage rect 1)
               (contentsScale 1.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=1 height=1)
                   (scrollOffset (0,1800))
-                  (position 0.00 -1800.00)
                   (anchor 0.00 0.00)
                   (bounds 385.00 3000.00)
                   (drawsContent 1)
index 292b085..0be7f13 100644 (file)
             (GraphicsLayer
               (offsetFromRenderer width=1 height=1)
               (position 1.00 1.00)
+              (bounds origin 0.00 200.00)
               (bounds 385.00 512.00)
-              (visible rect 0.00, 0.00 385.00 x 512.00)
-              (coverage rect 0.00, 0.00 385.00 x 512.00)
+              (visible rect 0.00, 200.00 385.00 x 512.00)
+              (coverage rect 0.00, 200.00 385.00 x 512.00)
               (intersects coverage rect 1)
               (contentsScale 1.00)
               (children 1
                 (GraphicsLayer
                   (offsetFromRenderer width=1 height=1)
                   (scrollOffset (0,200))
-                  (position 0.00 -200.00)
                   (anchor 0.00 0.00)
                   (bounds 385.00 3000.00)
                   (drawsContent 1)
index e1f35d2..687a1b4 100644 (file)
@@ -1,3 +1,52 @@
+2019-06-18  Simon Fraser  <simon.fraser@apple.com>
+
+        Convert macOS to scroll by changing layer boundsOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=198917
+
+        Reviewed by Antti Koivisto.
+
+        macOS did frame and overflow scrolling by changing the position of the scrolled
+        contents layer. iOS scrolls by changing the boundsOrigin of the scrollContainer layer
+        (which it has to, to match how UIScrollView works).
+
+        The iOS approach removes the need for an extra layer whose only role is for
+        scroll positioning, so migrate macOS to the same approach. A later patch can remove
+        m_scrolledContentsLayer.
+        
+        We can remove RenderLayerCompositor::m_clipLayer since m_scrollContainerLayer has exactly
+        the same role now.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::insetClipLayerForFrameView):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
+        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):
+        * platform/graphics/cocoa/WebCoreCALayerExtras.h:
+        * platform/graphics/cocoa/WebCoreCALayerExtras.mm:
+        (-[CALayer _web_setLayerBoundsOrigin:]):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGeometry):
+        (WebCore::RenderLayerBacking::setLocationOfScrolledContents):
+        (WebCore::RenderLayerBacking::updateScrollOffset):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::~RenderLayerCompositor):
+        (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
+        (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
+        (WebCore::RenderLayerCompositor::updateLayersForScrollPosition):
+        (WebCore::RenderLayerCompositor::updateScrollContainerGeometry):
+        (WebCore::RenderLayerCompositor::frameViewDidScroll):
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+        (WebCore::RenderLayerCompositor::destroyRootLayer):
+        (WebCore::RenderLayerCompositor::updateScrollingNodeLayers):
+        (WebCore::RenderLayerCompositor::updateScrollLayerPosition): Deleted.
+        (WebCore::RenderLayerCompositor::updateScrollLayerClipping): Deleted.
+        * rendering/RenderLayerCompositor.h:
+
 2019-06-18  Philippe Normand  <pnormand@igalia.com>
 
         [GStreamer] Identify elements with monotonically increasing counters
index d5e447b..77fc583 100644 (file)
@@ -446,24 +446,15 @@ 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
-    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 9290b8b..c0685e2 100644 (file)
@@ -272,7 +272,7 @@ GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView
 GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView& frameView)
 {
     if (auto* renderView = frameView.frame().contentRenderer())
-        return renderView->compositor().clipLayer();
+        return renderView->compositor().scrollContainerLayer();
     return nullptr;
 }
 
index 1477441..cf6d06d 100644 (file)
@@ -199,7 +199,8 @@ void ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged()
 
 void ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers()
 {
-    scrolledContentsLayer().position = -currentScrollPosition();
+    // We use scroll position here because the root content layer is offset to account for scrollOrigin (see FrameView::positionForRootContentLayer).
+    [scrollContainerLayer() _web_setLayerBoundsOrigin:currentScrollPosition()];
 }
 
 void ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers()
index d15fa94..885742c 100644 (file)
@@ -31,6 +31,7 @@
 #import "Logging.h"
 #import "ScrollingStateOverflowScrollingNode.h"
 #import "ScrollingTree.h"
+#import "WebCoreCALayerExtras.h"
 #import <wtf/text/TextStream.h>
 
 namespace WebCore {
@@ -91,7 +92,7 @@ FloatPoint ScrollingTreeOverflowScrollingNodeMac::adjustedScrollPosition(const F
 void ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers()
 {
     auto scrollOffset = ScrollableArea::scrollOffsetFromPosition(currentScrollPosition(), toFloatSize(scrollOrigin()));
-    scrolledContentsLayer().position = -scrollOffset;
+    [scrollContainerLayer() _web_setLayerBoundsOrigin:scrollOffset];
 }
 
 void ScrollingTreeOverflowScrollingNodeMac::repositionRelatedLayers()
index ce684d2..f656eda 100644 (file)
@@ -28,6 +28,7 @@
 @interface CALayer (WebCoreCALayerExtras)
 
 - (void)web_disableAllActions;
+- (void)_web_setLayerBoundsOrigin:(CGPoint)origin;
 - (void)_web_setLayerTopLeftPosition:(CGPoint)position;
 + (CALayer *)_web_renderLayerWithContextID:(uint32_t)contextID;
 
index 74ec053..23bb0de 100644 (file)
     };
 }
 
+- (void)_web_setLayerBoundsOrigin:(CGPoint)origin
+{
+    CGRect bounds = [self bounds];
+    bounds.origin = origin;
+    [self setBounds:bounds];
+}
+
 - (void)_web_setLayerTopLeftPosition:(CGPoint)position
 {
     CGSize layerSize = [self bounds].size;
index c820832..499c165 100644 (file)
@@ -1225,9 +1225,6 @@ void RenderLayerBacking::updateGeometry()
 
         ScrollOffset scrollOffset = m_owningLayer.scrollOffset();
         updateScrollOffset(scrollOffset);
-#if PLATFORM(IOS_FAMILY)
-        m_scrolledContentsLayer->setPosition({ }); // FIXME: necessary?
-#endif
 
         FloatSize oldScrollingLayerOffset = m_scrollContainerLayer->offsetFromRenderer();
         m_scrollContainerLayer->setOffsetFromRenderer(toFloatSize(paddingBox.location()));
@@ -1306,17 +1303,10 @@ void RenderLayerBacking::updateGeometry()
 
 void RenderLayerBacking::setLocationOfScrolledContents(ScrollOffset scrollOffset, ScrollingLayerPositionAction setOrSync)
 {
-#if PLATFORM(IOS_FAMILY)
     if (setOrSync == ScrollingLayerPositionAction::Sync)
         m_scrollContainerLayer->syncBoundsOrigin(scrollOffset);
     else
         m_scrollContainerLayer->setBoundsOrigin(scrollOffset);
-#else
-    if (setOrSync == ScrollingLayerPositionAction::Sync)
-        m_scrolledContentsLayer->syncPosition(-scrollOffset);
-    else
-        m_scrolledContentsLayer->setPosition(-scrollOffset);
-#endif
 }
 
 void RenderLayerBacking::updateScrollOffset(ScrollOffset scrollOffset)
@@ -1330,6 +1320,8 @@ void RenderLayerBacking::updateScrollOffset(ScrollOffset scrollOffset)
         setLocationOfScrolledContents(scrollOffset, ScrollingLayerPositionAction::Set);
         m_owningLayer.setRequiresScrollPositionReconciliation(false);
     }
+
+    ASSERT(m_scrolledContentsLayer->position().isZero());
 }
 
 void RenderLayerBacking::updateAfterDescendants()
index 77e074a..ab0d72c 100644 (file)
@@ -301,7 +301,6 @@ 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);
 
@@ -521,7 +520,7 @@ void RenderLayerCompositor::flushPendingLayerChanges(bool isFlushRoot)
 #if ENABLE(TREE_DEBUGGING)
         if (layersLogEnabled()) {
             LOG(Layers, "RenderLayerCompositor::flushPendingLayerChanges");
-            showGraphicsLayerTree(m_rootContentsLayer.get());
+            showGraphicsLayerTree(m_overflowControlsHostLayer.get());
         }
 #endif
     }
@@ -1969,7 +1968,7 @@ void RenderLayerCompositor::frameViewDidChangeSize()
         layer->setNeedsCompositingGeometryUpdate();
 
     if (m_scrolledContentsLayer) {
-        updateScrollLayerClipping();
+        updateScrollContainerGeometry();
         frameViewDidScroll();
         updateOverflowControlsLayers();
 
@@ -1989,28 +1988,26 @@ bool RenderLayerCompositor::hasCoordinatedScrolling() const
     return scrollingCoordinator && scrollingCoordinator->coordinatesScrollingForFrameView(m_renderView.frameView());
 }
 
-void RenderLayerCompositor::updateScrollLayerPosition()
+void RenderLayerCompositor::updateLayersForScrollPosition()
 {
     ASSERT(!hasCoordinatedScrolling());
-    ASSERT(m_scrolledContentsLayer);
+    ASSERT(m_scrollContainerLayer);
 
     auto& frameView = m_renderView.frameView();
-    IntPoint scrollPosition = frameView.scrollPosition();
-
-    m_scrolledContentsLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
+    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
+    m_scrollContainerLayer->setBoundsOrigin(frameView.scrollPosition());
 
     if (auto* fixedBackgroundLayer = fixedRootBackgroundLayer())
         fixedBackgroundLayer->setPosition(frameView.scrollPositionForFixedPosition());
 }
 
-void RenderLayerCompositor::updateScrollLayerClipping()
+void RenderLayerCompositor::updateScrollContainerGeometry()
 {
-    auto* layerForClipping = this->layerForClipping();
-    if (!layerForClipping)
+    if (!m_scrollContainerLayer)
         return;
 
-    layerForClipping->setSize(m_renderView.frameView().sizeForVisibleContent());
-    layerForClipping->setPosition(positionForClipLayer());
+    m_scrollContainerLayer->setSize(m_renderView.frameView().sizeForVisibleContent());
+    m_scrollContainerLayer->setPosition(positionForClipLayer());
 }
 
 FloatPoint RenderLayerCompositor::positionForClipLayer() const
@@ -2035,7 +2032,7 @@ void RenderLayerCompositor::frameViewDidScroll()
         return;
     }
 
-    updateScrollLayerPosition();
+    updateLayersForScrollPosition();
 }
 
 void RenderLayerCompositor::frameViewDidAddOrRemoveScrollbars()
@@ -2252,10 +2249,10 @@ void RenderLayerCompositor::updateRootLayerPosition()
     if (m_rootContentsLayer) {
         m_rootContentsLayer->setSize(m_renderView.frameView().contentsSize());
         m_rootContentsLayer->setPosition(m_renderView.frameView().positionForRootContentLayer());
-        m_rootContentsLayer->setAnchorPoint(FloatPoint3D());
+        m_rootContentsLayer->setAnchorPoint({ });
     }
 
-    updateScrollLayerClipping();
+    updateScrollContainerGeometry();
 
 #if ENABLE(RUBBER_BANDING)
     if (m_contentShadowLayer && m_rootContentsLayer) {
@@ -3682,7 +3679,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, layerForClipping());
+            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, m_scrollContainerLayer.get());
         }
     } else
         GraphicsLayer::unparentAndClear(m_layerForOverhangAreas);
@@ -3772,7 +3769,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(FloatPoint());
+        m_rootContentsLayer->setPosition({ });
 
 #if PLATFORM(IOS_FAMILY)
         // Page scale is applied above this on iOS, so we'll just say that our root layer applies it.
@@ -3788,52 +3785,35 @@ 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({ });
 
-#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
-            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_overflowControlsHostLayer->addChild(*m_scrollContainerLayer);
+            m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
             m_scrolledContentsLayer->addChild(*m_rootContentsLayer);
 
-            updateScrollLayerClipping();
+            updateScrollContainerGeometry();
             updateOverflowControlsLayers();
 
             if (hasCoordinatedScrolling())
                 scheduleLayerFlush(true);
             else
-                updateScrollLayerPosition();
+                updateLayersForScrollPosition();
         }
     } else {
         if (m_overflowControlsHostLayer) {
             GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
-            GraphicsLayer::unparentAndClear(m_clipLayer);
             GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
             GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
         }
@@ -3880,7 +3860,6 @@ void RenderLayerCompositor::destroyRootLayer()
 
     if (m_overflowControlsHostLayer) {
         GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
-        GraphicsLayer::unparentAndClear(m_clipLayer);
         GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
         GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     }
@@ -4320,7 +4299,7 @@ void RenderLayerCompositor::updateScrollingNodeLayers(ScrollingNodeID nodeID, Re
         FrameView& frameView = m_renderView.frameView();
         scrollingCoordinator.setNodeLayers(nodeID, { nullptr,
             scrollContainerLayer(), scrolledContentsLayer(),
-            fixedRootBackgroundLayer(), clipLayer(), rootContentsLayer(),
+            fixedRootBackgroundLayer(), nullptr, rootContentsLayer(),
             frameView.layerForHorizontalScrollbar(), frameView.layerForVerticalScrollbar() });
     } else {
         auto& backing = *layer.backing();
index 9134779..fe8d75c 100644 (file)
@@ -246,11 +246,8 @@ 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(); }
@@ -440,8 +437,8 @@ private:
 
     void updateOverflowControlsLayers();
 
-    void updateScrollLayerPosition();
-    void updateScrollLayerClipping();
+    void updateLayersForScrollPosition();
+    void updateScrollContainerGeometry();
 
     FloatPoint positionForClipLayer() const;
 
@@ -574,7 +571,6 @@ private:
     RefPtr<GraphicsLayer> m_rootContentsLayer;
 
     // Enclosing clipping layer for iframe content
-    RefPtr<GraphicsLayer> m_clipLayer;
     RefPtr<GraphicsLayer> m_scrollContainerLayer;
     RefPtr<GraphicsLayer> m_scrolledContentsLayer;
 
index 5f21dbd..0ac4bd1 100644 (file)
@@ -1,3 +1,15 @@
+2019-06-18  Simon Fraser  <simon.fraser@apple.com>
+
+        Convert macOS to scroll by changing layer boundsOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=198917
+
+        Reviewed by Antti Koivisto.
+
+        Remove unreached and confusing code.
+
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
+        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers):
+
 2019-06-18  Dean Jackson  <dino@apple.com>
 
         Attachment elements are missing context menu previews
index 1136fc9..81a2eb9 100644 (file)
@@ -122,9 +122,7 @@ void ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers()
         return;
     }
 
-    auto scrollPosition = currentScrollPosition();
-    // FIXME: This is always wrong on iOS. Maybe assert that we always have a delegate.
-    [scrolledContentsLayer() setPosition:-scrollPosition];
+    // Main frame scrolling is handled by the main UIScrollView.
 }
 
 void ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers()