Track "scrolling scope" on RenderLayers
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2020 03:26:03 +0000 (03:26 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2020 03:26:03 +0000 (03:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208620

Reviewed by Zalan Bujtas.
Source/WebCore:

The scrolling scope code added in r257920 failed to recompute m_contentsScrollingScope
when hasCompositedScrollableOverflow() changed, causing bugs on gmail.

Recompute the m_contentsScrollingScope to match or not match the m_boxScrollingScope
based on whether the layer is composited-scrollable.

Test: fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
* rendering/RenderLayerCompositor.cpp:
(WebCore::isScrolledByOverflowScrollLayer):

LayoutTests:

* fast/scrolling/mac/absolute-in-overflow-scroll-dynamic-expected.html: Added.
* fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html: Added.
* fast/scrolling/mac/absolute-in-overflow-scroll.html: Fix typo.

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

LayoutTests/ChangeLog
LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic-expected.html [new file with mode: 0644]
LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html [new file with mode: 0644]
LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll.html
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp

index aaddaa4..a8d4f98 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-10  Simon Fraser  <simon.fraser@apple.com>
+
+        Track "scrolling scope" on RenderLayers
+        https://bugs.webkit.org/show_bug.cgi?id=208620
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/scrolling/mac/absolute-in-overflow-scroll-dynamic-expected.html: Added.
+        * fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html: Added.
+        * fast/scrolling/mac/absolute-in-overflow-scroll.html: Fix typo.
+
 2020-03-10  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(iOS): editing/selection/ios/selection-after-changing-text-with-callout-menu.html intermittently fails
diff --git a/LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic-expected.html b/LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic-expected.html
new file mode 100644 (file)
index 0000000..7ae6dbf
--- /dev/null
@@ -0,0 +1,70 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+        .container {
+            position: absolute; /* Containing block for the inner absolute */
+            top: 10px;
+            left: 10px;
+        }
+        .scroller {
+            height: 300px;
+            width: 300px;
+            border: 20px solid gray;
+            padding: 5px;
+            overflow: scroll;
+            opacity: 0.8; /* Force stacking context */
+        }
+        
+        .content {
+            width: 200%;
+            height: 300%;
+        }
+        
+        .absolute {
+            position: absolute;
+            top: 100px;
+            left: 50px;
+            height: 200px;
+            width: 200px;
+            background-color: green;
+        }
+    </style>
+    <script src="../../../resources/ui-helper.js"></script>
+    <script>
+        async function scrollOverContent()
+        {
+            await UIHelper.mouseWheelScrollAt(50, 50);
+        }
+
+        async function scrollTest()
+        {
+            await scrollOverContent();
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }
+        
+        async function doTest()
+        {
+            document.body.offsetWidth;
+            document.body.classList.add('changed');
+            setTimeout(scrollTest, 0);
+        }
+
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div class="container">
+        <div class="scroller">
+            <div class="content">
+                <div class="absolute">
+                </div>
+            </div>
+        </div>
+    </div>
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html b/LayoutTests/fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html
new file mode 100644 (file)
index 0000000..40d389d
--- /dev/null
@@ -0,0 +1,74 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+        .container {
+            position: absolute; /* Containing block for the inner absolute */
+            top: 10px;
+            left: 10px;
+        }
+        .scroller {
+            height: 300px;
+            width: 300px;
+            border: 20px solid gray;
+            padding: 5px;
+            overflow: hidden;
+            opacity: 0.8; /* Force stacking context */
+        }
+        
+        body.changed .scroller {
+            overflow: scroll;
+        }
+        
+        .content {
+            width: 200%;
+            height: 300%;
+        }
+        
+        .absolute {
+            position: absolute;
+            top: 100px;
+            left: 50px;
+            height: 200px;
+            width: 200px;
+            background-color: green;
+        }
+    </style>
+    <script src="../../../resources/ui-helper.js"></script>
+    <script>
+        async function scrollOverContent()
+        {
+            await UIHelper.mouseWheelScrollAt(50, 50);
+        }
+
+        async function scrollTest()
+        {
+            await scrollOverContent();
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }
+        
+        async function doTest()
+        {
+            document.body.offsetWidth;
+            document.body.classList.add('changed');
+            setTimeout(scrollTest, 0);
+        }
+
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div class="container">
+        <div class="scroller">
+            <div class="content">
+                <div class="absolute">
+                </div>
+            </div>
+        </div>
+    </div>
+</body>
+</html>
index cdb84ff..d09b3ec 100644 (file)
@@ -16,7 +16,7 @@
             border: 20px solid gray;
             padding: 5px;
             overflow: scroll;
-            opacity: 0.8; /* Force stackingc context */
+            opacity: 0.8; /* Force stacking context */
         }
         .content {
             width: 200%;
index 6f06a85..14e8917 100644 (file)
@@ -1,3 +1,23 @@
+2020-03-10  Simon Fraser  <simon.fraser@apple.com>
+
+        Track "scrolling scope" on RenderLayers
+        https://bugs.webkit.org/show_bug.cgi?id=208620
+
+        Reviewed by Zalan Bujtas.
+        
+        The scrolling scope code added in r257920 failed to recompute m_contentsScrollingScope
+        when hasCompositedScrollableOverflow() changed, causing bugs on gmail.
+
+        Recompute the m_contentsScrollingScope to match or not match the m_boxScrollingScope
+        based on whether the layer is composited-scrollable.
+
+        Test: fast/scrolling/mac/absolute-in-overflow-scroll-dynamic.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateLayerPosition):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::isScrolledByOverflowScrollLayer):
+
 2020-03-10  Don Olmstead  <don.olmstead@sony.com>
 
         Non-unified build fixes early March 2020 edition
index b96874e..2d72c43 100644 (file)
@@ -1759,9 +1759,9 @@ bool RenderLayer::updateLayerPosition(OptionSet<UpdateLayerPositionsFlag>* flags
     }
 
     if (hasCompositedScrollableOverflow()) {
-        if (!m_contentsScrollingScope)
+        if (!m_contentsScrollingScope || m_contentsScrollingScope == m_boxScrollingScope)
             m_contentsScrollingScope = nextScrollingScope();
-    } else if (!m_contentsScrollingScope)
+    } else if (!m_contentsScrollingScope || m_contentsScrollingScope != m_boxScrollingScope)
         m_contentsScrollingScope = m_boxScrollingScope;
 
     bool positionOrOffsetChanged = false;
index 2a5130b..062509c 100644 (file)
@@ -3194,15 +3194,7 @@ bool RenderLayerCompositor::useCoordinatedScrollingForLayer(const RenderLayer& l
 
 static bool isScrolledByOverflowScrollLayer(const RenderLayer& layer, const RenderLayer& overflowScrollLayer)
 {
-    bool scrolledByOverflowScroll = false;
-    traverseAncestorLayers(layer, [&](const RenderLayer& ancestorLayer, bool inContainingBlockChain, bool) {
-        if (&ancestorLayer == &overflowScrollLayer) {
-            scrolledByOverflowScroll = inContainingBlockChain;
-            return AncestorTraversal::Stop;
-        }
-        return AncestorTraversal::Continue;
-    });
-    return scrolledByOverflowScroll;
+    return layer.boxScrollingScope() == overflowScrollLayer.contentsScrollingScope();
 }
 
 static RenderLayer* enclosingCompositedScrollingLayer(const RenderLayer& layer, const RenderLayer& intermediateLayer, bool& sawIntermediateLayer)