Title: [279748] trunk
Revision
279748
Author
simon.fra...@apple.com
Date
2021-07-08 13:29:32 -0700 (Thu, 08 Jul 2021)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279747 => 279748)


--- trunk/LayoutTests/ChangeLog	2021-07-08 20:27:22 UTC (rev 279747)
+++ trunk/LayoutTests/ChangeLog	2021-07-08 20:29:32 UTC (rev 279748)
@@ -1,3 +1,14 @@
+2021-07-08  Simon Fraser  <simon.fra...@apple.com>
+
+        Scrollbar hidden when scroller has a negative z-index child
+        https://bugs.webkit.org/show_bug.cgi?id=227545
+
+        Reviewed by Alan Bujtas.
+
+        * 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.
+
 2021-07-08  Yoshiaki Jitsukawa  <yoshiaki.jitsuk...@sony.com>
 
         [OpenSSL] Implement HKDF and PBKDF2 support

Modified: trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt (279747 => 279748)


--- trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt	2021-07-08 20:27:22 UTC (rev 279747)
+++ trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/layer-for-negative-z-in-scroller-expected.txt	2021-07-08 20:29:32 UTC (rev 279748)
@@ -23,18 +23,6 @@
               )
             )
             (GraphicsLayer
-              (position 9.00 9.00)
-              (bounds 300.00 300.00)
-              (clips 1)
-              (children 1
-                (GraphicsLayer
-                  (position 285.00 0.00)
-                  (bounds 15.00 300.00)
-                  (drawsContent 1)
-                )
-              )
-            )
-            (GraphicsLayer
               (bounds 800.00 600.00)
             )
             (GraphicsLayer
@@ -58,6 +46,18 @@
                 )
               )
             )
+            (GraphicsLayer
+              (position 9.00 9.00)
+              (bounds 300.00 300.00)
+              (clips 1)
+              (children 1
+                (GraphicsLayer
+                  (position 285.00 0.00)
+                  (bounds 15.00 300.00)
+                  (drawsContent 1)
+                )
+              )
+            )
           )
         )
       )

Added: trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar-expected.html (0 => 279748)


--- trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar-expected.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar-expected.html	2021-07-08 20:29:32 UTC (rev 279748)
@@ -0,0 +1,29 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ] -->
+<head>
+    <style>
+        .scroller {
+            position: relative;
+            height: 300px;
+            width: 300px;
+            margin: 20px;
+            border: 1px solid black;
+            background-color: red;
+            overflow-y: scroll;
+        }
+        .content {
+            background-color: white;
+        }
+        .filler {
+            width: 10px;
+            height: 1100px;
+        }
+    </style>
+</head>
+<body>
+<div class="scroller">
+    <div class="content">
+        <div class="filler"></div>
+    </div>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html (0 => 279748)


--- trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/scrolling/async-overflow-scrolling/negative-z-in-scroller-hidden-scrollbar.html	2021-07-08 20:29:32 UTC (rev 279748)
@@ -0,0 +1,37 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ] -->
+<head>
+    <style>
+        .scroller {
+            position: relative;
+            height: 300px;
+            width: 300px;
+            margin: 20px;
+            border: 1px solid black;
+            background-color: red;
+            overflow-y: scroll;
+        }
+        .content {
+            background-color: white;
+        }
+        .filler {
+            width: 10px;
+            height: 1000px;
+        }
+        .negative {
+            position: relative;
+            width: 100px;
+            height: 100px;
+            z-index: -1;
+            background-color: gray;
+        }
+    </style>
+</head>
+<body>
+<div class="scroller">
+    <div class="content">
+        <div class="negative"></div>
+        <div class="filler"></div>
+    </div>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (279747 => 279748)


--- trunk/Source/WebCore/ChangeLog	2021-07-08 20:27:22 UTC (rev 279747)
+++ trunk/Source/WebCore/ChangeLog	2021-07-08 20:29:32 UTC (rev 279748)
@@ -1,3 +1,23 @@
+2021-07-08  Simon Fraser  <simon.fra...@apple.com>
+
+        Scrollbar hidden when scroller has a negative z-index child
+        https://bugs.webkit.org/show_bug.cgi?id=227545
+
+        Reviewed by Alan Bujtas.
+        
+        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):
+
 2021-07-08  Yoshiaki Jitsukawa  <yoshiaki.jitsuk...@sony.com>
 
         [OpenSSL] Implement HKDF and PBKDF2 support

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (279747 => 279748)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2021-07-08 20:27:22 UTC (rev 279747)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2021-07-08 20:29:32 UTC (rev 279748)
@@ -1484,8 +1484,6 @@
         if (!overflowContainerLayer)
             continue;
 
-        LOG_WITH_STREAM(Compositing, stream << "Moving overflow controls layer for " << overflowScrollingLayer << " to appear after " << lastContainedDescendant);
-
         overflowContainerLayer->removeFromParent();
 
         if (overflowBacking->hasAncestorClippingLayers())
@@ -1499,12 +1497,23 @@
         }
 
         auto* lastDescendantGraphicsLayer = lastContainedDescendantBacking->childForSuperlayers();
-        auto lastDescendantIndex = layerChildren.findMatching([&](auto& item) {
-            return item.ptr() == lastDescendantGraphicsLayer;
-        });
+        auto* overflowScrollerGraphicsLayer = overflowBacking->childForSuperlayers();
+        
+        std::optional<size_t> lastDescendantLayerIndex;
+        std::optional<size_t> scrollerLayerIndex;
+        for (size_t i = 0; i < layerChildren.size(); ++i) {
+            const auto* graphicsLayer = layerChildren[i].ptr();
+            if (graphicsLayer == lastDescendantGraphicsLayer)
+                lastDescendantLayerIndex = i;
+            else if (graphicsLayer == overflowScrollerGraphicsLayer)
+                scrollerLayerIndex = i;
+        }
 
-        if (lastDescendantIndex != notFound)
-            layerChildren.insert(lastDescendantIndex + 1, *overflowContainerLayer);
+        if (lastDescendantLayerIndex && scrollerLayerIndex) {
+            auto insertionIndex = std::max(lastDescendantLayerIndex.value() + 1, scrollerLayerIndex.value() + 1);
+            LOG_WITH_STREAM(Compositing, stream << "Moving overflow controls layer for " << overflowScrollingLayer << " to appear after " << lastContainedDescendant);
+            layerChildren.insert(insertionIndex, *overflowContainerLayer);
+        }
 
         overflowBacking->adjustOverflowControlsPositionRelativeToAncestor(stackingContextLayer);
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to