[iOS] Tiles not created in large scrollable iframes
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 07:49:33 +0000 (07:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 07:49:33 +0000 (07:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193665

Reviewed by Simon Fraser.

Source/WebCore:

We are not syncing scroll position back to the graphics layer tree correctly.

Test by Frédéric Wang.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewRootLayerDidChange):
(WebCore::AsyncScrollingCoordinator::reconcileScrollingState):
(WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):

Factor setting and syncing scrolling layer positions into a function.
Use bounds.origin scrolling mechanic when scrollContainerLayer is present.

(WebCore::AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange):
(WebCore::AsyncScrollingCoordinator::setSynchronousScrollingReasons):
(WebCore::AsyncScrollingCoordinator::updateScrollLayerPosition): Deleted.
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::scrollContainerLayerForFrameView):
(WebCore::ScrollingCoordinator::scrolledContentsLayerForFrameView):
(WebCore::ScrollingCoordinator::scrollLayerForFrameView): Deleted.
* page/scrolling/ScrollingCoordinator.h:
* rendering/RenderLayerCompositor.cpp:

Rename scrollLayer to scrolledContentsLayer according to out preferred naming scheme and use it in that role only.
Add scrollContainerLayer as a separate layer. It is only constructed when using async scrolling on iOS.

(WebCore::RenderLayerCompositor::~RenderLayerCompositor):
(WebCore::RenderLayerCompositor::customPositionForVisibleRectComputation const):
(WebCore::RenderLayerCompositor::visibleRectForLayerFlushing const):
(WebCore::RenderLayerCompositor::didChangePlatformLayerForLayer):
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateScrollLayerPosition):
(WebCore::RenderLayerCompositor::frameViewDidScroll):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForHeader):
(WebCore::RenderLayerCompositor::updateLayerForFooter):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
(WebCore::RenderLayerCompositor::ensureRootLayer):
(WebCore::RenderLayerCompositor::destroyRootLayer):
(WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingRole):
* rendering/RenderLayerCompositor.h:

Source/WebKit:

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

We now use scrollContainerLayer consistently so remove the special cases.

LayoutTests:

Test by Frédéric Wang.

* fast/scrolling/ios/scroll-iframe-expected.html:
* fast/scrolling/ios/scroll-iframe.html:
* platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt:
* platform/ios-wk2/compositing/tiling/tiled-drawing-async-frame-scrolling-expected.txt:
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/scrolling/ios/scroll-iframe-expected.html
LayoutTests/fast/scrolling/ios/scroll-iframe.html
LayoutTests/platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt
LayoutTests/platform/ios-wk2/compositing/tiling/tiled-drawing-async-frame-scrolling-expected.txt
LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm

index b231bbc..56c7ee0 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-03  Antti Koivisto  <antti@apple.com>
+
+        [iOS] Tiles not created in large scrollable iframes
+        https://bugs.webkit.org/show_bug.cgi?id=193665
+
+        Reviewed by Simon Fraser.
+
+        Test by Frédéric Wang.
+
+        * fast/scrolling/ios/scroll-iframe-expected.html:
+        * fast/scrolling/ios/scroll-iframe.html:
+        * platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt:
+        * platform/ios-wk2/compositing/tiling/tiled-drawing-async-frame-scrolling-expected.txt:
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
+
 2019-02-03  John Wilander  <wilander@apple.com>
 
         Parse and handle Ad Click Attribution attributes in HTMLAnchorElement::handleClick()
index 28fbc26..d7f646a 100644 (file)
@@ -18,6 +18,7 @@
         <div class=testdiv></div>
         <div class=testdiv></div>
         <div class=testdiv></div>
+        <div class=testdiv></div>
     </div>
 </body>
 </html>
index 66c2f0e..3b1e33c 100644 (file)
          var c = centerOf("maxScrollX");
          await touchAndDragFromPointToPoint(c.x, c.y, c.x - 150, c.y);
          await liftUpAtPoint(c.x - 150, c.y);
+
          c = centerOf("maxScrollY");
          await touchAndDragFromPointToPoint(c.x, c.y, c.x, c.y - 150);
          await liftUpAtPoint(c.x, c.y - 150);
+         
          c = centerOf("maxScrollXY");
          await touchAndDragFromPointToPoint(c.x, c.y, c.x - 150, c.y - 150);
          await liftUpAtPoint(c.x - 150, c.y - 150);
 
+         c = centerOf("largeContent");
+         await touchAndDragFromPointToPoint(c.x, c.y, c.x, c.y - 2000);
+         await liftUpAtPoint(c.x, c.y - 2000);
+
          // Wait for scrolling to stabilize and for scrollbars to disappear.
          setTimeout(() => {testRunner.notifyDone(); }, 2000);
        }
 
