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

Changeset 266825 in webkit


Ignore:
Timestamp:
Sep 10, 2020, 8:22:05 AM (6 years ago)
Author:
Simon Fraser
Message:

REGRESSION (Async overflow scroll): Truncated scrollbars in facebook chat
https://bugs.webkit.org/show_bug.cgi?id=216294
<rdar://problem/61918702>

Reviewed by Antti Koivisto.

Source/WebCore:

When both async overflow scroll and overlay scrollbars are enabled, it's possible for
composited layers that are later in z-order than the overflow to overlap the scrollbars
(overflow does not create stacking context, so they are later siblings to the overflow).

To fix this we have to hoist the layer that hosts the overflow controls above all later layers
which belong to contents scrolled by this overflow. We know which layers these are; they have
ancestor clippings stacks that reference the overflow layer.

This overflow controls layer hoisting happens in the context of the enclosing composited layer.

So to fix this RenderLayerCompositor::updateBackingAndHierarchy() tracks these layers that belong to
an overflow scroll. RenderLayerCompositor::adjustOverflowScrollbarContainerLayers() uses them to find
the overflow scroll layers whose controls need hoisting, and where to insert those overflow controls
hosting layers in the sublayers list of the enclosing composited layer.

An additional source of complexity occurs with overflow scroll nested inside another scroller or
overflow:hidden (in the same composited stacking context): the overflow controls reparenting is hoisting
that layer up, so that layer itself needs additional layers to clip it (essentially the overflow control
layer behaves like a later sibling that needs its own ancestor clipping stack). When this occurs,
RenderLayerBacking creates an additional "ancestor clipping stack" in m_overflowControlsHostLayerAncestorClippingStack
which is a parallel stack to m_ancestorClippingStack, but with its own set of clipping layers. At some point
this will also need scrolling tree nodes created for it. Some minor refactoring helps share code for
the two LayerAncestorClippingStacks.

This new code all runs late in the compositing update for a given layer, which is not ideal; we replicate
some code from updateGeometry() and updateInternalHierarchy(). Ideally we'd be able to know at
computeCompositingRequirements() time if we need to do layer hoisting and ancestor clipping stack duplication,
but that proves hard because of ordering dependencies.

Tests: compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic.html

compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden.html
compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested.html
compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar.html
compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position.html

  • rendering/LayerAncestorClippingStack.cpp:

(WebCore::LayerAncestorClippingStack::compositedClipData const):

  • rendering/LayerAncestorClippingStack.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateGeometry):
(WebCore::RenderLayerBacking::adjustOverflowControlsPositionRelativeToAncestor):
(WebCore::RenderLayerBacking::updateInternalHierarchy):
(WebCore::RenderLayerBacking::updateAncestorClippingStack):
(WebCore::RenderLayerBacking::ensureOverflowControlsHostLayerAncestorClippingStack):
(WebCore::RenderLayerBacking::ensureClippingStackLayers):
(WebCore::RenderLayerBacking::removeClippingStackLayers):
(WebCore::RenderLayerBacking::connectClippingStackLayers):
(WebCore::RenderLayerBacking::updateClippingStackLayerGeometry):
(WebCore::RenderLayerBacking::updateAncestorClipping):
(WebCore::RenderLayerBacking::offsetRelativeToRendererOriginForDescendantLayers const):

  • rendering/RenderLayerBacking.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::UpdateBackingTraversalState::UpdateBackingTraversalState):
(WebCore::RenderLayerCompositor::UpdateBackingTraversalState::stateForDescendants const):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::adjustOverflowScrollbarContainerLayers):
(WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingProxyRole):

  • rendering/RenderLayerCompositor.h:

LayoutTests:

Some new tests, and new baselines for tests that have different layer trees now.

  • compositing/layer-creation/clipping-scope/nested-scroller-overlap-expected.txt:
  • compositing/layer-creation/clipping-scope/overlap-constrained-inside-scroller-expected.txt:
  • compositing/layer-creation/clipping-scope/scroller-with-negative-z-children-expected.txt:
  • compositing/overflow/scrolling-content-clip-to-viewport-expected.txt:
  • compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-clipped-by-scroll-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-nested-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-hidden-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-visible-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-gain-clipping-layer-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-in-clipped-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/layer-in-overflow-lose-clipping-layer-expected.txt:
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic-expected.txt: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic.html: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-expected.txt: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden-expected.txt: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden.html: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested-expected.txt: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested.html: Added.
  • compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar.html: Added.
  • compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position-expected.txt: Added.
  • compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position.html: Added.
  • compositing/shared-backing/overflow-scroll/composited-absolute-in-absolute-in-relative-in-scroller-expected.txt:
  • compositing/shared-backing/overflow-scroll/previous-sibling-prevents-inclusiveness-expected.txt:
