Create scrolling tree nodes for descendants of position:absolute inside stacking...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 15:48:52 +0000 (15:48 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 15:48:52 +0000 (15:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198154

Reviewed by Antti Koivisto.
Source/WebCore:

There exists code that creates scrolling tree nodes for position:absolute when the containing block
chain skips an enclosing scroller, but the compositing ancestor tree includes the scroller. However
this code explicitly checked that the layer was position:absolute.

This needed to be generalized for any layer whose containing block ancestor chain includes
a position:absolute that skips the scroller, for example a transformed inside a position:absolute,
so remove an explicit isAbsolutelyPositioned() check and some similar assertions.

Test: scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::collectStationaryLayerRelatedOverflowNodes):
(WebCore::RenderLayerCompositor::computeCoordinatedPositioningForLayer const):
(WebCore::collectRelatedCoordinatedScrollingNodes):

LayoutTests:

* platform/ios-wk2/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt: Copied from LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt.
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt:
* scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt: Copied from LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt.
* scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt
LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt [new file with mode: 0644]
LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 503e259..8a36d28 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Create scrolling tree nodes for descendants of position:absolute inside stacking-context overflow
+        https://bugs.webkit.org/show_bug.cgi?id=198154
+
+        Reviewed by Antti Koivisto.
+
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt: Copied from LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt.
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt:
+        * scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt: Copied from LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt.
+        * scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt:
+
 2019-05-23  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [WHLSL] Implement property resolver
diff --git a/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt b/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt
new file mode 100644 (file)
index 0000000..14f4bfc
--- /dev/null
@@ -0,0 +1,43 @@
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 1)
+    (vertical scroll elasticity 1)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 300 300)
+      (contents size 300 1000)
+      (parent relative scrollable rect at (30,22) size 300x300)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 1)
+        (vertical scroll elasticity 1)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+      (children 2
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (20,28))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (40,48))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+      )
+    )
+  )
+)
+
index 45cb0eb..208a7bd 100644 (file)
@@ -25,7 +25,7 @@ abs
         (horizontal scrollbar mode 0)
         (vertical scrollbar mode 0)
         (has enabled vertical scrollbar 1))
-      (children 2
+      (children 3
         (Positioned node
           (layout constraints 
             (layer-position-at-last-layout (20,28))
@@ -34,6 +34,12 @@ abs
         )
         (Positioned node
           (layout constraints 
+            (layer-position-at-last-layout (32,60))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
             (layer-position-at-last-layout (47,55))
             (positioning-behavior stationary))
           (related overflow nodes 1)
diff --git a/LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt b/LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow-expected.txt
new file mode 100644 (file)
index 0000000..b11f860
--- /dev/null
@@ -0,0 +1,43 @@
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 2)
+    (vertical scroll elasticity 2)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 285 285)
+      (contents size 285 1000)
+      (parent relative scrollable rect at (30,22) size 285x285)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 0)
+        (vertical scroll elasticity 0)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+      (children 2
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (20,28))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (40,48))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html b/LayoutTests/scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html
new file mode 100644 (file)
index 0000000..49f48a8
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Tests that we make a scrolling tree node for composited layers nested inside position:absolute in a stacking-context scroller</title>
+    <style>
+        .scroller {
+            overflow: scroll;
+            margin: 20px;
+            height: 300px;
+            width: 300px;
+            border: 2px solid black;
+            opacity: 0.9;
+        }
+
+        .absolute {
+            position:absolute;
+            left: 50px;
+            top: 50px;
+            width: 200px;
+            height: 120px;
+            padding: 20px;
+            background: gray;
+        }
+        
+        .composited {
+            transform: translateZ(0);
+            width: 100px;
+            height: 100px;
+            background-color: green;
+        }
+        
+        .spacer {
+            height: 500px;
+            width: 10px;
+            background-image: repeating-linear-gradient(to bottom, white, silver 200px);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.internals)
+                document.getElementById('tree').innerText = internals.scrollingStateTreeAsText();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scroller">
+        <div class="spacer"></div>
+        <div class="absolute">
+            <div class="composited box"></div>
+        </div>
+        <div class="spacer"></div>
+    </div>
+<pre id="tree"></pre>
+</body>
+</html>
index 80aeb63..f5913a7 100644 (file)
@@ -25,7 +25,7 @@ abs
         (horizontal scrollbar mode 0)
         (vertical scrollbar mode 0)
         (has enabled vertical scrollbar 1))