-       var frameToLoadCount = 3;
+       var frameToLoadCount = 4;
        function newFrameLoaded() {
            frameToLoadCount--;
            if (frameToLoadCount == 0)
                 <div style='left: 100px; top: 100px; position: absolute; width: 100px; height: 100px; background: green;'></div>
             </body>" onload="newFrameLoaded()">
         </iframe>
+        <iframe id="largeContent" scrolling="yes" srcdoc="
+            <body style='margin: 0;'>
+            <div style='width: 100px; height: 500px; background: red;'></div>
+            <div style='width: 100px; height: 500px; background: blue;'></div>
+            <div style='width: 100px; height: 500px; background: red;'></div>
+            <div style='width: 100px; height: 500px; background: blue;'></div>
+            <div style='width: 100px; height: 500px; background: green;'></div>
+            </body>" onload="newFrameLoaded()">
+        </iframe>
     </div>
 </body>
 </html>
index 5ef7550..843dff8 100644 (file)
@@ -20,7 +20,6 @@
                   (bounds 300.00 150.00)
                   (children 1
                     (GraphicsLayer
-                      (position -80.00 -80.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index 6b5d2fe..d052717 100644 (file)
                   (bounds 300.00 150.00)
                   (backingStoreAttached 1)
                   (visible rect 0.00, 0.00 300.00 x 150.00)
-                  (coverage rect -10.00, -10.00 800.00 x 600.00)
+                  (coverage rect 0.00, 0.00 300.00 x 150.00)
                   (intersects coverage rect 1)
                   (contentsScale 2.00)
                   (children 1
                     (GraphicsLayer
                       (anchor 0.00 0.00)
-                      (bounds 400.00 300.00)
-                      (backingStoreAttached 1)
-                      (visible rect 0.00, 0.00 400.00 x 300.00)
-                      (coverage rect 0.00, 0.00 400.00 x 300.00)
-                      (intersects coverage rect 1)
+                      (backingStoreAttached 0)
+                      (visible rect 0.00, 0.00 0.00 x 0.00)
+                      (coverage rect 0.00, 0.00 300.00 x 150.00)
+                      (intersects coverage rect 0)
                       (contentsScale 2.00)
                       (children 1
                         (GraphicsLayer
+                          (anchor 0.00 0.00)
                           (bounds 400.00 300.00)
-                          (drawsContent 1)
                           (backingStoreAttached 1)
-                          (visible rect 0.00, 0.00 400.00 x 300.00)
-                          (coverage rect 0.00, 0.00 400.00 x 300.00)
+                          (visible rect 0.00, 0.00 300.00 x 150.00)
+                          (coverage rect 0.00, 0.00 300.00 x 150.00)
                           (intersects coverage rect 1)
                           (contentsScale 2.00)
-                          (tile cache coverage 0, 0 400 x 300)
-                          (tile size 512 x 512)
-                          (top left tile 0, 0 tiles grid 1 x 1)
-                          (in window 1)
                           (children 1
                             (GraphicsLayer
-                              (backingStoreAttached 0)
-                              (visible rect 0.00, 0.00 0.00 x 0.00)
-                              (coverage rect 0.00, 0.00 400.00 x 300.00)
-                              (intersects coverage rect 0)
+                              (bounds 400.00 300.00)
+                              (drawsContent 1)
+                              (backingStoreAttached 1)
+                              (visible rect 0.00, 0.00 300.00 x 150.00)
+                              (coverage rect 0.00, 0.00 300.00 x 150.00)
+                              (intersects coverage rect 1)
                               (contentsScale 2.00)
+                              (tile cache coverage 0, 0 400 x 300)
+                              (tile size 512 x 512)
+                              (top left tile 0, 0 tiles grid 1 x 1)
+                              (in window 1)
+                              (children 1
+                                (GraphicsLayer
+                                  (backingStoreAttached 0)
+                                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                                  (coverage rect 0.00, 0.00 300.00 x 150.00)
+                                  (intersects coverage rect 0)
+                                  (contentsScale 2.00)
+                                )
+                              )
                             )
                           )
                         )
                   (bounds 300.00 150.00)
                   (backingStoreAttached 1)
                   (visible rect 0.00, 0.00 300.00 x 150.00)
-                  (coverage rect -318.00, -10.00 800.00 x 600.00)
+                  (coverage rect 0.00, 0.00 300.00 x 150.00)
                   (intersects coverage rect 1)
                   (contentsScale 2.00)
                   (children 1
                     (GraphicsLayer
                       (anchor 0.00 0.00)
-                      (bounds 400.00 300.00)
-                      (backingStoreAttached 1)
-                      (visible rect 0.00, 0.00 400.00 x 300.00)
-                      (coverage rect 0.00, 0.00 400.00 x 300.00)
-                      (intersects coverage rect 1)
+                      (backingStoreAttached 0)
+                      (visible rect 0.00, 0.00 0.00 x 0.00)
+                      (coverage rect 0.00, 0.00 300.00 x 150.00)
+                      (intersects coverage rect 0)
                       (contentsScale 2.00)
                       (children 1
                         (GraphicsLayer
+                          (anchor 0.00 0.00)
                           (bounds 400.00 300.00)
-                          (drawsContent 1)
                           (backingStoreAttached 1)
-                          (visible rect 0.00, 0.00 400.00 x 300.00)
-                          (coverage rect 0.00, 0.00 400.00 x 300.00)
+                          (visible rect 0.00, 0.00 300.00 x 150.00)
+                          (coverage rect 0.00, 0.00 300.00 x 150.00)
                           (intersects coverage rect 1)
                           (contentsScale 2.00)
-                          (tile cache coverage 0, 0 400 x 300)
-                          (tile size 512 x 512)
-                          (top left tile 0, 0 tiles grid 1 x 1)
-                          (in window 1)
                           (children 1
                             (GraphicsLayer
-                              (backingStoreAttached 0)
-                              (visible rect 0.00, 0.00 0.00 x 0.00)
-                              (coverage rect 0.00, 0.00 400.00 x 300.00)
-                              (intersects coverage rect 0)
+                              (bounds 400.00 300.00)
+                              (drawsContent 1)
+                              (backingStoreAttached 1)
+                              (visible rect 0.00, 0.00 300.00 x 150.00)
+                              (coverage rect 0.00, 0.00 300.00 x 150.00)
+                              (intersects coverage rect 1)
                               (contentsScale 2.00)
+                              (tile cache coverage 0, 0 400 x 300)
+                              (tile size 512 x 512)
+                              (top left tile 0, 0 tiles grid 1 x 1)
+                              (in window 1)
+                              (children 1
+                                (GraphicsLayer
+                                  (backingStoreAttached 0)
+                                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                                  (coverage rect 0.00, 0.00 300.00 x 150.00)
+                                  (intersects coverage rect 0)
+                                  (contentsScale 2.00)
+                                )
+                              )
                             )
                           )
                         )
                   (bounds 300.00 150.00)
                   (backingStoreAttached 1)
                   (visible rect 0.00, 0.00 300.00 x 150.00)
-                  (coverage rect -10.00, -169.00 800.00 x 600.00)
+                  (coverage rect 0.00, 0.00 300.00 x 150.00)
                   (intersects coverage rect 1)
                   (contentsScale 2.00)
                   (children 1
                     (GraphicsLayer
                       (anchor 0.00 0.00)
-                      (bounds 400.00 300.00)
-                      (backingStoreAttached 1)
-                      (visible rect 0.00, 0.00 400.00 x 300.00)
-                      (coverage rect 0.00, 0.00 400.00 x 300.00)
-                      (intersects coverage rect 1)
+                      (backingStoreAttached 0)
+                      (visible rect 0.00, 0.00 0.00 x 0.00)
+                      (coverage rect 0.00, 0.00 300.00 x 150.00)
+                      (intersects coverage rect 0)
                       (contentsScale 2.00)
                       (children 1
                         (GraphicsLayer
+                          (anchor 0.00 0.00)
                           (bounds 400.00 300.00)
-                          (drawsContent 1)
                           (backingStoreAttached 1)
-                          (visible rect 0.00, 0.00 400.00 x 300.00)
-                          (coverage rect 0.00, 0.00 400.00 x 300.00)
+                          (visible rect 0.00, 0.00 300.00 x 150.00)
+                          (coverage rect 0.00, 0.00 300.00 x 150.00)
                           (intersects coverage rect 1)
                           (contentsScale 2.00)
-                          (tile cache coverage 0, 0 400 x 300)
-                          (tile size 512 x 512)
-                          (top left tile 0, 0 tiles grid 1 x 1)
-                          (in window 1)
                           (children 1
                             (GraphicsLayer
-                              (backingStoreAttached 0)
-                              (visible rect 0.00, 0.00 0.00 x 0.00)
-                              (coverage rect 0.00, 0.00 400.00 x 300.00)
-                              (intersects coverage rect 0)
+                              (bounds 400.00 300.00)
+                              (drawsContent 1)
+                              (backingStoreAttached 1)
+                              (visible rect 0.00, 0.00 300.00 x 150.00)
+                              (coverage rect 0.00, 0.00 300.00 x 150.00)
+                              (intersects coverage rect 1)
                               (contentsScale 2.00)
+                              (tile cache coverage 0, 0 400 x 300)
+                              (tile size 512 x 512)
+                              (top left tile 0, 0 tiles grid 1 x 1)
+                              (in window 1)
+                              (children 1
+                                (GraphicsLayer
+                                  (backingStoreAttached 0)
+                                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                                  (coverage rect 0.00, 0.00 300.00 x 150.00)
+                                  (intersects coverage rect 0)
+                                  (contentsScale 2.00)
+                                )
+                              )
                             )
                           )
                         )
index 27782ba..9db90e5 100644 (file)
@@ -68,7 +68,6 @@
                   (bounds 480.00 400.00)
                   (children 1
                     (GraphicsLayer
-                      (position 0.00 -120.00)
                       (anchor 0.00 0.00)
                       (children 1
                         (GraphicsLayer
index e3478e3..8b802f0 100644 (file)
@@ -1,3 +1,53 @@
+2019-02-03  Antti Koivisto  <antti@apple.com>
+
+        [iOS] Tiles not created in large scrollable iframes
+        https://bugs.webkit.org/show_bug.cgi?id=193665
+
+        Reviewed by Simon Fraser.
+
+        We are not syncing scroll position back to the graphics layer tree correctly.
+
+        Test by Frédéric Wang.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::frameViewRootLayerDidChange):
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollingState):
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
+
+        Factor setting and syncing scrolling layer positions into a function.
+        Use bounds.origin scrolling mechanic when scrollContainerLayer is present.
+
+        (WebCore::AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange):
+        (WebCore::AsyncScrollingCoordinator::setSynchronousScrollingReasons):
+        (WebCore::AsyncScrollingCoordinator::updateScrollLayerPosition): Deleted.
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::scrollContainerLayerForFrameView):
+        (WebCore::ScrollingCoordinator::scrolledContentsLayerForFrameView):
+        (WebCore::ScrollingCoordinator::scrollLayerForFrameView): Deleted.
+        * page/scrolling/ScrollingCoordinator.h:
+        * rendering/RenderLayerCompositor.cpp:
+
+        Rename scrollLayer to scrolledContentsLayer according to out preferred naming scheme and use it in that role only.
+        Add scrollContainerLayer as a separate layer. It is only constructed when using async scrolling on iOS.
+
+        (WebCore::RenderLayerCompositor::~RenderLayerCompositor):
+        (WebCore::RenderLayerCompositor::customPositionForVisibleRectComputation const):
+        (WebCore::RenderLayerCompositor::visibleRectForLayerFlushing const):
+        (WebCore::RenderLayerCompositor::didChangePlatformLayerForLayer):
+        (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
+        (WebCore::RenderLayerCompositor::updateScrollLayerPosition):
+        (WebCore::RenderLayerCompositor::frameViewDidScroll):
+        (WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
+        (WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
+        (WebCore::RenderLayerCompositor::updateLayerForHeader):
+        (WebCore::RenderLayerCompositor::updateLayerForFooter):
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+        (WebCore::RenderLayerCompositor::destroyRootLayer):
+        (WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingRole):
+        * rendering/RenderLayerCompositor.h:
+
 2019-02-03  Simon Fraser  <simon.fraser@apple.com>
 
         Make setNeedsLayout on the root more explicitly about triggering its side-effects
index 50fb161..537c0d0 100644 (file)
@@ -226,7 +226,8 @@ void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView
     ScrollingCoordinator::frameViewRootLayerDidChange(frameView);
 
     auto* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID()));
-    node->setScrolledContentsLayer(scrollLayerForFrameView(frameView));
+    node->setScrollContainerLayer(scrollContainerLayerForFrameView(frameView));
+    node->setScrolledContentsLayer(scrolledContentsLayerForFrameView(frameView));
     node->setRootContentsLayer(rootContentsLayerForFrameView(frameView));
     node->setCounterScrollingLayer(counterScrollingLayerForFrameView(frameView));
     node->setInsetClipLayer(insetClipLayerForFrameView(frameView));
@@ -413,8 +414,7 @@ void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, co
             reconcileViewportConstrainedLayerPositions(scrollingNodeID, LayoutRect(layoutViewportRect.value()), scrollingLayerPositionAction);
     }
 
-    auto* scrollLayer = scrollLayerForFrameView(frameView);
-    if (!scrollLayer)
+    if (!scrolledContentsLayerForFrameView(frameView))
         return;
 
     auto* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
@@ -438,7 +438,8 @@ void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, co
         FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, frameView.totalContentsSize().height(), frameView.footerHeight()));
 
     if (programmaticScroll || scrollingLayerPositionAction == ScrollingLayerPositionAction::Set) {
-        scrollLayer->setPosition(-frameView.scrollPosition());
+        reconcileScrollPosition(frameView, ScrollingLayerPositionAction::Set);
+
         if (counterScrollingLayer)
             counterScrollingLayer->setPosition(scrollPositionForFixed);
         if (insetClipLayer)
@@ -452,7 +453,8 @@ void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, co
         if (footerLayer)
             footerLayer->setPosition(positionForFooterLayer);
     } else {
-        scrollLayer->syncPosition(-frameView.scrollPosition());
+        reconcileScrollPosition(frameView, ScrollingLayerPositionAction::Sync);
+
         if (counterScrollingLayer)
             counterScrollingLayer->syncPosition(scrollPositionForFixed);
         if (insetClipLayer)
@@ -468,6 +470,28 @@ 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;
+    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)
 {
     ASSERT(isMainThread());
@@ -480,7 +504,6 @@ void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(Scrollable
             scrollingNode.setVerticalScrollbarLayer(scrollableArea.layerForVerticalScrollbar());
         else
             scrollingNode.setHorizontalScrollbarLayer(scrollableArea.layerForHorizontalScrollbar());
-
     }
 
     if (&scrollableArea == m_page->mainFrame().view()) {
@@ -659,17 +682,10 @@ void AsyncScrollingCoordinator::setSynchronousScrollingReasons(FrameView& frameV
     // at this point. So we'll update it before we switch back to main thread scrolling
     // in order to avoid layer positioning bugs.
     if (reasons)
-        updateScrollLayerPosition(frameView);
+        reconcileScrollPosition(frameView, ScrollingLayerPositionAction::Set);
     scrollingStateNode->setSynchronousScrollingReasons(reasons);
 }
 
-void AsyncScrollingCoordinator::updateScrollLayerPosition(FrameView& frameView)
-{
-    ASSERT(isMainThread());
-    if (auto* scrollLayer = scrollLayerForFrameView(frameView))
-        scrollLayer->setPosition(-frameView.scrollPosition());
-}
-
 bool AsyncScrollingCoordinator::isRubberBandInProgress() const
 {
     return scrollingTree()->isRubberBandInProgress();
index d389f0c..104cc82 100644 (file)
@@ -113,6 +113,7 @@ private:
     WEBCORE_EXPORT void setViewportConstraintedNodeGeometry(ScrollingNodeID, const ViewportConstraints&) override;
 
     WEBCORE_EXPORT void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool programmaticScroll, ViewportRectStability, ScrollingLayerPositionAction) override;
+    void reconcileScrollPosition(FrameView&, ScrollingLayerPositionAction);
 
     bool isRubberBandInProgress() const override;
     void setScrollPinningBehavior(ScrollPinningBehavior) override;
@@ -129,7 +130,6 @@ private:
     virtual void scheduleTreeStateCommit() = 0;
 
     void ensureRootStateNodeForFrameView(FrameView&);
-    void updateScrollLayerPosition(FrameView&);
 
     void updateScrollPositionAfterAsyncScrollTimerFired();
     void setEventTrackingRegionsDirty();
index c29d080..22f9fc2 100644 (file)
@@ -224,10 +224,17 @@ void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView& frameView)
     updateSynchronousScrollingReasons(frameView);
 }
 
-GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::scrollContainerLayerForFrameView(FrameView& frameView)
 {
     if (auto* renderView = frameView.frame().contentRenderer())
-        return renderView->compositor().scrollLayer();
+        return renderView->compositor().scrollContainerLayer();
+    return nullptr;
+}
+
+GraphicsLayer* ScrollingCoordinator::scrolledContentsLayerForFrameView(FrameView& frameView)
+{
+    if (auto* renderView = frameView.frame().contentRenderer())
+        return renderView->compositor().scrolledContentsLayer();
     return nullptr;
 }
 
index d1b3330..2ca1dc9 100644 (file)
@@ -192,7 +192,8 @@ public:
 protected:
     explicit ScrollingCoordinator(Page*);
 
-    GraphicsLayer* scrollLayerForFrameView(FrameView&);
+    GraphicsLayer* scrollContainerLayerForFrameView(FrameView&);
+    GraphicsLayer* scrolledContentsLayerForFrameView(FrameView&);
     GraphicsLayer* counterScrollingLayerForFrameView(FrameView&);
     GraphicsLayer* insetClipLayerForFrameView(FrameView&);
     GraphicsLayer* rootContentsLayerForFrameView(FrameView&);
index 97c1786..70b9e3e 100644 (file)
@@ -291,7 +291,7 @@ RenderLayerCompositor::~RenderLayerCompositor()
 {
     // Take care that the owned GraphicsLayers are deleted first as their destructors may call back here.
     m_clipLayer = nullptr;
-    m_scrollLayer = nullptr;
+    m_scrolledContentsLayer = nullptr;
     ASSERT(m_rootLayerAttachment == RootLayerUnattached);
 }
 
@@ -411,7 +411,7 @@ bool RenderLayerCompositor::didRecalcStyleWithNoPendingLayout()
 
 void RenderLayerCompositor::customPositionForVisibleRectComputation(const GraphicsLayer* graphicsLayer, FloatPoint& position) const
 {
-    if (graphicsLayer != m_scrollLayer.get())
+    if (graphicsLayer != m_scrolledContentsLayer.get())
         return;
 
     FloatPoint scrollPosition = -position;
@@ -453,8 +453,8 @@ FloatRect RenderLayerCompositor::visibleRectForLayerFlushing() const
 #if PLATFORM(IOS_FAMILY)
     return frameView.exposedContentRect();
 #else
-    // Having a m_scrollLayer indicates that we're doing scrolling via GraphicsLayers.
-    FloatRect visibleRect = m_scrollLayer ? FloatRect({ }, frameView.sizeForVisibleContent()) : frameView.visibleContentRect();
+    // Having a m_scrolledContentsLayer indicates that we're doing scrolling via GraphicsLayers.
+    FloatRect visibleRect = m_scrolledContentsLayer ? FloatRect({ }, frameView.sizeForVisibleContent()) : frameView.visibleContentRect();
 
     if (frameView.viewExposedRect())
         visibleRect.intersect(frameView.viewExposedRect().value());
@@ -549,10 +549,9 @@ void RenderLayerCompositor::didChangePlatformLayerForLayer(RenderLayer& layer, c
     if (auto nodeID = backing->scrollingNodeIDForRole(ScrollCoordinationRole::Scrolling)) {
         // FIXME: would be nice to not have to special-case the root.
         ScrollingCoordinator::NodeLayers nodeLayers;
-        if (layer.isRenderViewLayer()) {
-            // FIXME: Reorganize the layers and pass the scrollContainerLayer.
-            nodeLayers = { nullptr, nullptr, m_scrollLayer.get(), fixedRootBackgroundLayer(), clipLayer(), m_rootContentsLayer.get() };
-        } else
+        if (layer.isRenderViewLayer())
+            nodeLayers = { nullptr, scrollContainerLayer(), scrolledContentsLayer(), fixedRootBackgroundLayer(), clipLayer(), rootContentsLayer() };
+        else
             nodeLayers = { layer.backing()->graphicsLayer(), backing->scrollContainerLayer(), backing->scrolledContentsLayer() };
 
         scrollingCoordinator->setNodeLayers(nodeID, nodeLayers);
@@ -1801,7 +1800,7 @@ void RenderLayerCompositor::frameViewDidChangeSize()
     if (auto* layer = m_renderView.layer())
         layer->setNeedsCompositingGeometryUpdate();
 
-    if (m_scrollLayer) {
+    if (m_scrolledContentsLayer) {
         updateScrollLayerClipping();
         frameViewDidScroll();
         updateOverflowControlsLayers();
@@ -1824,12 +1823,13 @@ bool RenderLayerCompositor::hasCoordinatedScrolling() const
 
 void RenderLayerCompositor::updateScrollLayerPosition()
 {
-    ASSERT(m_scrollLayer);
+    ASSERT(!hasCoordinatedScrolling());
+    ASSERT(m_scrolledContentsLayer);
 
     auto& frameView = m_renderView.frameView();
     IntPoint scrollPosition = frameView.scrollPosition();
 
-    m_scrollLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
+    m_scrolledContentsLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
 
     if (auto* fixedBackgroundLayer = fixedRootBackgroundLayer())
         fixedBackgroundLayer->setPosition(frameView.scrollPositionForFixedPosition());
@@ -1856,7 +1856,7 @@ FloatPoint RenderLayerCompositor::positionForClipLayer() const
 
 void RenderLayerCompositor::frameViewDidScroll()
 {
-    if (!m_scrollLayer)
+    if (!m_scrolledContentsLayer)
         return;
 
     // If there's a scrolling coordinator that manages scrolling for this frame view,
@@ -3124,7 +3124,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForTopOverhangArea(bool wantsLa
     if (!m_layerForTopOverhangArea) {
         m_layerForTopOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
         m_layerForTopOverhangArea->setName("top overhang");
-        m_scrollLayer->addChildBelow(*m_layerForTopOverhangArea, m_rootContentsLayer.get());
+        m_scrolledContentsLayer->addChildBelow(*m_layerForTopOverhangArea, m_rootContentsLayer.get());
     }
 
     return m_layerForTopOverhangArea.get();
@@ -3143,7 +3143,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForBottomOverhangArea(bool want
     if (!m_layerForBottomOverhangArea) {
         m_layerForBottomOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
         m_layerForBottomOverhangArea->setName("bottom overhang");
-        m_scrollLayer->addChildBelow(*m_layerForBottomOverhangArea, m_rootContentsLayer.get());
+        m_scrolledContentsLayer->addChildBelow(*m_layerForBottomOverhangArea, m_rootContentsLayer.get());
     }
 
     m_layerForBottomOverhangArea->setPosition(FloatPoint(0, m_rootContentsLayer->size().height() + m_renderView.frameView().headerHeight()
@@ -3171,7 +3171,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForHeader(bool wantsLayer)
     if (!m_layerForHeader) {
         m_layerForHeader = GraphicsLayer::create(graphicsLayerFactory(), *this);
         m_layerForHeader->setName("header");
-        m_scrollLayer->addChildAbove(*m_layerForHeader, m_rootContentsLayer.get());
+        m_scrolledContentsLayer->addChildAbove(*m_layerForHeader, m_rootContentsLayer.get());
         m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
     }
 
@@ -3208,7 +3208,7 @@ GraphicsLayer* RenderLayerCompositor::updateLayerForFooter(bool wantsLayer)
     if (!m_layerForFooter) {
         m_layerForFooter = GraphicsLayer::create(graphicsLayerFactory(), *this);
         m_layerForFooter->setName("footer");
-        m_scrollLayer->addChildAbove(*m_layerForFooter, m_rootContentsLayer.get());
+        m_scrolledContentsLayer->addChildAbove(*m_layerForFooter, m_rootContentsLayer.get());
     }
 
     float totalContentHeight = m_rootContentsLayer->size().height() + m_renderView.frameView().headerHeight() + m_renderView.frameView().footerHeight();
@@ -3342,7 +3342,7 @@ void RenderLayerCompositor::updateOverflowControlsLayers()
             m_contentShadowLayer->setAnchorPoint(FloatPoint3D());
             m_contentShadowLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingShadow);
 
-            m_scrollLayer->addChildBelow(*m_contentShadowLayer, m_rootContentsLayer.get());
+            m_scrolledContentsLayer->addChildBelow(*m_contentShadowLayer, m_rootContentsLayer.get());
         }
     } else
         GraphicsLayer::unparentAndClear(m_contentShadowLayer);
@@ -3433,36 +3433,40 @@ void RenderLayerCompositor::ensureRootLayer()
 
     if (requiresScrollLayer(expectedAttachment)) {
         if (!m_overflowControlsHostLayer) {
-            ASSERT(!m_scrollLayer);
+            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");
 
-            auto scrollLayerType = GraphicsLayer::Type::Normal;
+            m_scrolledContentsLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
+            m_scrolledContentsLayer->setName("scrolled contents layer");
+            m_scrolledContentsLayer->setAnchorPoint({ });
+
 #if PLATFORM(IOS_FAMILY)
-            if (m_renderView.settings().asyncFrameScrollingEnabled())
-                scrollLayerType = GraphicsLayer::Type::Scrolling;
-#endif
-            m_scrollLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, scrollLayerType);
-            m_scrollLayer->setName("frame scrolling");
-            m_scrollLayer->setAnchorPoint({ });
+            if (m_renderView.settings().asyncFrameScrollingEnabled()) {
+                m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::Scrolling);
 
-            if (scrollLayerType == GraphicsLayer::Type::Scrolling) {
-                // Scroll layer clips so there is no need for a separate clipping layer.
-                m_overflowControlsHostLayer->addChild(*m_scrollLayer);
-            } else {
+                m_scrollContainerLayer->setName("scroll containers layer");
+                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_scrollLayer);
+                m_clipLayer->addChild(*m_scrolledContentsLayer);
                 m_overflowControlsHostLayer->addChild(*m_clipLayer);
             }
 
-            m_scrollLayer->addChild(*m_rootContentsLayer);
+            m_scrolledContentsLayer->addChild(*m_rootContentsLayer);
 
             updateScrollLayerClipping();
             updateOverflowControlsLayers();
@@ -3476,7 +3480,8 @@ void RenderLayerCompositor::ensureRootLayer()
         if (m_overflowControlsHostLayer) {
             GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
             GraphicsLayer::unparentAndClear(m_clipLayer);
-            GraphicsLayer::unparentAndClear(m_scrollLayer);
+            GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
+            GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
         }
     }
 
@@ -3522,9 +3527,10 @@ void RenderLayerCompositor::destroyRootLayer()
     if (m_overflowControlsHostLayer) {
         GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
         GraphicsLayer::unparentAndClear(m_clipLayer);
-        GraphicsLayer::unparentAndClear(m_scrollLayer);
+        GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
+        GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     }
-    ASSERT(!m_scrollLayer);
+    ASSERT(!m_scrolledContentsLayer);
     GraphicsLayer::unparentAndClear(m_rootContentsLayer);
 
     m_layerUpdater = nullptr;
@@ -4013,7 +4019,7 @@ ScrollingNodeID RenderLayerCompositor::updateScrollingNodeForScrollingRole(Rende
         }
 
         if (changes & ScrollingNodeChangeFlags::Layer)
-            scrollingCoordinator->setNodeLayers(newNodeID, { nullptr, nullptr, m_scrollLayer.get(), fixedRootBackgroundLayer(), clipLayer(), m_rootContentsLayer.get() });
+            scrollingCoordinator->setNodeLayers(newNodeID, { nullptr, scrollContainerLayer(), scrolledContentsLayer(), fixedRootBackgroundLayer(), clipLayer(), rootContentsLayer() });
 
         if (changes & ScrollingNodeChangeFlags::LayerGeometry) {
             ScrollingCoordinator::ScrollingGeometry scrollingGeometry;
index ca4b4e8..8694533 100644 (file)
@@ -241,11 +241,12 @@ public:
     WEBCORE_EXPORT RenderLayer& rootRenderLayer() const;
     GraphicsLayer* rootGraphicsLayer() const;
 
-    GraphicsLayer* scrollLayer() const { return m_scrollLayer.get(); }
+    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_scrollLayer.get();  }
+    GraphicsLayer* layerForClipping() const {  return m_clipLayer ? m_clipLayer.get() : m_scrollContainerLayer.get();  }
 
 #if ENABLE(RUBBER_BANDING)
     GraphicsLayer* headerLayer() const { return m_layerForHeader.get(); }
@@ -564,7 +565,8 @@ private:
 
     // Enclosing clipping layer for iframe content
     RefPtr<GraphicsLayer> m_clipLayer;
-    RefPtr<GraphicsLayer> m_scrollLayer;
+    RefPtr<GraphicsLayer> m_scrollContainerLayer;
+    RefPtr<GraphicsLayer> m_scrolledContentsLayer;
 
     // Enclosing layer for overflow controls and the clipping layer
     RefPtr<GraphicsLayer> m_overflowControlsHostLayer;
index 41073f1..62e3438 100644 (file)
@@ -1,3 +1,17 @@
+2019-02-03  Antti Koivisto  <antti@apple.com>
+
+        [iOS] Tiles not created in large scrollable iframes
+        https://bugs.webkit.org/show_bug.cgi?id=193665
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
+        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::commitStateBeforeChildren):
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateBeforeChildren):
+
+        We now use scrollContainerLayer consistently so remove the special cases.
+
 2019-02-03  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [curl] [WebKit] Assertion failures of missing networkStorageSession for storage/indexeddb tests
index 8bb45ba..78ab20e 100644 (file)
@@ -52,9 +52,8 @@ void ScrollingTreeFrameScrollingNodeRemoteIOS::commitStateBeforeChildren(const S
 {
     ScrollingTreeFrameScrollingNodeIOS::commitStateBeforeChildren(stateNode);
 
-    // FIXME: Should be ScrollContainerLayer.
-    if (stateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) {
-        if (scrolledContentsLayer() && [[scrolledContentsLayer() delegate] isKindOfClass:[UIScrollView self]])
+    if (stateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) {
+        if (scrollContainerLayer())
             m_scrollingNodeDelegate = std::make_unique<ScrollingTreeScrollingNodeDelegateIOS>(*this);
         else
             m_scrollingNodeDelegate = nullptr;
index ca997b0..5c3653b 100644 (file)
@@ -215,20 +215,8 @@ void ScrollingTreeScrollingNodeDelegateIOS::resetScrollViewDelegate()
 
 void ScrollingTreeScrollingNodeDelegateIOS::commitStateBeforeChildren(const ScrollingStateScrollingNode& scrollingStateNode)
 {
-    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) {
-        RetainPtr<CALayer> layer;
-        layer = scrollingStateNode.scrollContainerLayer();
-        if ([[layer delegate] isKindOfClass:[UIScrollView self]])
-            m_scrollLayer = layer;
-    }
-
-    // FIMXE: ScrollContainerLayer should always be the UIScrollView layer.
-    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) {
-        RetainPtr<CALayer> layer;
-        layer = scrollingStateNode.scrolledContentsLayer();
-        if ([[layer delegate] isKindOfClass:[UIScrollView self]])
-            m_scrollLayer = layer;
-    }
+    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer))
+        m_scrollLayer = scrollingStateNode.scrollContainerLayer();
 }
 
 void ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren(const ScrollingStateScrollingNode& scrollingStateNode)