⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246538 in webkit


Ignore:
Timestamp:
Jun 18, 2019, 8:16:33 AM (7 years ago)
Author:
Simon Fraser
Message:

Convert macOS to scroll by changing layer boundsOrigin
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:
Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246536 r246538  
     12019-06-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert macOS to scroll by changing layer boundsOrigin
     4        https://bugs.webkit.org/show_bug.cgi?id=198917
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * compositing/iframes/scrolling-iframe-expected.txt:
     9        * compositing/overflow/textarea-scroll-touch-expected.txt:
     10        * compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt:
     11        * compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt:
     12        * compositing/repaint/scroller-with-foreground-layer-repaints-expected.txt:
     13        * compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
     14        * scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt:
     15
    1162019-06-18  Zan Dobersek  <zdobersek@igalia.com>
    217
  • trunk/LayoutTests/compositing/iframes/scrolling-iframe-expected.txt

    r240677 r246538  
    1717              (children 1
    1818                (GraphicsLayer
     19                  (bounds origin 80.00 80.00)
    1920                  (anchor 0.00 0.00)
    2021                  (bounds 285.00 135.00)
    2122                  (children 1
    2223                    (GraphicsLayer
    23                       (position -80.00 -80.00)
    2424                      (anchor 0.00 0.00)
    2525                      (children 1
  • trunk/LayoutTests/compositing/overflow/textarea-scroll-touch-expected.txt

    r243347 r246538  
    1717              (offsetFromRenderer width=1 height=1)
    1818              (position 1.00 1.00)
     19              (bounds origin 0.00 50.00)
    1920              (bounds 189.00 124.00)
    2021              (children 1
     
    2223                  (offsetFromRenderer width=1 height=1)
    2324                  (scrollOffset (0,50))
    24                   (position 0.00 -50.00)
    2525                  (anchor 0.00 0.00)
    2626                  (bounds 189.00 270.00)
     
    4040              (offsetFromRenderer width=1 height=1)
    4141              (position 1.00 1.00)
     42              (bounds origin 0.00 50.00)
    4243              (bounds 189.00 124.00)
    4344              (children 1
     
    4546                  (offsetFromRenderer width=1 height=1)
    4647                  (scrollOffset (0,50))
    47                   (position 0.00 -50.00)
    4848                  (anchor 0.00 0.00)
    4949                  (bounds 189.00 270.00)
  • trunk/LayoutTests/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt

    r240677 r246538  
    1818              (children 1
    1919                (GraphicsLayer
     20                  (bounds origin 0.00 100.00)
    2021                  (anchor 0.00 0.00)
    2122                  (bounds 400.00 300.00)
    2223                  (children 1
    2324                    (GraphicsLayer
    24                       (position 0.00 -100.00)
    2525                      (anchor 0.00 0.00)
    2626                      (children 1
  • trunk/LayoutTests/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt

    r240677 r246538  
    1818              (children 1
    1919                (GraphicsLayer
     20                  (bounds origin 0.00 100.00)
    2021                  (anchor 0.00 0.00)
    2122                  (bounds 400.00 300.00)
    2223                  (children 1
    2324                    (GraphicsLayer
    24                       (position 0.00 -100.00)
    2525                      (anchor 0.00 0.00)
    2626                      (children 1
  • trunk/LayoutTests/compositing/repaint/scroller-with-foreground-layer-repaints-expected.txt

    r246018 r246538  
    2121              (offsetFromRenderer width=1 height=1)
    2222              (position 1.00 1.00)
     23              (bounds origin 0.00 200.00)
    2324              (bounds 305.00 305.00)
    2425              (children 1
     
    2627                  (offsetFromRenderer width=1 height=1)
    2728                  (scrollOffset (0,200))
    28                   (position 0.00 -200.00)
    2929                  (anchor 0.00 0.00)
    3030                  (bounds 305.00 1020.00)
  • trunk/LayoutTests/compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt

    r245170 r246538  
    1616              (offsetFromRenderer width=2 height=2)
    1717              (position 2.00 2.00)
     18              (bounds origin 366.00 0.00)
    1819              (bounds 400.00 204.00)
    1920              (children 1
     
    2122                  (offsetFromRenderer width=2 height=2)
    2223                  (scrollOffset (366,0))
    23                   (position -366.00 0.00)
    2424                  (anchor 0.00 0.00)
    2525                  (bounds 766.00 204.00)
  • trunk/LayoutTests/platform/ios-wk2/compositing/iframes/scrolling-iframe-expected.txt

    r240916 r246538  
    1717              (children 1
    1818                (GraphicsLayer
     19                  (bounds origin 80.00 80.00)
    1920                  (anchor 0.00 0.00)
    2021                  (bounds 300.00 150.00)
  • trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt

    r242333 r246538  
    6464              (children 1
    6565                (GraphicsLayer
     66                  (bounds origin 0.00 120.00)
    6667                  (anchor 0.00 0.00)
    6768                  (bounds 480.00 400.00)
  • trunk/LayoutTests/platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt

    r240694 r246538  
    2222              (children 1
    2323                (GraphicsLayer
     24                  (bounds origin 0.00 100.00)
    2425                  (anchor 0.00 0.00)
    2526                  (bounds 400.00 300.00)
    2627                  (children 1
    2728                    (GraphicsLayer
    28                       (position 0.00 -100.00)
    2929                      (anchor 0.00 0.00)
    3030                      (children 1
  • trunk/LayoutTests/platform/mac-highsierra-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt

    r240694 r246538  
    2222              (children 1
    2323                (GraphicsLayer
     24                  (bounds origin 0.00 100.00)
    2425                  (anchor 0.00 0.00)
    2526                  (bounds 400.00 300.00)
    2627                  (children 1
    2728                    (GraphicsLayer
    28                       (position 0.00 -100.00)
    2929                      (anchor 0.00 0.00)
    3030                      (children 1
  • trunk/LayoutTests/platform/mac-sierra-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt

    r238034 r246538  
    2121              (children 1
    2222                (GraphicsLayer
     23                  (bounds origin 0.00 100.00)
    2324                  (anchor 0.00 0.00)
    2425                  (bounds 400.00 300.00)
    2526                  (children 1
    2627                    (GraphicsLayer
    27                       (position 0.00 -100.00)
    2828                      (children 1
    2929                        (GraphicsLayer
  • trunk/LayoutTests/platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-scroll-repaint-expected.txt

    r240677 r246538  
    2121              (children 1
    2222                (GraphicsLayer
     23                  (bounds origin 0.00 100.00)
    2324                  (anchor 0.00 0.00)
    2425                  (bounds 400.00 300.00)
    2526                  (children 1
    2627                    (GraphicsLayer
    27                       (position 0.00 -100.00)
    2828                      (anchor 0.00 0.00)
    2929                      (children 1
     
    3535                              (bounds 400.00 1016.00)
    3636                              (drawsContent 1)
     37                              (repaint rects
     38                                (rect 0.00 0.00 400.00 1016.00)
     39                                (rect 0.00 0.00 400.00 1016.00)
     40                                (rect 8.00 8.00 384.00 1000.00)
     41                                (rect 0.00 0.00 400.00 1016.00)
     42                              )
    3743                              (children 1
    3844                                (GraphicsLayer
  • trunk/LayoutTests/platform/mac-wk1/compositing/repaint/iframes/compositing-iframe-with-fixed-background-doc-repaint-expected.txt

    r240677 r246538  
    2121              (children 1
    2222                (GraphicsLayer
     23                  (bounds origin 0.00 100.00)
    2324                  (anchor 0.00 0.00)
    2425                  (bounds 400.00 300.00)
    2526                  (children 1
    2627                    (GraphicsLayer
    27                       (position 0.00 -100.00)
    2828                      (anchor 0.00 0.00)
    2929                      (children 1
  • trunk/LayoutTests/scrollingcoordinator/scrolling-tree/fixed-inside-frame-expected.txt

    r243825 r246538  
    6666              (children 1
    6767                (GraphicsLayer
     68                  (bounds origin 0.00 120.00)
    6869                  (anchor 0.00 0.00)
    6970                  (bounds 465.00 400.00)
    7071                  (children 1
    7172                    (GraphicsLayer
    72                       (position 0.00 -120.00)
    7373                      (anchor 0.00 0.00)
    7474                      (children 1
  • trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-down-tile-coverage-expected.txt

    r245837 r246538  
    3131              (offsetFromRenderer width=1 height=1)
    3232              (position 1.00 1.00)
     33              (bounds origin 0.00 1800.00)
    3334              (bounds 385.00 512.00)
    34               (visible rect 0.00, 0.00 385.00 x 512.00)
    35               (coverage rect 0.00, 0.00 385.00 x 512.00)
     35              (visible rect 0.00, 1800.00 385.00 x 512.00)
     36              (coverage rect 0.00, 1800.00 385.00 x 512.00)
    3637              (intersects coverage rect 1)
    3738              (contentsScale 1.00)
     
    4041                  (offsetFromRenderer width=1 height=1)
    4142                  (scrollOffset (0,1800))
    42                   (position 0.00 -1800.00)
    4343                  (anchor 0.00 0.00)
    4444                  (bounds 385.00 3000.00)
  • trunk/LayoutTests/tiled-drawing/scrolling/overflow/overflow-scrolled-up-tile-coverage-expected.txt

    r245837 r246538  
    3131              (offsetFromRenderer width=1 height=1)
    3232              (position 1.00 1.00)
     33              (bounds origin 0.00 200.00)
    3334              (bounds 385.00 512.00)
    34               (visible rect 0.00, 0.00 385.00 x 512.00)
    35               (coverage rect 0.00, 0.00 385.00 x 512.00)
     35              (visible rect 0.00, 200.00 385.00 x 512.00)
     36              (coverage rect 0.00, 200.00 385.00 x 512.00)
    3637              (intersects coverage rect 1)
    3738              (contentsScale 1.00)
     
    4041                  (offsetFromRenderer width=1 height=1)
    4142                  (scrollOffset (0,200))
    42                   (position 0.00 -200.00)
    4343                  (anchor 0.00 0.00)
    4444                  (bounds 385.00 3000.00)
  • trunk/Source/WebCore/ChangeLog

    r246537 r246538  
     12019-06-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert macOS to scroll by changing layer boundsOrigin
     4        https://bugs.webkit.org/show_bug.cgi?id=198917
     5
     6        Reviewed by Antti Koivisto.
     7
     8        macOS did frame and overflow scrolling by changing the position of the scrolled
     9        contents layer. iOS scrolls by changing the boundsOrigin of the scrollContainer layer
     10        (which it has to, to match how UIScrollView works).
     11
     12        The iOS approach removes the need for an extra layer whose only role is for
     13        scroll positioning, so migrate macOS to the same approach. A later patch can remove
     14        m_scrolledContentsLayer.
     15       
     16        We can remove RenderLayerCompositor::m_clipLayer since m_scrollContainerLayer has exactly
     17        the same role now.
     18
     19        * page/scrolling/AsyncScrollingCoordinator.cpp:
     20        (WebCore::AsyncScrollingCoordinator::reconcileScrollPosition):
     21        * page/scrolling/ScrollingCoordinator.cpp:
     22        (WebCore::ScrollingCoordinator::insetClipLayerForFrameView):
     23        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     24        (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
     25        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
     26        (WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):
     27        * platform/graphics/cocoa/WebCoreCALayerExtras.h:
     28        * platform/graphics/cocoa/WebCoreCALayerExtras.mm:
     29        (-[CALayer _web_setLayerBoundsOrigin:]):
     30        * rendering/RenderLayerBacking.cpp:
     31        (WebCore::RenderLayerBacking::updateGeometry):
     32        (WebCore::RenderLayerBacking::setLocationOfScrolledContents):
     33        (WebCore::RenderLayerBacking::updateScrollOffset):
     34        * rendering/RenderLayerCompositor.cpp:
     35        (WebCore::RenderLayerCompositor::~RenderLayerCompositor):
     36        (WebCore::RenderLayerCompositor::flushPendingLayerChanges):
     37        (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
     38        (WebCore::RenderLayerCompositor::updateLayersForScrollPosition):
     39        (WebCore::RenderLayerCompositor::updateScrollContainerGeometry):
     40        (WebCore::RenderLayerCompositor::frameViewDidScroll):
     41        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
     42        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
     43        (WebCore::RenderLayerCompositor::ensureRootLayer):
     44        (WebCore::RenderLayerCompositor::destroyRootLayer):
     45        (WebCore::RenderLayerCompositor::updateScrollingNodeLayers):
     46        (WebCore::RenderLayerCompositor::updateScrollLayerPosition): Deleted.
     47        (WebCore::RenderLayerCompositor::updateScrollLayerClipping): Deleted.
     48        * rendering/RenderLayerCompositor.h:
     49
    1502019-06-18  Philippe Normand  <pnormand@igalia.com>
    251
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r245568 r246538  
    447447void AsyncScrollingCoordinator::reconcileScrollPosition(FrameView& frameView, ScrollingLayerPositionAction scrollingLayerPositionAction)
    448448{
    449 #if PLATFORM(IOS_FAMILY)
    450     // Doing all scrolling like this (UIScrollView style) would simplify code.
    451449    auto* scrollContainerLayer = scrollContainerLayerForFrameView(frameView);
    452450    if (!scrollContainerLayer)
    453451        return;
     452
     453    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
    454454    if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
    455455        scrollContainerLayer->setBoundsOrigin(frameView.scrollPosition());
    456456    else
    457457        scrollContainerLayer->syncBoundsOrigin(frameView.scrollPosition());
    458 #else
    459     auto* scrolledContentsLayer = scrolledContentsLayerForFrameView(frameView);
    460     if (!scrolledContentsLayer)
    461         return;
    462     if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set)
    463         scrolledContentsLayer->setPosition(-frameView.scrollPosition());
    464     else
    465         scrolledContentsLayer->syncPosition(-frameView.scrollPosition());
    466 #endif
    467458}
    468459
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r246036 r246538  
    273273{
    274274    if (auto* renderView = frameView.frame().contentRenderer())
    275         return renderView->compositor().clipLayer();
     275        return renderView->compositor().scrollContainerLayer();
    276276    return nullptr;
    277277}
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r245543 r246538  
    200200void ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers()
    201201{
    202     scrolledContentsLayer().position = -currentScrollPosition();
     202    // We use scroll position here because the root content layer is offset to account for scrollOrigin (see FrameView::positionForRootContentLayer).
     203    [scrollContainerLayer() _web_setLayerBoundsOrigin:currentScrollPosition()];
    203204}
    204205
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm

    r245771 r246538  
    3232#import "ScrollingStateOverflowScrollingNode.h"
    3333#import "ScrollingTree.h"
     34#import "WebCoreCALayerExtras.h"
    3435#import <wtf/text/TextStream.h>
    3536
     
    9293{
    9394    auto scrollOffset = ScrollableArea::scrollOffsetFromPosition(currentScrollPosition(), toFloatSize(scrollOrigin()));
    94     scrolledContentsLayer().position = -scrollOffset;
     95    [scrollContainerLayer() _web_setLayerBoundsOrigin:scrollOffset];
    9596}
    9697
  • trunk/Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.h

    r242669 r246538  
    2929
    3030- (void)web_disableAllActions;
     31- (void)_web_setLayerBoundsOrigin:(CGPoint)origin;
    3132- (void)_web_setLayerTopLeftPosition:(CGPoint)position;
    3233+ (CALayer *)_web_renderLayerWithContextID:(uint32_t)contextID;
  • trunk/Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.mm

    r242669 r246538  
    5757}
    5858
     59- (void)_web_setLayerBoundsOrigin:(CGPoint)origin
     60{
     61    CGRect bounds = [self bounds];
     62    bounds.origin = origin;
     63    [self setBounds:bounds];
     64}
     65
    5966- (void)_web_setLayerTopLeftPosition:(CGPoint)position
    6067{
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r246389 r246538  
    12261226        ScrollOffset scrollOffset = m_owningLayer.scrollOffset();
    12271227        updateScrollOffset(scrollOffset);
    1228 #if PLATFORM(IOS_FAMILY)
    1229         m_scrolledContentsLayer->setPosition({ }); // FIXME: necessary?
    1230 #endif
    12311228
    12321229        FloatSize oldScrollingLayerOffset = m_scrollContainerLayer->offsetFromRenderer();
     
    13071304void RenderLayerBacking::setLocationOfScrolledContents(ScrollOffset scrollOffset, ScrollingLayerPositionAction setOrSync)
    13081305{
    1309 #if PLATFORM(IOS_FAMILY)
    13101306    if (setOrSync == ScrollingLayerPositionAction::Sync)
    13111307        m_scrollContainerLayer->syncBoundsOrigin(scrollOffset);
    13121308    else
    13131309        m_scrollContainerLayer->setBoundsOrigin(scrollOffset);
    1314 #else
    1315     if (setOrSync == ScrollingLayerPositionAction::Sync)
    1316         m_scrolledContentsLayer->syncPosition(-scrollOffset);
    1317     else
    1318         m_scrolledContentsLayer->setPosition(-scrollOffset);
    1319 #endif
    13201310}
    13211311
     
    13311321        m_owningLayer.setRequiresScrollPositionReconciliation(false);
    13321322    }
     1323
     1324    ASSERT(m_scrolledContentsLayer->position().isZero());
    13331325}
    13341326
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r246367 r246538  
    302302    GraphicsLayer::unparentAndClear(m_rootContentsLayer);
    303303   
    304     GraphicsLayer::unparentAndClear(m_clipLayer);
    305304    GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
    306305    GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     
    522521        if (layersLogEnabled()) {
    523522            LOG(Layers, "RenderLayerCompositor::flushPendingLayerChanges");
    524             showGraphicsLayerTree(m_rootContentsLayer.get());
     523            showGraphicsLayerTree(m_overflowControlsHostLayer.get());
    525524        }
    526525#endif
     
    19701969
    19711970    if (m_scrolledContentsLayer) {
    1972         updateScrollLayerClipping();
     1971        updateScrollContainerGeometry();
    19731972        frameViewDidScroll();
    19741973        updateOverflowControlsLayers();
     
    19901989}
    19911990
    1992 void RenderLayerCompositor::updateScrollLayerPosition()
     1991void RenderLayerCompositor::updateLayersForScrollPosition()
    19931992{
    19941993    ASSERT(!hasCoordinatedScrolling());
    1995     ASSERT(m_scrolledContentsLayer);
     1994    ASSERT(m_scrollContainerLayer);
    19961995
    19971996    auto& frameView = m_renderView.frameView();
    1998     IntPoint scrollPosition = frameView.scrollPosition();
    1999 
    2000     m_scrolledContentsLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
     1997    // This uses scrollPosition because the root content layer accounts for scrollOrigin (see FrameView::positionForRootContentLayer()).
     1998    m_scrollContainerLayer->setBoundsOrigin(frameView.scrollPosition());
    20011999
    20022000    if (auto* fixedBackgroundLayer = fixedRootBackgroundLayer())
     
    20042002}
    20052003
    2006 void RenderLayerCompositor::updateScrollLayerClipping()
    2007 {
    2008     auto* layerForClipping = this->layerForClipping();
    2009     if (!layerForClipping)
     2004void RenderLayerCompositor::updateScrollContainerGeometry()
     2005{
     2006    if (!m_scrollContainerLayer)
    20102007        return;
    20112008
    2012     layerForClipping->setSize(m_renderView.frameView().sizeForVisibleContent());
    2013     layerForClipping->setPosition(positionForClipLayer());
     2009    m_scrollContainerLayer->setSize(m_renderView.frameView().sizeForVisibleContent());
     2010    m_scrollContainerLayer->setPosition(positionForClipLayer());
    20142011}
    20152012
     
    20362033    }
    20372034
    2038     updateScrollLayerPosition();
     2035    updateLayersForScrollPosition();
    20392036}
    20402037
     
    22532250        m_rootContentsLayer->setSize(m_renderView.frameView().contentsSize());
    22542251        m_rootContentsLayer->setPosition(m_renderView.frameView().positionForRootContentLayer());
    2255         m_rootContentsLayer->setAnchorPoint(FloatPoint3D());
    2256     }
    2257 
    2258     updateScrollLayerClipping();
     2252        m_rootContentsLayer->setAnchorPoint({ });
     2253    }
     2254
     2255    updateScrollContainerGeometry();
    22592256
    22602257#if ENABLE(RUBBER_BANDING)
     
    36833680            // We want the overhang areas layer to be positioned below the frame contents,
    36843681            // so insert it below the clip layer.
    3685             m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, layerForClipping());
     3682            m_overflowControlsHostLayer->addChildBelow(*m_layerForOverhangAreas, m_scrollContainerLayer.get());
    36863683        }
    36873684    } else
     
    37733770        IntRect overflowRect = snappedIntRect(m_renderView.layoutOverflowRect());
    37743771        m_rootContentsLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.maxY()));
    3775         m_rootContentsLayer->setPosition(FloatPoint());
     3772        m_rootContentsLayer->setPosition({ });
    37763773
    37773774#if PLATFORM(IOS_FAMILY)
     
    37893786        if (!m_overflowControlsHostLayer) {
    37903787            ASSERT(!m_scrolledContentsLayer);
    3791             ASSERT(!m_clipLayer);
    37923788
    37933789            // Create a layer to host the clipping layer and the overflow controls layers.
     
    37953791            m_overflowControlsHostLayer->setName("overflow controls host");
    37963792
     3793            m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrollContainer);
     3794            m_scrollContainerLayer->setName("scroll container");
     3795            m_scrollContainerLayer->setMasksToBounds(true);
     3796            m_scrollContainerLayer->setAnchorPoint({ });
     3797
    37973798            m_scrolledContentsLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrolledContents);
    37983799            m_scrolledContentsLayer->setName("scrolled contents");
    37993800            m_scrolledContentsLayer->setAnchorPoint({ });
    38003801
    3801 #if PLATFORM(IOS_FAMILY)
    3802             if (m_renderView.settings().asyncFrameScrollingEnabled()) {
    3803                 m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrollContainer);
    3804 
    3805                 m_scrollContainerLayer->setName("scroll container");
    3806                 m_scrollContainerLayer->setMasksToBounds(true);
    3807                 m_scrollContainerLayer->setAnchorPoint({ });
    3808 
    3809                 m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
    3810                 m_overflowControlsHostLayer->addChild(*m_scrollContainerLayer);
    3811             }
    3812 #endif
    3813             if (!m_scrollContainerLayer) {
    3814                 m_clipLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
    3815                 m_clipLayer->setName("frame clipping");
    3816                 m_clipLayer->setMasksToBounds(true);
    3817                 m_clipLayer->setAnchorPoint({ });
    3818 
    3819                 m_clipLayer->addChild(*m_scrolledContentsLayer);
    3820                 m_overflowControlsHostLayer->addChild(*m_clipLayer);
    3821             }
    3822 
     3802            m_overflowControlsHostLayer->addChild(*m_scrollContainerLayer);
     3803            m_scrollContainerLayer->addChild(*m_scrolledContentsLayer);
    38233804            m_scrolledContentsLayer->addChild(*m_rootContentsLayer);
    38243805
    3825             updateScrollLayerClipping();
     3806            updateScrollContainerGeometry();
    38263807            updateOverflowControlsLayers();
    38273808
     
    38293810                scheduleLayerFlush(true);
    38303811            else
    3831                 updateScrollLayerPosition();
     3812                updateLayersForScrollPosition();
    38323813        }
    38333814    } else {
    38343815        if (m_overflowControlsHostLayer) {
    38353816            GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
    3836             GraphicsLayer::unparentAndClear(m_clipLayer);
    38373817            GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
    38383818            GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     
    38813861    if (m_overflowControlsHostLayer) {
    38823862        GraphicsLayer::unparentAndClear(m_overflowControlsHostLayer);
    3883         GraphicsLayer::unparentAndClear(m_clipLayer);
    38843863        GraphicsLayer::unparentAndClear(m_scrollContainerLayer);
    38853864        GraphicsLayer::unparentAndClear(m_scrolledContentsLayer);
     
    43214300        scrollingCoordinator.setNodeLayers(nodeID, { nullptr,
    43224301            scrollContainerLayer(), scrolledContentsLayer(),
    4323             fixedRootBackgroundLayer(), clipLayer(), rootContentsLayer(),
     4302            fixedRootBackgroundLayer(), nullptr, rootContentsLayer(),
    43244303            frameView.layerForHorizontalScrollbar(), frameView.layerForVerticalScrollbar() });
    43254304    } else {
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r245950 r246538  
    247247    GraphicsLayer* scrollContainerLayer() const { return m_scrollContainerLayer.get(); }
    248248    GraphicsLayer* scrolledContentsLayer() const { return m_scrolledContentsLayer.get(); }
    249     GraphicsLayer* clipLayer() const { return m_clipLayer.get(); }
    250249    GraphicsLayer* rootContentsLayer() const { return m_rootContentsLayer.get(); }
    251 
    252     GraphicsLayer* layerForClipping() const {  return m_clipLayer ? m_clipLayer.get() : m_scrollContainerLayer.get();  }
    253250
    254251#if ENABLE(RUBBER_BANDING)
     
    441438    void updateOverflowControlsLayers();
    442439
    443     void updateScrollLayerPosition();
    444     void updateScrollLayerClipping();
     440    void updateLayersForScrollPosition();
     441    void updateScrollContainerGeometry();
    445442
    446443    FloatPoint positionForClipLayer() const;
     
    575572
    576573    // Enclosing clipping layer for iframe content
    577     RefPtr<GraphicsLayer> m_clipLayer;
    578574    RefPtr<GraphicsLayer> m_scrollContainerLayer;
    579575    RefPtr<GraphicsLayer> m_scrolledContentsLayer;
  • trunk/Source/WebKit/ChangeLog

    r246535 r246538  
     12019-06-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Convert macOS to scroll by changing layer boundsOrigin
     4        https://bugs.webkit.org/show_bug.cgi?id=198917
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Remove unreached and confusing code.
     9
     10        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
     11        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers):
     12
    1132019-06-18  Dean Jackson  <dino@apple.com>
    214
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm

    r243926 r246538  
    123123    }
    124124
    125     auto scrollPosition = currentScrollPosition();
    126     // FIXME: This is always wrong on iOS. Maybe assert that we always have a delegate.
    127     [scrolledContentsLayer() setPosition:-scrollPosition];
     125    // Main frame scrolling is handled by the main UIScrollView.
    128126}
    129127
Note: See TracChangeset for help on using the changeset viewer.