Title: [287757] trunk
Revision
287757
Author
simon.fra...@apple.com
Date
2022-01-07 10:06:43 -0800 (Fri, 07 Jan 2022)

Log Message

REGRESSION (Safari 14): background-attachment: local does not work
https://bugs.webkit.org/show_bug.cgi?id=219324
Source/WebCore:

<rdar://71808922>

Reviewed by Antti Koivisto.

With async overflow scrolling, we need to trigger a repaint if the scrolling element
has any background layer with `background-attachment: local`.

The background won't always be synchronized with the scrolling, but a little jitter
is better than a broken CSS behavior (and this is what Firefox does).

Test: fast/repaint/background-attachment-local-scroll.html

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::needsRepaintOnCompositedScroll const):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::hasAnyLocalBackground const):
* rendering/style/RenderStyle.h:

LayoutTests:

Reviewed by Antti Koivisto.

Skip the test on platforms without async overflow scroll.

* TestExpectations:
* fast/repaint/background-attachment-local-scroll-expected.txt: Added.
* fast/repaint/background-attachment-local-scroll.html: Added.
* platform/ios-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287756 => 287757)


--- trunk/LayoutTests/ChangeLog	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/LayoutTests/ChangeLog	2022-01-07 18:06:43 UTC (rev 287757)
@@ -1,3 +1,18 @@
+2022-01-07  Simon Fraser  <simon.fra...@apple.com>
+
+        REGRESSION (Safari 14): background-attachment: local does not work
+        https://bugs.webkit.org/show_bug.cgi?id=219324
+
+        Reviewed by Antti Koivisto.
+
+        Skip the test on platforms without async overflow scroll.
+
+        * TestExpectations:
+        * fast/repaint/background-attachment-local-scroll-expected.txt: Added.
+        * fast/repaint/background-attachment-local-scroll.html: Added.
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
 2022-01-07  Kate Cheney  <katherine_che...@apple.com>
 
         Implement CSP strict-dynamic for module scripts

Modified: trunk/LayoutTests/TestExpectations (287756 => 287757)


--- trunk/LayoutTests/TestExpectations	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/LayoutTests/TestExpectations	2022-01-07 18:06:43 UTC (rev 287757)
@@ -91,6 +91,7 @@
 compositing/shared-backing/overflow-scroll [ Skip ]
 compositing/scrolling/async-overflow-scrolling [ Skip ]
 compositing/layer-creation/clipping-scope [ Skip ]
+fast/repaint/background-attachment-local-scroll.html [ Skip ]
 
 # WebKit2 only.
 printing/printing-events.html [ Skip ]

Added: trunk/LayoutTests/fast/repaint/background-attachment-local-scroll-expected.txt (0 => 287757)


--- trunk/LayoutTests/fast/repaint/background-attachment-local-scroll-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/repaint/background-attachment-local-scroll-expected.txt	2022-01-07 18:06:43 UTC (rev 287757)
@@ -0,0 +1,10 @@
+Test that a scroll of an overflow scrolling element, with `background-attachment:local`, repaints
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS layerTreeAsText.indexOf('repaint rect') > -1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+text here

Added: trunk/LayoutTests/fast/repaint/background-attachment-local-scroll.html (0 => 287757)