Location:
trunk
Files:
10 added
25 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r266822 r266825  
     12020-09-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (Async overflow scroll): Truncated scrollbars in facebook chat
     4        https://bugs.webkit.org/show_bug.cgi?id=216294
     5        <rdar://problem/61918702>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Some new tests, and new baselines for tests that have different layer trees now.
     10
     11        * compositing/layer-creation/clipping-scope/nested-scroller-overlap-expected.txt:
     12        * compositing/layer-creation/clipping-scope/overlap-constrained-inside-scroller-expected.txt:
     13        * compositing/layer-creation/clipping-scope/scroller-with-negative-z-children-expected.txt:
     14        * compositing/overflow/scrolling-content-clip-to-viewport-expected.txt:
     15        * compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
     16        * compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-clipped-by-scroll-expected.txt:
     17        * compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-expected.txt:
     18        * compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-nested-expected.txt:
     19        * compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt:
     20        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-hidden-expected.txt:
     21        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-visible-expected.txt:
     22        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-expected.txt:
     23        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-gain-clipping-layer-expected.txt:
     24        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-in-clipped-expected.txt:
     25        * compositing/scrolling/async-overflow-scrolling/layer-in-overflow-lose-clipping-layer-expected.txt:
     26        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic-expected.txt: Added.
     27        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic.html: Added.
     28        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-expected.txt: Added.
     29        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden-expected.txt: Added.
     30        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden.html: Added.
     31        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested-expected.txt: Added.
     32        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested.html: Added.
     33        * compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar.html: Added.
     34        * compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position-expected.txt: Added.
     35        * compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position.html: Added.
     36        * compositing/shared-backing/overflow-scroll/composited-absolute-in-absolute-in-relative-in-scroller-expected.txt:
     37        * compositing/shared-backing/overflow-scroll/previous-sibling-prevents-inclusiveness-expected.txt:
     38
    1392020-09-10  Diego Pino Garcia  <dpino@igalia.com>
    240
  • trunk/LayoutTests/compositing/layer-creation/clipping-scope/nested-scroller-overlap-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 7
     9      (children 8
    1010        (GraphicsLayer
    1111          (position 23.00 105.00)
    1212          (bounds 402.00 352.00)
    1313          (drawsContent 1)
    14           (children 2
     14          (children 1
    1515            (GraphicsLayer
    1616              (offsetFromRenderer width=1 height=1)
     
    5858                    )
    5959                  )
    60                 )
    61               )
    62             )
    63             (GraphicsLayer
    64               (position 1.00 1.00)
    65               (bounds 400.00 350.00)
    66               (children 1
    67                 (GraphicsLayer
    68                   (position 385.00 0.00)
    69                   (bounds 15.00 350.00)
    70                   (drawsContent 1)
    7160                )
    7261              )
     
    148137        )
    149138        (GraphicsLayer
     139          (position 24.00 106.00)
     140          (bounds 400.00 350.00)
     141          (children 1
     142            (GraphicsLayer
     143              (position 385.00 0.00)
     144              (bounds 15.00 350.00)
     145              (drawsContent 1)
     146            )
     147          )
     148        )
     149        (GraphicsLayer
    150150          (position 18.00 472.00)
    151151          (bounds 100.00 80.00)
  • trunk/LayoutTests/compositing/layer-creation/clipping-scope/overlap-constrained-inside-scroller-expected.txt

    r260305 r266825  
    66      (bounds 800.00 600.00)
    77      (contentsOpaque 1)
    8       (children 6
     8      (children 7
    99        (GraphicsLayer
    1010          (position 8.00 8.00)
    1111          (bounds 302.00 302.00)
    1212          (drawsContent 1)
    13           (children 2
     13          (children 1
    1414            (GraphicsLayer
    1515              (offsetFromRenderer width=1 height=1)
     
    2121                  (anchor 0.00 0.00)
    2222                  (bounds 285.00 500.00)
    23                 )
    24               )
    25             )
    26             (GraphicsLayer
    27               (position 1.00 1.00)
    28               (bounds 300.00 300.00)
    29               (children 1
    30                 (GraphicsLayer
    31                   (position 285.00 0.00)
    32                   (bounds 15.00 300.00)
    33                   (drawsContent 1)
    3423                )
    3524              )
     
    9281          )
    9382        )
     83        (GraphicsLayer
     84          (position 9.00 9.00)
     85          (bounds 300.00 300.00)
     86          (children 1
     87            (GraphicsLayer
     88              (position 285.00 0.00)
     89              (bounds 15.00 300.00)
     90              (drawsContent 1)
     91            )
     92          )
     93        )
    9494      )
    9595    )
  • trunk/LayoutTests/compositing/layer-creation/clipping-scope/scroller-with-negative-z-children-expected.txt

    r260305 r266825  
    1010          (bounds 800.00 600.00)
    1111          (drawsContent 1)
    12           (children 7
     12          (children 8
    1313            (GraphicsLayer
    1414              (position 9.00 9.00)
     
    3030              (bounds 302.00 302.00)
    3131              (drawsContent 1)
    32               (children 2
     32              (children 1
    3333                (GraphicsLayer
    3434                  (offsetFromRenderer width=1 height=1)
     
    4040                      (anchor 0.00 0.00)
    4141                      (bounds 285.00 500.00)
    42                     )
    43                   )
    44                 )
    45                 (GraphicsLayer
    46                   (position 1.00 1.00)
    47                   (bounds 300.00 300.00)
    48                   (children 1
    49                     (GraphicsLayer
    50                       (position 285.00 0.00)
    51                       (bounds 15.00 300.00)
    52                       (drawsContent 1)
    5342                    )
    5443                  )
     
    10089              )
    10190            )
     91            (GraphicsLayer
     92              (position 9.00 9.00)
     93              (bounds 300.00 300.00)
     94              (children 1
     95                (GraphicsLayer
     96                  (position 285.00 0.00)
     97                  (bounds 15.00 300.00)
     98                  (drawsContent 1)
     99                )
     100              )
     101            )
    102102          )
    103103        )
  • trunk/LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt

    r260305 r266825  
    66      (bounds 800.00 600.00)
    77      (contentsOpaque 1)
    8       (children 2
     8      (children 3
    99        (GraphicsLayer
    1010          (bounds 320.00 340.00)
    11           (children 2
     11          (children 1
    1212            (GraphicsLayer
    1313              (bounds 305.00 325.00)
     
    1616                  (anchor 0.00 0.00)
    1717                  (bounds 305.00 1224.00)
    18                 )
    19               )
    20             )
    21             (GraphicsLayer
    22               (bounds 320.00 340.00)
    23               (children 3
    24                 (GraphicsLayer
    25                   (position 0.00 325.00)
    26                   (bounds 305.00 15.00)
    27                   (drawsContent 1)
    28                 )
    29                 (GraphicsLayer
    30                   (position 305.00 0.00)
    31                   (bounds 15.00 325.00)
    32                   (drawsContent 1)
    33                 )
    34                 (GraphicsLayer
    35                   (position 305.00 325.00)
    36                   (bounds 15.00 15.00)
    37                   (drawsContent 1)
    3818                )
    3919              )
     
    5232          )
    5333        )
     34        (GraphicsLayer
     35          (bounds 320.00 340.00)
     36          (children 3
     37            (GraphicsLayer
     38              (position 0.00 325.00)
     39              (bounds 305.00 15.00)
     40              (drawsContent 1)
     41            )
     42            (GraphicsLayer
     43              (position 305.00 0.00)
     44              (bounds 15.00 325.00)
     45              (drawsContent 1)
     46            )
     47            (GraphicsLayer
     48              (position 305.00 325.00)
     49              (bounds 15.00 15.00)
     50              (drawsContent 1)
     51            )
     52          )
     53        )
    5454      )
    5555    )
  • trunk/LayoutTests/compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt

    r260305 r266825  
    88      (bounds 800.00 600.00)
    99      (contentsOpaque 1)
    10       (children 5
     10      (children 6
    1111        (GraphicsLayer
    1212          (position 8.00 8.00)
    1313          (bounds 404.00 223.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=2 height=2)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 766.00 204.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 2.00 2.00)
    34               (bounds 400.00 219.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 0.00 204.00)
    38                   (bounds 400.00 15.00)
    3928                  (drawsContent 1)
    4029                )
     
    9584          )
    9685        )
     86        (GraphicsLayer
     87          (position 10.00 10.00)
     88          (bounds 400.00 219.00)
     89          (children 1
     90            (GraphicsLayer
     91              (position 0.00 204.00)
     92              (bounds 400.00 15.00)
     93              (drawsContent 1)
     94            )
     95          )
     96        )
    9797      )
    9898    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-clipped-by-scroll-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 640.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    6453          )
    6554        )
     55        (GraphicsLayer
     56          (position 41.00 33.00)
     57          (bounds 316.00 316.00)
     58          (children 1
     59            (GraphicsLayer
     60              (position 301.00 0.00)
     61              (bounds 15.00 316.00)
     62              (drawsContent 1)
     63            )
     64          )
     65        )
    6666      )
    6767    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 540.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    6453          )
    6554        )
     55        (GraphicsLayer
     56          (position 41.00 33.00)
     57          (bounds 316.00 316.00)
     58          (children 1
     59            (GraphicsLayer
     60              (position 301.00 0.00)
     61              (bounds 15.00 316.00)
     62              (drawsContent 1)
     63            )
     64          )
     65        )
    6666      )
    6767    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/clipped-layer-in-overflow-nested-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    7373              )
    7474            )
    75             (GraphicsLayer
    76               (position 23.00 23.00)
    77               (bounds 316.00 316.00)
    78               (children 1
    79                 (GraphicsLayer
    80                   (position 301.00 0.00)
    81                   (bounds 15.00 316.00)
    82                   (drawsContent 1)
    83                 )
    84               )
    85             )
    8675          )
    8776        )
     
    121110          )
    122111        )
     112        (GraphicsLayer
     113          (position 41.00 33.00)
     114          (bounds 316.00 316.00)
     115          (children 1
     116            (GraphicsLayer
     117              (position 301.00 0.00)
     118              (bounds 15.00 316.00)
     119              (drawsContent 1)
     120            )
     121          )
     122        )
    123123      )
    124124    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt

    r260305 r266825  
    1010        (GraphicsLayer
    1111          (bounds 800.00 600.00)
    12           (children 3
     12          (children 4
    1313            (GraphicsLayer
    1414              (position 9.00 9.00)
     
    2424            )
    2525            (GraphicsLayer
     26              (position 9.00 9.00)
     27              (bounds 300.00 300.00)
     28              (children 1
     29                (GraphicsLayer
     30                  (position 285.00 0.00)
     31                  (bounds 15.00 300.00)
     32                  (drawsContent 1)
     33                )
     34              )
     35            )
     36            (GraphicsLayer
    2637              (bounds 800.00 600.00)
    2738            )
     
    3041              (bounds 302.00 302.00)
    3142              (drawsContent 1)
    32               (children 2
     43              (children 1
    3344                (GraphicsLayer
    3445                  (offsetFromRenderer width=1 height=1)
     
    4556                  )
    4657                )
    47                 (GraphicsLayer
    48                   (position 1.00 1.00)
    49                   (bounds 300.00 300.00)
    50                   (children 1
    51                     (GraphicsLayer
    52                       (position 285.00 0.00)
    53                       (bounds 15.00 300.00)
    54                       (drawsContent 1)
    55                     )
    56                   )
    57                 )
    5858              )
    5959            )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-hidden-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 540.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    6453          )
    6554        )
     55        (GraphicsLayer
     56          (position 41.00 33.00)
     57          (bounds 316.00 316.00)
     58          (children 1
     59            (GraphicsLayer
     60              (position 301.00 0.00)
     61              (bounds 15.00 316.00)
     62              (drawsContent 1)
     63            )
     64          )
     65        )
    6666      )
    6767    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-clip-to-visible-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 540.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    5746          )
    5847        )
     48        (GraphicsLayer
     49          (position 41.00 33.00)
     50          (bounds 316.00 316.00)
     51          (children 1
     52            (GraphicsLayer
     53              (position 301.00 0.00)
     54              (bounds 15.00 316.00)
     55              (drawsContent 1)
     56            )
     57          )
     58        )
    5959      )
    6060    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 516.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    5746          )
    5847        )
     48        (GraphicsLayer
     49          (position 41.00 33.00)
     50          (bounds 316.00 316.00)
     51          (children 1
     52            (GraphicsLayer
     53              (position 301.00 0.00)
     54              (bounds 15.00 316.00)
     55              (drawsContent 1)
     56            )
     57          )
     58        )
    5959      )
    6060    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-gain-clipping-layer-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 540.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    6453          )
    6554        )
     55        (GraphicsLayer
     56          (position 41.00 33.00)
     57          (bounds 316.00 316.00)
     58          (children 1
     59            (GraphicsLayer
     60              (position 301.00 0.00)
     61              (bounds 15.00 316.00)
     62              (drawsContent 1)
     63            )
     64          )
     65        )
    6666      )
    6767    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-in-clipped-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (position 33.00 25.00)
     
    1818              (bounds 362.00 362.00)
    1919              (drawsContent 1)
    20               (children 2
     20              (children 1
    2121                (GraphicsLayer
    2222                  (offsetFromRenderer width=13 height=13)
     
    3131                      (anchor 0.00 0.00)
    3232                      (bounds 301.00 516.00)
    33                       (drawsContent 1)
    34                     )
    35                   )
    36                 )
    37                 (GraphicsLayer
    38                   (position 23.00 23.00)
    39                   (bounds 316.00 316.00)
    40                   (children 1
    41                     (GraphicsLayer
    42                       (position 301.00 0.00)
    43                       (bounds 15.00 316.00)
    4433                      (drawsContent 1)
    4534                    )
     
    7160          )
    7261        )
     62        (GraphicsLayer
     63          (position 33.00 25.00)
     64          (bounds 312.00 212.00)
     65          (clips 1)
     66          (children 1
     67            (GraphicsLayer
     68              (position 39.00 39.00)
     69              (bounds 316.00 316.00)
     70              (children 1
     71                (GraphicsLayer
     72                  (position 301.00 0.00)
     73                  (bounds 15.00 316.00)
     74                  (drawsContent 1)
     75                )
     76              )
     77            )
     78          )
     79        )
    7380      )
    7481    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-in-overflow-lose-clipping-layer-expected.txt

    r260305 r266825  
    77      (bounds 800.00 600.00)
    88      (contentsOpaque 1)
    9       (children 2
     9      (children 3
    1010        (GraphicsLayer
    1111          (offsetFromRenderer width=-10 height=-10)
     
    1313          (bounds 362.00 362.00)
    1414          (drawsContent 1)
    15           (children 2
     15          (children 1
    1616            (GraphicsLayer
    1717              (offsetFromRenderer width=13 height=13)
     
    2626                  (anchor 0.00 0.00)
    2727                  (bounds 301.00 540.00)
    28                   (drawsContent 1)
    29                 )
    30               )
    31             )
    32             (GraphicsLayer
    33               (position 23.00 23.00)
    34               (bounds 316.00 316.00)
    35               (children 1
    36                 (GraphicsLayer
    37                   (position 301.00 0.00)
    38                   (bounds 15.00 316.00)
    3928                  (drawsContent 1)
    4029                )
     
    5746          )
    5847        )
     48        (GraphicsLayer
     49          (position 41.00 33.00)
     50          (bounds 316.00 316.00)
     51          (children 1
     52            (GraphicsLayer
     53              (position 301.00 0.00)
     54              (bounds 15.00 316.00)
     55              (drawsContent 1)
     56            )
     57          )
     58        )
    5959      )
    6060    )
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position-expected.txt

    r266824 r266825  
     1 
     2 
    13(GraphicsLayer
    24  (anchor 0.00 0.00)
    35  (bounds 800.00 600.00)
     6  (clips 1)
    47  (children 1
    58    (GraphicsLayer
    69      (bounds 800.00 600.00)
    710      (contentsOpaque 1)
    8       (children 2
     11      (children 1
    912        (GraphicsLayer
    10           (position 8.00 8.00)
    11           (bounds 404.00 404.00)
     13          (position 58.00 50.00)
     14          (bounds 524.00 424.00)
    1215          (drawsContent 1)
    1316          (children 2
     
    1518              (offsetFromRenderer width=2 height=2)
    1619              (position 2.00 2.00)
    17               (bounds 385.00 400.00)
     20              (bounds 520.00 405.00)
     21              (clips 1)
    1822              (children 1
    1923                (GraphicsLayer
    2024                  (offsetFromRenderer width=2 height=2)
    2125                  (anchor 0.00 0.00)
    22                   (bounds 385.00 1044.00)
     26                  (bounds 2050.00 405.00)
    2327                  (drawsContent 1)
    2428                )
     
    2731            (GraphicsLayer
    2832              (position 2.00 2.00)
    29               (bounds 400.00 400.00)
     33              (bounds 520.00 420.00)
    3034              (children 1
    3135                (GraphicsLayer
    32                   (position 385.00 0.00)
    33                   (bounds 15.00 400.00)
     36                  (position 0.00 405.00)
     37                  (bounds 520.00 15.00)
    3438                  (drawsContent 1)
    3539                )
    3640              )
    37             )
    38           )
    39         )
    40         (GraphicsLayer
    41           (position 10.00 10.00)
    42           (bounds 385.00 400.00)
    43           (children 1
    44             (GraphicsLayer
    45               (position 34.00 134.00)
    46               (bounds 220.00 220.00)
    47               (contentsOpaque 1)
    4841            )
    4942          )
  • trunk/LayoutTests/compositing/shared-backing/overflow-scroll/composited-absolute-in-absolute-in-relative-in-scroller-expected.txt

    r260305 r266825  
    66      (bounds 800.00 600.00)
    77      (contentsOpaque 1)
    8       (children 2
     8      (children 3
    99        (GraphicsLayer
    1010          (position 8.00 8.00)
    1111          (bounds 404.00 404.00)
    1212          (drawsContent 1)
    13           (children 2
     13          (children 1
    1414            (GraphicsLayer
    1515              (offsetFromRenderer width=2 height=2)
     
    2121                  (anchor 0.00 0.00)
    2222                  (bounds 385.00 1044.00)
    23                   (drawsContent 1)
    24                 )
    25               )
    26             )
    27             (GraphicsLayer
    28               (position 2.00 2.00)
    29               (bounds 400.00 400.00)
    30               (children 1
    31                 (GraphicsLayer
    32                   (position 385.00 0.00)
    33                   (bounds 15.00 400.00)
    3423                  (drawsContent 1)
    3524                )
     
    4938          )
    5039        )
     40        (GraphicsLayer
     41          (position 10.00 10.00)
     42          (bounds 400.00 400.00)
     43          (children 1
     44            (GraphicsLayer
     45              (position 385.00 0.00)
     46              (bounds 15.00 400.00)
     47              (drawsContent 1)
     48            )
     49          )
     50        )
    5151      )
    5252    )
  • trunk/Source/WebCore/ChangeLog

    r266824 r266825  
     12020-09-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (Async overflow scroll): Truncated scrollbars in facebook chat
     4        https://bugs.webkit.org/show_bug.cgi?id=216294
     5        <rdar://problem/61918702>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        When both async overflow scroll and overlay scrollbars are enabled, it's possible for
     10        composited layers that are later in z-order than the overflow to overlap the scrollbars
     11        (overflow does not create stacking context, so they are later siblings to the overflow).
     12
     13        To fix this we have to hoist the layer that hosts the overflow controls above all later layers
     14        which belong to contents scrolled by this overflow. We know which layers these are; they have
     15        ancestor clippings stacks that reference the overflow layer.
     16
     17        This overflow controls layer hoisting happens in the context of the enclosing composited layer.
     18
     19        So to fix this RenderLayerCompositor::updateBackingAndHierarchy() tracks these layers that belong to
     20        an overflow scroll. RenderLayerCompositor::adjustOverflowScrollbarContainerLayers() uses them to find
     21        the overflow scroll layers whose controls need hoisting, and where to insert those overflow controls
     22        hosting layers in the sublayers list of the enclosing composited layer.
     23
     24        An additional source of complexity occurs with overflow scroll nested inside another scroller or
     25        overflow:hidden (in the same composited stacking context): the overflow controls reparenting is hoisting
     26        that layer up, so that layer itself needs additional layers to clip it (essentially the overflow control
     27        layer behaves like a later sibling that needs its own ancestor clipping stack). When this occurs,
     28        RenderLayerBacking creates an additional "ancestor clipping stack" in m_overflowControlsHostLayerAncestorClippingStack
     29        which is a parallel stack to m_ancestorClippingStack, but with its own set of clipping layers. At some point
     30        this will also need scrolling tree nodes created for it. Some minor refactoring helps share code for
     31        the two LayerAncestorClippingStacks.
     32
     33        This new code all runs late in the compositing update for a given layer, which is not ideal; we replicate
     34        some code from updateGeometry() and updateInternalHierarchy(). Ideally we'd be able to know at
     35        computeCompositingRequirements() time if we need to do layer hoisting and ancestor clipping stack duplication,
     36        but that proves hard because of ordering dependencies.
     37
     38        Tests: compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-dynamic.html
     39               compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-inside-hidden.html
     40               compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar-nested.html
     41               compositing/scrolling/async-overflow-scrolling/overlapped-overlay-scrollbar.html
     42               compositing/scrolling/async-overflow-scrolling/transform-change-scrollbar-position.html
     43
     44        * rendering/LayerAncestorClippingStack.cpp:
     45        (WebCore::LayerAncestorClippingStack::compositedClipData const):
     46        * rendering/LayerAncestorClippingStack.h:
     47        * rendering/RenderLayerBacking.cpp:
     48        (WebCore::RenderLayerBacking::updateConfiguration):
     49        (WebCore::RenderLayerBacking::updateGeometry):
     50        (WebCore::RenderLayerBacking::adjustOverflowControlsPositionRelativeToAncestor):
     51        (WebCore::RenderLayerBacking::updateInternalHierarchy):
     52        (WebCore::RenderLayerBacking::updateAncestorClippingStack):
     53        (WebCore::RenderLayerBacking::ensureOverflowControlsHostLayerAncestorClippingStack):
     54        (WebCore::RenderLayerBacking::ensureClippingStackLayers):
     55        (WebCore::RenderLayerBacking::removeClippingStackLayers):
     56        (WebCore::RenderLayerBacking::connectClippingStackLayers):
     57        (WebCore::RenderLayerBacking::updateClippingStackLayerGeometry):
     58        (WebCore::RenderLayerBacking::updateAncestorClipping):
     59        (WebCore::RenderLayerBacking::offsetRelativeToRendererOriginForDescendantLayers const):
     60        * rendering/RenderLayerBacking.h:
     61        * rendering/RenderLayerCompositor.cpp:
     62        (WebCore::RenderLayerCompositor::UpdateBackingTraversalState::UpdateBackingTraversalState):
     63        (WebCore::RenderLayerCompositor::UpdateBackingTraversalState::stateForDescendants const):
     64        (WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
     65        (WebCore::RenderLayerCompositor::adjustOverflowScrollbarContainerLayers):
     66        (WebCore::RenderLayerCompositor::updateScrollingNodeForScrollingProxyRole):
     67        * rendering/RenderLayerCompositor.h:
     68
    1692020-09-10  Aditya Keerthi  <akeerthi@apple.com>
    270
  • trunk/Source/WebCore/platform/Logging.cpp

    r251193 r266825  
    9191    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
    9292    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
     93    LogCompositing.state = WTFLogChannelState::On;
    9394}
    9495
  • trunk/Source/WebCore/rendering/LayerAncestorClippingStack.cpp

    r246725 r266825  
    164164}
    165165
     166Vector<CompositedClipData> LayerAncestorClippingStack::compositedClipData() const
     167{
     168    Vector<CompositedClipData> clipData;
     169    clipData.reserveInitialCapacity(m_stack.size());
     170
     171    for (const auto& entry : m_stack)
     172        clipData.uncheckedAppend(entry.clipData);
     173
     174    return clipData;
     175}
     176
    166177static TextStream& operator<<(TextStream& ts, const LayerAncestorClippingStack::ClippingStackEntry& entry)
    167178{
  • trunk/Source/WebCore/rendering/LayerAncestorClippingStack.h

    r246734 r266825  
    7878    bool equalToClipData(const Vector<CompositedClipData>&) const;
    7979    bool updateWithClipData(ScrollingCoordinator*, Vector<CompositedClipData>&&);
     80   
     81    Vector<CompositedClipData> compositedClipData() const;
    8082
    8183    void clear(ScrollingCoordinator*);
     
    8789    GraphicsLayer* lastClippingLayer() const;
    8890    ScrollingNodeID lastOverflowScrollProxyNodeID() const;
    89    
    90     bool update(LayerAncestorClippingStack&&);
    91    
     91
    9292    struct ClippingStackEntry {
    9393        CompositedClipData clipData;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r266363 r266825  
    10011001        updateInternalHierarchy();
    10021002
     1003    // RenderLayerCompositor::adjustOverflowScrollbarContainerLayers() may have reparented the overflowControlsContainer
     1004    // in an earlier update, so always put it back here. We don't yet know if it will get reparented again.
     1005    if (m_overflowControlsContainer && m_overflowControlsContainer->parent() != m_graphicsLayer.get()) {
     1006        m_graphicsLayer->addChild(*m_overflowControlsContainer);
     1007        // Ensure that we fix up the position of m_overflowControlsContainer.
     1008        m_owningLayer.setNeedsCompositingGeometryUpdate();
     1009    }
     1010
     1011    // FIXME: Overlow controls need to be above the flattening layer?
    10031012    if (auto* flatteningLayer = tileCacheFlatteningLayer()) {
    10041013        if (layerConfigChanged || flatteningLayer->parent() != m_graphicsLayer.get())
     
    12621271    LayoutRect parentGraphicsLayerRect = computeParentGraphicsLayerRect(compositedAncestor);
    12631272
    1264     if (m_ancestorClippingStack) {
    1265         // All clipRects in the stack are computed relative to m_owningLayer, so convert them back to compositedAncestor.
    1266         auto offsetFromCompositedAncestor = toLayoutSize(m_owningLayer.convertToLayerCoords(compositedAncestor, { }, RenderLayer::AdjustForColumns));
    1267         LayoutRect lastClipLayerRect = parentGraphicsLayerRect;
    1268 
    1269         for (auto& entry : m_ancestorClippingStack->stack()) {
    1270             auto clipRect = entry.clipData.clipRect;
    1271             LayoutSize clippingOffset = computeOffsetFromAncestorGraphicsLayer(compositedAncestor, clipRect.location() + offsetFromCompositedAncestor, deviceScaleFactor);
    1272             LayoutRect snappedClippingLayerRect = snappedGraphicsLayer(clippingOffset, clipRect.size(), deviceScaleFactor).m_snappedRect;
    1273 
    1274             entry.clippingLayer->setPosition(toLayoutPoint(snappedClippingLayerRect.location() - lastClipLayerRect.location()));
    1275             lastClipLayerRect = snappedClippingLayerRect;
    1276 
    1277             entry.clippingLayer->setSize(snappedClippingLayerRect.size());
    1278 
    1279             if (entry.clipData.isOverflowScroll) {
    1280                 ScrollOffset scrollOffset = entry.clipData.clippingLayer->scrollOffset();
    1281 
    1282                 entry.clippingLayer->setBoundsOrigin(scrollOffset);
    1283                 lastClipLayerRect.moveBy(-scrollOffset);
    1284             } else
    1285                 entry.clippingLayer->setBoundsOrigin({ });
    1286         }
    1287 
    1288         parentGraphicsLayerRect = lastClipLayerRect;
    1289     }
     1273    if (m_ancestorClippingStack)
     1274        updateClippingStackLayerGeometry(*m_ancestorClippingStack, compositedAncestor, parentGraphicsLayerRect);
    12901275
    12911276    LayoutRect primaryGraphicsLayerRect = computePrimaryGraphicsLayerRect(compositedAncestor, parentGraphicsLayerRect);
     
    14721457}
    14731458
     1459void RenderLayerBacking::adjustOverflowControlsPositionRelativeToAncestor(const RenderLayer& ancestorLayer)
     1460{
     1461    ASSERT(m_overflowControlsContainer);
     1462    ASSERT(ancestorLayer.isComposited());
     1463    auto ancestorBacking = ancestorLayer.backing();
     1464    if (!ancestorBacking)
     1465        return;
     1466
     1467    LayoutRect parentGraphicsLayerRect = computeParentGraphicsLayerRect(&ancestorLayer);
     1468    LayoutRect primaryGraphicsLayerRect = computePrimaryGraphicsLayerRect(&ancestorLayer, parentGraphicsLayerRect);
     1469
     1470    auto overflowControlsRect = overflowControlsHostLayerRect(downcast<RenderBox>(renderer()));
     1471
     1472    if (overflowControlsHostLayerAncestorClippingStack())
     1473        updateClippingStackLayerGeometry(*m_overflowControlsHostLayerAncestorClippingStack, &ancestorLayer, parentGraphicsLayerRect);
     1474
     1475    ComputedOffsets rendererOffset(m_owningLayer, &ancestorLayer, { }, parentGraphicsLayerRect, primaryGraphicsLayerRect);
     1476
     1477    LayoutSize boxOffsetFromGraphicsLayer = toLayoutSize(overflowControlsRect.location()) + rendererOffset.fromParentGraphicsLayer();
     1478    SnappedRectInfo snappedBoxInfo = snappedGraphicsLayer(boxOffsetFromGraphicsLayer, overflowControlsRect.size(), deviceScaleFactor());
     1479
     1480    m_overflowControlsContainer->setPosition(snappedBoxInfo.m_snappedRect.location());
     1481}
     1482
    14741483void RenderLayerBacking::setLocationOfScrolledContents(ScrollOffset scrollOffset, ScrollingLayerPositionAction setOrSync)
    14751484{
     
    15731582    GraphicsLayer* lastClippingLayer = nullptr;
    15741583    if (m_ancestorClippingStack) {
    1575         auto& clippingStack = m_ancestorClippingStack->stack();
    1576         for (unsigned i = 0; i < clippingStack.size() - 1; ++i) {
    1577             auto& entry = clippingStack.at(i);
    1578             Vector<Ref<GraphicsLayer>> children;
    1579             children.append(*clippingStack.at(i + 1).clippingLayer);
    1580             entry.clippingLayer->setChildren(WTFMove(children));
    1581         }
    1582        
    1583         lastClippingLayer = clippingStack.last().clippingLayer.get();
    1584         lastClippingLayer->removeAllChildren();
    1585     }
    1586    
     1584        connectClippingStackLayers(*m_ancestorClippingStack);
     1585        lastClippingLayer = m_ancestorClippingStack->lastClippingLayer();
     1586    }
     1587
    15871588    if (m_contentsContainmentLayer) {
    15881589        m_contentsContainmentLayer->removeAllChildren();
     
    16201621            m_overflowControlsContainer->addChild(*m_layerForScrollCorner);
    16211622
     1623        // m_overflowControlsContainer may get reparented later.
    16221624        m_graphicsLayer->addChild(*m_overflowControlsContainer);
    16231625    }
     
    17901792        m_ancestorClippingStack->clear(scrollingCoordinator);
    17911793        m_ancestorClippingStack = nullptr;
     1794       
     1795        if (m_overflowControlsHostLayerAncestorClippingStack) {
     1796            m_overflowControlsHostLayerAncestorClippingStack->clear(scrollingCoordinator);
     1797            m_overflowControlsHostLayerAncestorClippingStack = nullptr;
     1798        }
    17921799        return true;
    17931800    }
     
    18061813    m_ancestorClippingStack->updateWithClipData(scrollingCoordinator, WTFMove(clippingData));
    18071814    LOG_WITH_STREAM(Compositing, stream << "layer " << &m_owningLayer << " ancestorClippingStack " << *m_ancestorClippingStack);
     1815    if (m_overflowControlsHostLayerAncestorClippingStack)
     1816        m_overflowControlsHostLayerAncestorClippingStack->updateWithClipData(scrollingCoordinator, WTFMove(clippingData));
    18081817    return true;
     1818}
     1819
     1820void RenderLayerBacking::ensureOverflowControlsHostLayerAncestorClippingStack(const RenderLayer* compositedAncestor)
     1821{
     1822    auto* scrollingCoordinator = m_owningLayer.page().scrollingCoordinator();
     1823    auto clippingData = m_ancestorClippingStack->compositedClipData();
     1824
     1825    if (m_overflowControlsHostLayerAncestorClippingStack)
     1826        m_overflowControlsHostLayerAncestorClippingStack->updateWithClipData(scrollingCoordinator, WTFMove(clippingData));
     1827    else
     1828        m_overflowControlsHostLayerAncestorClippingStack = makeUnique<LayerAncestorClippingStack>(WTFMove(clippingData));
     1829
     1830    ensureClippingStackLayers(*m_overflowControlsHostLayerAncestorClippingStack);
     1831
     1832    LayoutRect parentGraphicsLayerRect = computeParentGraphicsLayerRect(compositedAncestor);
     1833    updateClippingStackLayerGeometry(*m_overflowControlsHostLayerAncestorClippingStack, compositedAncestor, parentGraphicsLayerRect);
     1834
     1835    connectClippingStackLayers(*m_overflowControlsHostLayerAncestorClippingStack);
     1836}
     1837
     1838void RenderLayerBacking::ensureClippingStackLayers(LayerAncestorClippingStack& clippingStack)
     1839{
     1840    for (auto& entry : clippingStack.stack()) {
     1841        if (!entry.clippingLayer) {
     1842            entry.clippingLayer = createGraphicsLayer(entry.clipData.isOverflowScroll ? "clip for scroller" : "ancestor clipping");
     1843            entry.clippingLayer->setMasksToBounds(true);
     1844            entry.clippingLayer->setPaintingPhase({ });
     1845        }
     1846    }
     1847}
     1848
     1849void RenderLayerBacking::removeClippingStackLayers(LayerAncestorClippingStack& clippingStack)
     1850{
     1851    for (auto& entry : clippingStack.stack())
     1852        GraphicsLayer::unparentAndClear(entry.clippingLayer);
     1853}
     1854
     1855void RenderLayerBacking::connectClippingStackLayers(LayerAncestorClippingStack& clippingStack)
     1856{
     1857    auto& clippingEntryStack = clippingStack.stack();
     1858    for (unsigned i = 0; i < clippingEntryStack.size() - 1; ++i) {
     1859        auto& entry = clippingEntryStack.at(i);
     1860        Vector<Ref<GraphicsLayer>> children;
     1861        children.append(*clippingEntryStack.at(i + 1).clippingLayer);
     1862        entry.clippingLayer->setChildren(WTFMove(children));
     1863    }
     1864
     1865    clippingEntryStack.last().clippingLayer->removeAllChildren();
     1866}
     1867
     1868void RenderLayerBacking::updateClippingStackLayerGeometry(LayerAncestorClippingStack& clippingStack, const RenderLayer* compositedAncestor, LayoutRect& parentGraphicsLayerRect)
     1869{
     1870    // All clipRects in the stack are computed relative to m_owningLayer, so convert them back to compositedAncestor.
     1871    auto offsetFromCompositedAncestor = toLayoutSize(m_owningLayer.convertToLayerCoords(compositedAncestor, { }, RenderLayer::AdjustForColumns));
     1872    LayoutRect lastClipLayerRect = parentGraphicsLayerRect;
     1873
     1874    auto deviceScaleFactor = this->deviceScaleFactor();
     1875    for (auto& entry : clippingStack.stack()) {
     1876        auto clipRect = entry.clipData.clipRect;
     1877        LayoutSize clippingOffset = computeOffsetFromAncestorGraphicsLayer(compositedAncestor, clipRect.location() + offsetFromCompositedAncestor, deviceScaleFactor);
     1878        LayoutRect snappedClippingLayerRect = snappedGraphicsLayer(clippingOffset, clipRect.size(), deviceScaleFactor).m_snappedRect;
     1879
     1880        entry.clippingLayer->setPosition(toLayoutPoint(snappedClippingLayerRect.location() - lastClipLayerRect.location()));
     1881        lastClipLayerRect = snappedClippingLayerRect;
     1882
     1883        entry.clippingLayer->setSize(snappedClippingLayerRect.size());
     1884
     1885        if (entry.clipData.isOverflowScroll) {
     1886            ScrollOffset scrollOffset = entry.clipData.clippingLayer->scrollOffset();
     1887
     1888            entry.clippingLayer->setBoundsOrigin(scrollOffset);
     1889            lastClipLayerRect.moveBy(-scrollOffset);
     1890        } else
     1891            entry.clippingLayer->setBoundsOrigin({ });
     1892    }
     1893
     1894    parentGraphicsLayerRect = lastClipLayerRect;
    18091895}
    18101896
     
    18161902    if (needsAncestorClip) {
    18171903        if (compositor().updateAncestorClippingStack(m_owningLayer, compositingAncestor)) {
    1818             // Make any layers we don't have.
    1819             if (m_ancestorClippingStack) {
    1820                 for (auto& entry : m_ancestorClippingStack->stack()) {
    1821                     if (!entry.clippingLayer) {
    1822                         entry.clippingLayer = createGraphicsLayer(entry.clipData.isOverflowScroll ? "clip for scroller" : "ancestor clipping");
    1823                         entry.clippingLayer->setMasksToBounds(true);
    1824                         entry.clippingLayer->setPaintingPhase({ });
    1825                     }
    1826                 }
    1827             }
     1904            if (m_ancestorClippingStack)
     1905                ensureClippingStackLayers(*m_ancestorClippingStack);
    18281906
    18291907            layersChanged = true;
    18301908        }
    18311909    } else if (m_ancestorClippingStack) {
    1832         for (auto& entry : m_ancestorClippingStack->stack())
    1833             GraphicsLayer::unparentAndClear(entry.clippingLayer);
     1910        removeClippingStackLayers(*m_ancestorClippingStack);
    18341911
    18351912        m_ancestorClippingStack = nullptr;
     
    28532930   
    28542931    return m_graphicsLayer.get();
     2932}
     2933
     2934LayoutSize RenderLayerBacking::offsetRelativeToRendererOriginForDescendantLayers() const
     2935{
     2936    if (m_scrolledContentsLayer)
     2937        return toLayoutSize(scrollContainerLayerBox(downcast<RenderBox>(renderer())).location());
     2938
     2939    if (hasClippingLayer())
     2940        return toLayoutSize(clippingLayerBox(downcast<RenderBox>(renderer())).location());
     2941
     2942    return { };
    28552943}
    28562944
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r265289 r266825  
    115115    bool updateAncestorClippingStack(Vector<CompositedClipData>&&);
    116116
     117    void ensureOverflowControlsHostLayerAncestorClippingStack(const RenderLayer* compositedAncestor);
     118    LayerAncestorClippingStack* overflowControlsHostLayerAncestorClippingStack() const { return m_overflowControlsHostLayerAncestorClippingStack.get(); }
     119
    117120    GraphicsLayer* contentsContainmentLayer() const { return m_contentsContainmentLayer.get(); }
    118121
     
    271274    GraphicsLayer* overflowControlsContainer() const { return m_overflowControlsContainer.get(); }
    272275
     276    void adjustOverflowControlsPositionRelativeToAncestor(const RenderLayer&);
     277
    273278    bool canCompositeFilters() const { return m_canCompositeFilters; }
    274279#if ENABLE(FILTERS_LEVEL_2)
     
    332337    FloatPoint3D computeTransformOriginForPainting(const LayoutRect& borderBox) const;
    333338
     339    LayoutSize offsetRelativeToRendererOriginForDescendantLayers() const;
     340   
     341    void ensureClippingStackLayers(LayerAncestorClippingStack&);
     342    void removeClippingStackLayers(LayerAncestorClippingStack&);
     343
     344    void updateClippingStackLayerGeometry(LayerAncestorClippingStack&, const RenderLayer* compositedAncestor, LayoutRect& parentGraphicsLayerRect);
     345
     346    void connectClippingStackLayers(LayerAncestorClippingStack&);
     347
    334348    void updateOpacity(const RenderStyle&);
    335349    void updateTransform(const RenderStyle&);
     
    400414
    401415    std::unique_ptr<LayerAncestorClippingStack> m_ancestorClippingStack; // Only used if we are clipped by an ancestor which is not a stacking context.
     416    std::unique_ptr<LayerAncestorClippingStack> m_overflowControlsHostLayerAncestorClippingStack; // Used when we have an overflow controls host layer which was reparented, and needs clipping by ancestors.
    402417
    403418    RefPtr<GraphicsLayer> m_contentsContainmentLayer; // Only used if we have a background layer; takes the transform.
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r266342 r266825  
    212212
    213213struct RenderLayerCompositor::UpdateBackingTraversalState {
    214 
    215     UpdateBackingTraversalState(RenderLayer* compAncestor = nullptr)
     214    UpdateBackingTraversalState(RenderLayer* compAncestor = nullptr, Vector<RenderLayer*>* clippedLayers = nullptr, Vector<RenderLayer*>* overflowScrollers = nullptr)
    216215        : compositingAncestor(compAncestor)
     216        , layersClippedByScrollers(clippedLayers)
     217        , overflowScrollLayers(overflowScrollers)
    217218    {
    218219    }
     
    220221    UpdateBackingTraversalState stateForDescendants() const
    221222    {
    222         UpdateBackingTraversalState state(compositingAncestor);
     223        UpdateBackingTraversalState state(compositingAncestor, layersClippedByScrollers, overflowScrollLayers);
    223224#if !LOG_DISABLED
    224225        state.depth = depth + 1;
     
    228229
    229230    RenderLayer* compositingAncestor;
     231
     232    // List of layers in the current stacking context that are clipped by ancestor scrollers.
     233    Vector<RenderLayer*>* layersClippedByScrollers;
     234    // List of layers with composited overflow:scroll.
     235    Vector<RenderLayer*>* overflowScrollLayers;
     236
    230237#if !LOG_DISABLED
    231238    unsigned depth { 0 };
     
    12631270    ScrollingTreeState scrollingStateForDescendants = scrollingTreeState;
    12641271    UpdateBackingTraversalState traversalStateForDescendants = traversalState.stateForDescendants();
    1265 
     1272    Vector<RenderLayer*> layersClippedByScrollers;
     1273    Vector<RenderLayer*> compositedOverflowScrollLayers;
     1274   
    12661275    if (layer.needsScrollingTreeUpdate())
    12671276        scrollingTreeState.needSynchronousScrollingReasonsUpdate = true;
     
    13121321       
    13131322        traversalStateForDescendants.compositingAncestor = &layer;
     1323        traversalStateForDescendants.layersClippedByScrollers = &layersClippedByScrollers;
     1324        traversalStateForDescendants.overflowScrollLayers = &compositedOverflowScrollLayers;
    13141325
    13151326#if !LOG_DISABLED
     
    13771388                }
    13781389
     1390                adjustOverflowScrollbarContainerLayers(layer, compositedOverflowScrollLayers, layersClippedByScrollers, layerChildren);
    13791391                layerBacking->parentForSublayers()->setChildren(WTFMove(layerChildren));
    13801392            }
     
    13831395        childLayersOfEnclosingLayer.append(*layerBacking->childForSuperlayers());
    13841396
     1397        if (layerBacking->hasAncestorClippingLayers() && layerBacking->ancestorClippingStack()->hasAnyScrollingLayers())
     1398            traversalState.layersClippedByScrollers->append(&layer);
     1399
     1400        if (layer.hasCompositedScrollableOverflow())
     1401            traversalState.overflowScrollLayers->append(&layer);
     1402
    13851403        layerBacking->updateAfterDescendants();
    13861404    }
    13871405   
    13881406    layer.clearUpdateBackingOrHierarchyTraversalState();
     1407}
     1408
     1409// Finds the set of overflow:scroll layers whose overflow controls hosting layer needs to be reparented,
     1410// to ensure that the scrollbars show on top of positioned content inside the scroller.
     1411void RenderLayerCompositor::adjustOverflowScrollbarContainerLayers(RenderLayer& stackingContextLayer, const Vector<RenderLayer*>& overflowScrollLayers, const Vector<RenderLayer*>& layersClippedByScrollers, Vector<Ref<GraphicsLayer>>& layerChildren)
     1412{
     1413    if (layersClippedByScrollers.isEmpty())
     1414        return;
     1415
     1416    HashMap<RenderLayer*, RenderLayer*> overflowScrollToLastContainedLayerMap;
     1417
     1418    for (auto* clippedLayer : layersClippedByScrollers) {
     1419        auto* clippingStack = clippedLayer->backing()->ancestorClippingStack();
     1420
     1421        for (const auto& stackEntry : clippingStack->stack()) {
     1422            if (!stackEntry.clipData.isOverflowScroll)
     1423                continue;
     1424
     1425            if (auto* layer = stackEntry.clipData.clippingLayer.get())
     1426                overflowScrollToLastContainedLayerMap.set(layer, clippedLayer);
     1427        }
     1428    }
     1429
     1430    for (auto* overflowScrollingLayer : overflowScrollLayers) {
     1431        auto it = overflowScrollToLastContainedLayerMap.find(overflowScrollingLayer);
     1432        if (it == overflowScrollToLastContainedLayerMap.end())
     1433            continue;
     1434   
     1435        auto* lastContainedDescendant = it->value;
     1436        if (!lastContainedDescendant || !lastContainedDescendant->isComposited())
     1437            continue;
     1438
     1439        auto* lastContainedDescendantBacking = lastContainedDescendant->backing();
     1440        auto* overflowBacking = overflowScrollingLayer->backing();
     1441        if (!overflowBacking)
     1442            continue;
     1443       
     1444        auto* overflowContainerLayer = overflowBacking->overflowControlsContainer();
     1445        if (!overflowContainerLayer)
     1446            continue;
     1447
     1448        LOG_WITH_STREAM(Compositing, stream << "Moving overflow controls layer for " << overflowScrollingLayer << " to appear after " << lastContainedDescendant);
     1449
     1450        overflowContainerLayer->removeFromParent();
     1451
     1452        if (overflowBacking->hasAncestorClippingLayers())
     1453            overflowBacking->ensureOverflowControlsHostLayerAncestorClippingStack(&stackingContextLayer);
     1454
     1455        if (auto* overflowControlsAncestorClippingStack = overflowBacking->overflowControlsHostLayerAncestorClippingStack()) {
     1456            Vector<Ref<GraphicsLayer>> children;
     1457            children.append(*overflowContainerLayer);
     1458            overflowControlsAncestorClippingStack->lastClippingLayer()->setChildren(WTFMove(children));
     1459            overflowContainerLayer = overflowControlsAncestorClippingStack->firstClippingLayer();
     1460        }
     1461
     1462        auto* lastDescendantGraphicsLayer = lastContainedDescendantBacking->childForSuperlayers();
     1463        auto lastDescendantIndex = layerChildren.findMatching([&](auto& item) {
     1464            return item.ptr() == lastDescendantGraphicsLayer;
     1465        });
     1466
     1467        if (lastDescendantIndex != notFound)
     1468            layerChildren.insert(lastDescendantIndex + 1, *overflowContainerLayer);
     1469
     1470        overflowBacking->adjustOverflowControlsPositionRelativeToAncestor(stackingContextLayer);
     1471    }
    13891472}
    13901473
     
    46644747        }
    46654748    }
     4749   
     4750    // FIXME: also m_overflowControlsHostLayerAncestorClippingStack
    46664751
    46674752    if (!nodeID)
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r266342 r266825  
    445445    void updateBackingAndHierarchy(RenderLayer&, Vector<Ref<GraphicsLayer>>& childGraphicsLayersOfEnclosingLayer, struct UpdateBackingTraversalState&, struct ScrollingTreeState&, OptionSet<UpdateLevel> = { });
    446446
     447    void adjustOverflowScrollbarContainerLayers(RenderLayer& stackingContextLayer, const Vector<RenderLayer*>& overflowScrollLayers, const Vector<RenderLayer*>& layersClippedByScrollers, Vector<Ref<GraphicsLayer>>&);
     448
    447449    bool layerHas3DContent(const RenderLayer&) const;
    448450    bool isRunningTransformAnimation(RenderLayerModelObject&) const;
Note: See TracChangeset for help on using the changeset viewer.