Title: [216104] trunk
Revision
216104
Author
[email protected]
Date
2017-05-02 16:06:13 -0700 (Tue, 02 May 2017)

Log Message

Dynamically added position:fixed element is in the wrong place
https://bugs.webkit.org/show_bug.cgi?id=170280
rdar://problem/31374008

Reviewed by Tim Horton.

Source/WebKit2:

Layers for position:fixed elements have their positions reconciled after scrolls
via AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions() and GraphicsLayerCA::syncPosition(),
which updates the GraphicsLayer's position, but does not push it to the PlatformCALayer.

This bug was a case where a position:fixed element gained a fixed ancestor, so had a GraphicsLayerCA whose
position had been updated via syncPosition() in the past. A subsequent layout updated the GraphicsLayerCA position,
but to a value that was the same as its pre-sync position, so the PlatformCALayerRemote's position didn't change,
but there was no signal to the UI process to restore the layer's pre-scrolled position.

Fix by avoiding the early return in PlatformCALayerRemote::setPosition(), to ensure that GraphicsLayerCA
geometry updates in the web process always send new positions to the UI process.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::setPosition):

LayoutTests:

* scrollingcoordinator/ios/nested-fixed-layer-positions-expected.html: Added.
* scrollingcoordinator/ios/nested-fixed-layer-positions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (216103 => 216104)


--- trunk/LayoutTests/ChangeLog	2017-05-02 23:06:09 UTC (rev 216103)
+++ trunk/LayoutTests/ChangeLog	2017-05-02 23:06:13 UTC (rev 216104)
@@ -1,3 +1,14 @@
+2017-05-02  Simon Fraser  <[email protected]>
+
+        Dynamically added position:fixed element is in the wrong place
+        https://bugs.webkit.org/show_bug.cgi?id=170280
+        rdar://problem/31374008
+
+        Reviewed by Tim Horton.
+
+        * scrollingcoordinator/ios/nested-fixed-layer-positions-expected.html: Added.
+        * scrollingcoordinator/ios/nested-fixed-layer-positions.html: Added.
+
 2017-05-02  Ryan Haddad  <[email protected]>
 
         Move flaky expectation for svg/animations/getCurrentTime-pause-unpause.html ios-wk1 to ios TestExpectations file.

Added: trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions-expected.html (0 => 216104)


--- trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions-expected.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions-expected.html	2017-05-02 23:06:13 UTC (rev 216104)
@@ -0,0 +1,29 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        body {
+            height: 2000px;
+            margin: 0;
+        }
+
+        .fixed {
+            position: fixed;
+        }
+        
+        .fixed-bar {
+            position: fixed;
+            top: 10px;
+            left: 0;
+            height: 100px;
+            width: 400px;
+            background-color: blue;
+        }
+    </style>
+</head>
+<body class="fixed">
+    <div class="fixed-bar"></div>
+</body>
+</html>

Added: trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions.html (0 => 216104)


--- trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/nested-fixed-layer-positions.html	2017-05-02 23:06:13 UTC (rev 216104)
@@ -0,0 +1,62 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        body {
+            height: 2000px;
+            margin: 0;
+        }
+
+        .fixed {
+            position: fixed;
+        }
+        
+        .fixed-bar {
+            position: fixed;
+            top: 10px;
+            left: 0;
+            height: 100px;
+            width: 400px;
+            background-color: blue;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        function getScrollDownUIScript()
+        {
+            return `(function() {
+                uiController.scrollToOffset(0, 300);
+                
+                uiController.didEndScrollingCallback = function() {
+                    uiController.uiScriptComplete();
+                };
+            })();`;
+        }
+        
+        function makeBodyFixed()
+        {
+            document.body.classList.add('fixed');
+            testRunner.notifyDone();
+        }
+
+        function doTest()
+        {
+            if (!testRunner.runUIScript)
+                return
+
+            testRunner.runUIScript(getScrollDownUIScript(), function() {
+                makeBodyFixed();
+            });
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div class="fixed-bar"></div>
+</body>
+</html>

Modified: trunk/Source/WebKit2/ChangeLog (216103 => 216104)


--- trunk/Source/WebKit2/ChangeLog	2017-05-02 23:06:09 UTC (rev 216103)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-02 23:06:13 UTC (rev 216104)
@@ -1,3 +1,26 @@
+2017-05-02  Simon Fraser  <[email protected]>
+
+        Dynamically added position:fixed element is in the wrong place
+        https://bugs.webkit.org/show_bug.cgi?id=170280
+        rdar://problem/31374008
+
+        Reviewed by Tim Horton.
+
+        Layers for position:fixed elements have their positions reconciled after scrolls
+        via AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions() and GraphicsLayerCA::syncPosition(),
+        which updates the GraphicsLayer's position, but does not push it to the PlatformCALayer.
+
+        This bug was a case where a position:fixed element gained a fixed ancestor, so had a GraphicsLayerCA whose
+        position had been updated via syncPosition() in the past. A subsequent layout updated the GraphicsLayerCA position,
+        but to a value that was the same as its pre-sync position, so the PlatformCALayerRemote's position didn't change,
+        but there was no signal to the UI process to restore the layer's pre-scrolled position.
+
+        Fix by avoiding the early return in PlatformCALayerRemote::setPosition(), to ensure that GraphicsLayerCA
+        geometry updates in the web process always send new positions to the UI process.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::setPosition):
+
 2017-05-02  Gwang Yoon Hwang  <[email protected]>
 
         [GTK] Drop coordinated surfaces from the compositing thread as soon as possible

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (216103 => 216104)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2017-05-02 23:06:09 UTC (rev 216103)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2017-05-02 23:06:13 UTC (rev 216104)
@@ -452,9 +452,9 @@
 
 void PlatformCALayerRemote::setPosition(const FloatPoint3D& value)
 {
-    if (value == m_properties.position)
-        return;
-
+    // We can't early return here if the position has not changed, since GraphicsLayerCA::syncPosition() may have changed
+    // the GraphicsLayer position (which doesn't force a geometry update) but we want a subsequent GraphicsLayerCA::setPosition()
+    // to push a new position to the UI process, even though our m_properties.position hasn't changed.
     m_properties.position = value;
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::PositionChanged);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to