Title: [175085] trunk
Revision
175085
Author
[email protected]
Date
2014-10-22 23:15:44 -0700 (Wed, 22 Oct 2014)

Log Message

[iOS] Toggling overflow:scroll to hidden on element with -webkit-overflow-scrolling:touch can cause children to disappear
https://bugs.webkit.org/show_bug.cgi?id=137999
rdar://problem/18425550

Reviewed by Zalan Bujtas.

Source/WebCore:

When toggling overflow from scroll to hidden on an element with -webkit-overflow-scrolling:touch,
we'd fail to do a compositing layer rebuild, which caused various issues like unparented
descendants, and misplaced and unrepainted content.

This happened because we'd get to RenderLayerBacking::updateConfiguration() via styleChanged
with the view needing layout, so never hit the updateScrollingLayers() code, and the subsequent
updateCompositingLayers() would be a no-op.

Fix by explicitly triggering a layer rebuild when style changes such that the touch-scrollability
of an element changes, as we do for changes in clip.

Test: compositing/scrolling/touch-scroll-to-clip.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::isScrollableOverflow):
(WebCore::styleHasTouchScrolling):
(WebCore::styleChangeRequiresLayerRebuild):

LayoutTests:

Test that toggles overflow on a touch scrolling div, and dumps layers.

* compositing/scrolling/touch-scroll-to-clip-expected.txt: Added.
* compositing/scrolling/touch-scroll-to-clip.html: Added.
* platform/ios-simulator/compositing/scrolling/touch-scroll-to-clip-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (175084 => 175085)


--- trunk/LayoutTests/ChangeLog	2014-10-23 04:32:27 UTC (rev 175084)
+++ trunk/LayoutTests/ChangeLog	2014-10-23 06:15:44 UTC (rev 175085)
@@ -1,3 +1,17 @@
+2014-10-22  Simon Fraser  <[email protected]>
+
+        [iOS] Toggling overflow:scroll to hidden on element with -webkit-overflow-scrolling:touch can cause children to disappear
+        https://bugs.webkit.org/show_bug.cgi?id=137999
+        rdar://problem/18425550
+
+        Reviewed by Zalan Bujtas.
+        
+        Test that toggles overflow on a touch scrolling div, and dumps layers.
+
+        * compositing/scrolling/touch-scroll-to-clip-expected.txt: Added.
+        * compositing/scrolling/touch-scroll-to-clip.html: Added.
+        * platform/ios-simulator/compositing/scrolling/touch-scroll-to-clip-expected.txt: Added.
+
 2014-10-22  Byungseon Shin  <[email protected]>
 
         String(new Date(Mar 30 2014 01:00:00)) is wrong in CET

Added: trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip-expected.txt (0 => 175085)


--- trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip-expected.txt	2014-10-23 06:15:44 UTC (rev 175085)
@@ -0,0 +1,30 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 320.00 440.00)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 280.00 400.00)
+              (children 1
+                (GraphicsLayer
+                  (anchor 0.50 0.50)
+                  (bounds 265.00 500.00)
+                  (contentsOpaque 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip.html (0 => 175085)


--- trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/scrolling/touch-scroll-to-clip.html	2014-10-23 06:15:44 UTC (rev 175085)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0">
+    <style>
+        html {
+            -webkit-overflow-scrolling: touch;
+        }
+        .container {
+            position: relative;
+            z-index: 0;
+            border: 20px solid black;
+            height: 400px;
+            width: 280px;
+            overflow: scroll;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+            width: 100%;
+            height: 500px;
+            background-color: silver;
+        }
+        
+        .container.no-scroll {
+            overflow: hidden;
+            border: 20px solid red;
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.waitUntilDone();
+            testRunner.dumpAsText();
+        }
+
+        function startTest()
+        {
+            document.body.offsetWidth;
+            window.setTimeout(function() {
+                var scroller = document.getElementById('scroller');
+                scroller.classList.toggle('no-scroll');
+
+                if (window.internals)
+                    document.getElementById('layer-tree').innerText = window.internals.layerTreeAsText(document);
+
+                if (window.testRunner)
+                    window.testRunner.notifyDone();
+                
+            }, 0);
+        }
+        window.addEventListener('load', startTest, false);
+    </script>
+</head>
+<body>
+    
+    <div id="scroller" class="container">
+        <div class="composited">
+        </div>
+    </div>
+<pre id="layer-tree">Layer tree goes here</pre>
+
+</body>
+</html>

Added: trunk/LayoutTests/platform/ios-simulator/compositing/scrolling/touch-scroll-to-clip-expected.txt (0 => 175085)


--- trunk/LayoutTests/platform/ios-simulator/compositing/scrolling/touch-scroll-to-clip-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/compositing/scrolling/touch-scroll-to-clip-expected.txt	2014-10-23 06:15:44 UTC (rev 175085)
@@ -0,0 +1,28 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 320.00 440.00)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 280.00 400.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 280.00 500.00)
+                  (contentsOpaque 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Modified: trunk/Source/WebCore/ChangeLog (175084 => 175085)


--- trunk/Source/WebCore/ChangeLog	2014-10-23 04:32:27 UTC (rev 175084)
+++ trunk/Source/WebCore/ChangeLog	2014-10-23 06:15:44 UTC (rev 175085)
@@ -1,3 +1,29 @@
+2014-10-22  Simon Fraser  <[email protected]>
+
+        [iOS] Toggling overflow:scroll to hidden on element with -webkit-overflow-scrolling:touch can cause children to disappear
+        https://bugs.webkit.org/show_bug.cgi?id=137999
+        rdar://problem/18425550
+
+        Reviewed by Zalan Bujtas.
+        
+        When toggling overflow from scroll to hidden on an element with -webkit-overflow-scrolling:touch,
+        we'd fail to do a compositing layer rebuild, which caused various issues like unparented
+        descendants, and misplaced and unrepainted content.
+        
+        This happened because we'd get to RenderLayerBacking::updateConfiguration() via styleChanged
+        with the view needing layout, so never hit the updateScrollingLayers() code, and the subsequent
+        updateCompositingLayers() would be a no-op.
+        
+        Fix by explicitly triggering a layer rebuild when style changes such that the touch-scrollability
+        of an element changes, as we do for changes in clip.
+
+        Test: compositing/scrolling/touch-scroll-to-clip.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::isScrollableOverflow):
+        (WebCore::styleHasTouchScrolling):
+        (WebCore::styleChangeRequiresLayerRebuild):
+
 2014-10-22  Chris Dumez  <[email protected]>
 
         Clean up virtual functions in rendering/

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (175084 => 175085)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-10-23 04:32:27 UTC (rev 175084)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-10-23 06:15:44 UTC (rev 175085)
@@ -862,6 +862,18 @@
     return false;
 }
 
+#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
+static bool isScrollableOverflow(EOverflow overflow)
+{
+    return overflow == OSCROLL || overflow == OAUTO || overflow == OOVERLAY;
+}
+
+static bool styleHasTouchScrolling(const RenderStyle& style)
+{
+    return isScrollableOverflow(style.overflowX()) && style.useTouchOverflowScrolling();
+}
+#endif
+
 static bool styleChangeRequiresLayerRebuild(const RenderLayer& layer, const RenderStyle& oldStyle, const RenderStyle& newStyle)
 {
     // Clip can affect ancestor compositing bounds, so we need recompute overlap when it changes on a non-composited layer.
@@ -872,6 +884,11 @@
     // When overflow changes, composited layers may need to update their ancestorClipping layers.
     if (!layer.isComposited() && (oldStyle.overflowX() != newStyle.overflowX()) && layer.stackingContainer()->hasCompositingDescendant())
         return true;
+    
+#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
+    if (styleHasTouchScrolling(oldStyle) != styleHasTouchScrolling(newStyle))
+        return true;
+#endif
 
     // Compositing layers keep track of whether they are clipped by any of the ancestors.
     // When the current layer's clipping behaviour changes, we need to propagate it to the descendants.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to