--- trunk/LayoutTests/fast/repaint/background-attachment-local-scroll.html	                        (rev 0)
+++ trunk/LayoutTests/fast/repaint/background-attachment-local-scroll.html	2022-01-07 18:06:43 UTC (rev 287757)
@@ -0,0 +1,61 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        #scroller {
+            width: 300px;
+            height: 300px;
+            overflow: scroll;
+            border: 1px solid black;
+            background-image: linear-gradient(lightblue, palegreen);
+            background-attachment: local;
+        }
+        
+        .content {
+            height: 300%;
+        }
+
+        /* Hide the scrollbars to remove scrollbar repaints. */
+        ::-webkit-scrollbar {
+            display: none;
+        }
+    </style>
+    <script src=""
+    <script>
+        jsTestIsAsync = true;
+        description("Test that a scroll of an overflow scrolling element, with `background-attachment:local`, repaints");
+
+        function startTrackingRepaints()
+        {
+            window.internals.startTrackingRepaints();
+            document.getElementById('scroller').scrollTop = 800;
+
+            logRepaints();
+        }
+
+        function logRepaints()
+        {
+            layerTreeAsText =  window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
+            window.internals.stopTrackingRepaints();
+            shouldBeTrue("layerTreeAsText.indexOf('repaint rect') > -1");
+
+            finishJSTest();
+        }
+
+        window.addEventListener('load', () => {
+            if (!window.testRunner || !window.internals)
+                return;
+
+            setTimeout(startTrackingRepaints, 0);
+        }, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="content">
+            text here
+        </div>
+    </div>
+
+<script src=""
+</html>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (287756 => 287757)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-01-07 18:06:43 UTC (rev 287757)
@@ -41,6 +41,7 @@
 fast/media/mq-prefers-contrast.html [ Pass ]
 fast/media/mq-prefers-contrast-live-update.html [ Pass ]
 
+fast/repaint/background-attachment-local-scroll.html [ Pass ]
 fast/repaint/placeholder-after-caps-lock-hidden.html [ Pass ]
 
 fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (287756 => 287757)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2022-01-07 18:06:43 UTC (rev 287757)
@@ -42,6 +42,7 @@
 fast/media/mq-prefers-contrast-live-update.html [ Pass ]
 fast/media/mq-prefers-contrast.html [ Pass ]
 
+fast/repaint/background-attachment-local-scroll.html [ Pass ]
 fast/scrolling/unfocusing-page-while-keyboard-scrolling.html [ Pass ]
 
 http/tests/ssl/applepay [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (287756 => 287757)


--- trunk/Source/WebCore/ChangeLog	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/Source/WebCore/ChangeLog	2022-01-07 18:06:43 UTC (rev 287757)
@@ -1,3 +1,25 @@
+2022-01-07  Simon Fraser  <simon.fra...@apple.com>
+
+        REGRESSION (Safari 14): background-attachment: local does not work
+        https://bugs.webkit.org/show_bug.cgi?id=219324
+        <rdar://71808922>
+
+        Reviewed by Antti Koivisto.
+
+        With async overflow scrolling, we need to trigger a repaint if the scrolling element
+        has any background layer with `background-attachment: local`.
+
+        The background won't always be synchronized with the scrolling, but a little jitter
+        is better than a broken CSS behavior (and this is what Firefox does).
+
+        Test: fast/repaint/background-attachment-local-scroll.html
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::needsRepaintOnCompositedScroll const):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::hasAnyLocalBackground const):
+        * rendering/style/RenderStyle.h:
+
 2022-01-07  Kate Cheney  <katherine_che...@apple.com>
 
         Implement CSP strict-dynamic for module scripts

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (287756 => 287757)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2022-01-07 18:06:43 UTC (rev 287757)
@@ -2034,9 +2034,12 @@
     if (!hasScrollingLayer())
         return false;
 
+    if (renderer().style().hasAnyLocalBackground())
+        return true;
+
     if (auto scrollingCoordinator = m_owningLayer.page().scrollingCoordinator())
         return scrollingCoordinator->hasSynchronousScrollingReasons(m_scrollingNodeID);
-    
+
     return false;
 }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (287756 => 287757)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-01-07 18:06:43 UTC (rev 287757)
@@ -1666,6 +1666,15 @@
     return allLayersAreFixed(backgroundLayers());
 }
 
+bool RenderStyle::hasAnyLocalBackground() const
+{
+    for (auto* layer = &backgroundLayers(); layer; layer = layer->next()) {
+        if (layer->image() && layer->attachment() == FillAttachment::LocalBackground)
+            return true;
+    }
+    return false;
+}
+
 const CounterDirectiveMap* RenderStyle::counterDirectives() const
 {
     return m_rareNonInheritedData->counterDirectives.get();

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (287756 => 287757)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-01-07 18:04:56 UTC (rev 287756)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-01-07 18:06:43 UTC (rev 287757)
@@ -214,6 +214,7 @@
     bool hasFixedBackgroundImage() const { return m_backgroundData->background->hasFixedImage(); }
 
     bool hasEntirelyFixedBackground() const;
+    bool hasAnyLocalBackground() const;
 
     bool hasAppearance() const { return appearance() != NoControlPart; }
     bool hasEffectiveAppearance() const { return effectiveAppearance() != NoControlPart; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to