-      (children 2
+      (children 3
         (Positioned node
           (layout constraints 
             (layer-position-at-last-layout (20,28))
@@ -34,6 +34,12 @@ abs
         )
         (Positioned node
           (layout constraints 
+            (layer-position-at-last-layout (32,58))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
             (layer-position-at-last-layout (47,55))
             (positioning-behavior stationary))
           (related overflow nodes 1)
index 68cad6e..0436aa1 100644 (file)
@@ -1,3 +1,25 @@
+2019-05-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Create scrolling tree nodes for descendants of position:absolute inside stacking-context overflow
+        https://bugs.webkit.org/show_bug.cgi?id=198154
+
+        Reviewed by Antti Koivisto.
+        
+        There exists code that creates scrolling tree nodes for position:absolute when the containing block
+        chain skips an enclosing scroller, but the compositing ancestor tree includes the scroller. However
+        this code explicitly checked that the layer was position:absolute.
+
+        This needed to be generalized for any layer whose containing block ancestor chain includes
+        a position:absolute that skips the scroller, for example a transformed inside a position:absolute,
+        so remove an explicit isAbsolutelyPositioned() check and some similar assertions.
+
+        Test: scrollingcoordinator/scrolling-tree/composited-in-absolute-in-stacking-context-overflow.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::collectStationaryLayerRelatedOverflowNodes):
+        (WebCore::RenderLayerCompositor::computeCoordinatedPositioningForLayer const):
+        (WebCore::collectRelatedCoordinatedScrollingNodes):
+
 2019-05-23  Adrian Perez de Castro  <aperez@igalia.com>
 
         Fix a few missing header inclusions often masked by by unified sources
index 1c61b49..cae45f8 100644 (file)
@@ -3110,8 +3110,6 @@ static void collectStationaryLayerRelatedOverflowNodes(const RenderLayer& layer,
             LOG(Scrolling, "Layer %p doesn't have scrolling node ID yet", &overflowLayer);
     };
 
-    ASSERT(layer.renderer().isAbsolutelyPositioned());
-
     // Collect all the composited scrollers which affect the position of this layer relative to its compositing ancestor (which might be inside the scroller or the scroller itself).
     bool seenPaintOrderAncestor = false;
     traverseAncestorLayers(layer, [&](const RenderLayer& ancestorLayer, bool isContainingBlockChain, bool isPaintOrderAncestor) {
@@ -3147,8 +3145,8 @@ ScrollPositioningBehavior RenderLayerCompositor::computeCoordinatedPositioningFo
         return ScrollPositioningBehavior::None;
     }
 
-    bool compositedAncestorIsInsideScroller = false;
-    auto* scrollingAncestor = enclosingCompositedScrollingLayer(layer, *compositedAncestor, compositedAncestorIsInsideScroller);
+    bool compositedAncestorIsScrolling = false;
+    auto* scrollingAncestor = enclosingCompositedScrollingLayer(layer, *compositedAncestor, compositedAncestorIsScrolling);
     if (!scrollingAncestor) {
         ASSERT_NOT_REACHED(); // layer.hasCompositedScrollingAncestor() should guarantee we have one.
         return ScrollPositioningBehavior::None;
@@ -3157,16 +3155,14 @@ ScrollPositioningBehavior RenderLayerCompositor::computeCoordinatedPositioningFo
     // There are two cases we have to deal with here:
     // 1. There's a composited overflow:scroll in the parent chain between the renderer and its containing block, and the layer's
     //    composited (z-order) ancestor is inside the scroller or is the scroller. In this case, we have to compensate for scroll position
-    //    changes to make the positioned layer stay in the same place. This only applies to position:absolute (since we handle fixed elsewhere).
-    if (layer.renderer().isAbsolutelyPositioned()) {
-        if (compositedAncestorIsInsideScroller && isNonScrolledLayerInsideScrolledCompositedAncestor(layer, *compositedAncestor, *scrollingAncestor))
-            return ScrollPositioningBehavior::Stationary;
-    }
+    //    changes to make the positioned layer stay in the same place. This only applies to position:absolute or descendants of position:absolute.
+    if (compositedAncestorIsScrolling && isNonScrolledLayerInsideScrolledCompositedAncestor(layer, *compositedAncestor, *scrollingAncestor))
+        return ScrollPositioningBehavior::Stationary;
 
     // 2. The layer's containing block is the overflow or inside the overflow:scroll, but its z-order ancestor is
     //    outside the overflow:scroll. In that case, we have to move the layer via the scrolling tree to make
     //    it move along with the overflow scrolling.
-    if (!compositedAncestorIsInsideScroller && isScrolledByOverflowScrollLayer(layer, *scrollingAncestor))
+    if (!compositedAncestorIsScrolling && isScrolledByOverflowScrollLayer(layer, *scrollingAncestor))
         return ScrollPositioningBehavior::Moves;
 
     return ScrollPositioningBehavior::None;
@@ -3192,7 +3188,6 @@ static Vector<ScrollingNodeID> collectRelatedCoordinatedScrollingNodes(const Ren
         break;
     }
     case ScrollPositioningBehavior::Stationary: {
-        ASSERT(layer.renderer().isAbsolutelyPositioned());
         auto* compositedAncestor = layer.ancestorCompositingLayer();
         if (!compositedAncestor)
             return overflowNodeData;