Changeset 279748 in webkit


Ignore:
Timestamp:
Jul 8, 2021 1:29:32 PM (13 months ago)
Author:
Simon Fraser
Message:

Scrollbar hidden when scroller has a negative z-index child
https://bugs.webkit.org/show_bug.cgi?id=227545

Reviewed by Alan Bujtas.
Source/WebCore:

The code to ensure that overflow:scroll scrollbars appeared on top of composited descendant
layers had incorrect behavior if the only descendant had negative z-index; it would move the
overflow controls container layer to be after that descendant, and thus behind foreground
content.

Fix by inserting the overflow controls container layer in front of the frontmost of the
descendant and the scroller itself.

Test: compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::adjustOverflowScrollbarContainerLayers):

LayoutTests:

  • compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt: Rebaseline
  • compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar-expected.html: Added.
  • compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r279742 r279748  
     12021-07-08  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Scrollbar hidden when scroller has a negative z-index child
     4        https://bugs.webkit.org/show_bug.cgi?id=227545
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt: Rebaseline
     9        * compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar-expected.html: Added.
     10        * compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html: Added.
     11
    1122021-07-08  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
    213
  • trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt

    r278883 r279748  
    2020                  (bounds 200.00 200.00)
    2121                  (contentsOpaque 1)
    22                 )
    23               )
    24             )
    25             (GraphicsLayer
    26               (position 9.00 9.00)
    27               (bounds 300.00 300.00)
    28               (clips 1)
    29               (children 1
    30                 (GraphicsLayer
    31                   (position 285.00 0.00)
    32                   (bounds 15.00 300.00)
    33                   (drawsContent 1)
    3422                )
    3523              )
     
    5947              )
    6048            )
     49            (GraphicsLayer
     50              (position 9.00 9.00)
     51              (bounds 300.00 300.00)
     52              (clips 1)
     53              (children 1
     54                (GraphicsLayer
     55                  (position 285.00 0.00)
     56                  (bounds 15.00 300.00)
     57                  (drawsContent 1)
     58                )
     59              )
     60            )
    6161          )
    6262        )
  • trunk/Source/WebCore/ChangeLog

    r279742 r279748  
     12021-07-08  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Scrollbar hidden when scroller has a negative z-index child
     4        https://bugs.webkit.org/show_bug.cgi?id=227545
     5
     6        Reviewed by Alan Bujtas.
     7       
     8        The code to ensure that overflow:scroll scrollbars appeared on top of composited descendant
     9        layers had incorrect behavior if the only descendant had negative z-index; it would move the
     10        overflow controls container layer to be after that descendant, and thus behind foreground
     11        content.
     12
     13        Fix by inserting the overflow controls container layer in front of the frontmost of the
     14        descendant and the scroller itself.
     15
     16        Test: compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html
     17
     18        * rendering/RenderLayerCompositor.cpp:
     19        (WebCore::RenderLayerCompositor::adjustOverflowScrollbarContainerLayers):
     20
    1212021-07-08  Yoshiaki Jitsukawa  <yoshiaki.jitsukawa@sony.com>
    222
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r279636 r279748  
    14851485            continue;
    14861486
    1487         LOG_WITH_STREAM(Compositing, stream << "Moving overflow controls layer for " << overflowScrollingLayer << " to appear after " << lastContainedDescendant);
    1488 
    14891487        overflowContainerLayer->removeFromParent();
    14901488
     
    15001498
    15011499        auto* lastDescendantGraphicsLayer = lastContainedDescendantBacking->childForSuperlayers();
    1502         auto lastDescendantIndex = layerChildren.findMatching([&](auto& item) {
    1503             return item.ptr() == lastDescendantGraphicsLayer;
    1504         });
    1505 
    1506         if (lastDescendantIndex != notFound)
    1507             layerChildren.insert(lastDescendantIndex + 1, *overflowContainerLayer);
     1500        auto* overflowScrollerGraphicsLayer = overflowBacking->childForSuperlayers();
     1501       
     1502        std::optional<size_t> lastDescendantLayerIndex;
     1503        std::optional<size_t> scrollerLayerIndex;
     1504        for (size_t i = 0; i < layerChildren.size(); ++i) {
     1505            const auto* graphicsLayer = layerChildren[i].ptr();
     1506            if (graphicsLayer == lastDescendantGraphicsLayer)
     1507                lastDescendantLayerIndex = i;
     1508            else if (graphicsLayer == overflowScrollerGraphicsLayer)
     1509                scrollerLayerIndex = i;
     1510        }
     1511
     1512        if (lastDescendantLayerIndex && scrollerLayerIndex) {
     1513            auto insertionIndex = std::max(lastDescendantLayerIndex.value() + 1, scrollerLayerIndex.value() + 1);
     1514            LOG_WITH_STREAM(Compositing, stream << "Moving overflow controls layer for " << overflowScrollingLayer << " to appear after " << lastContainedDescendant);
     1515            layerChildren.insert(insertionIndex, *overflowContainerLayer);
     1516        }
    15081517
    15091518        overflowBacking->adjustOverflowControlsPositionRelativeToAncestor(stackingContextLayer);
Note: See TracChangeset for help on using the changeset viewer.