Event region should be set on scrolledContentsLayer if it exists
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jun 2019 20:43:17 +0000 (20:43 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jun 2019 20:43:17 +0000 (20:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198717
<rdar://problem/51572169>

Reviewed by Simon Fraser.

Source/WebCore:

Test: pointerevents/ios/touch-action-region-overflow.html

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):

Move to updateBackingAndHierarchy.

(WebCore::RenderLayerBacking::updateEventRegion):

- Set event region on scrolledContentsLayer if it exists
- Translate away the scroll offset
- Get the offset from renderer from the GraphicsLayer so scrolling and non-scrolling case can be handled uniformly.

* rendering/RenderLayerBacking.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):

Invoke updateEventRegion after geometry update so offsets are already available on GraphicsLayer.

LayoutTests:

* pointerevents/ios/touch-action-region-backing-sharing-expected.txt:
* pointerevents/ios/touch-action-region-overflow-expected.txt: Added.
* pointerevents/ios/touch-action-region-overflow.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/pointerevents/ios/touch-action-region-backing-sharing-expected.txt
LayoutTests/pointerevents/ios/touch-action-region-overflow-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-overflow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp

index a1a7fda..1b9d124 100644 (file)
@@ -1,3 +1,15 @@
+2019-06-10  Antti Koivisto  <antti@apple.com>
+
+        Event region should be set on scrolledContentsLayer if it exists
+        https://bugs.webkit.org/show_bug.cgi?id=198717
+        <rdar://problem/51572169>
+
+        Reviewed by Simon Fraser.
+
+        * pointerevents/ios/touch-action-region-backing-sharing-expected.txt:
+        * pointerevents/ios/touch-action-region-overflow-expected.txt: Added.
+        * pointerevents/ios/touch-action-region-overflow.html: Added.
+
 2019-06-10  Daniel Bates  <dabates@apple.com>
 
         [CSP] Blob URLs should inherit their CSP policy
index 8aec3a7..0d344d4 100644 (file)
@@ -1,7 +1,6 @@
 (GraphicsLayer
   (anchor 0.00 0.00)
   (bounds 800.00 600.00)
-  (deep color 1)
   (children 1
     (GraphicsLayer
       (bounds 800.00 600.00)
@@ -9,15 +8,10 @@
       (event region
         (rect (0,0) width=800 height=600)
       )
-      (deep color 1)
       (children 2
         (GraphicsLayer
           (position 8.00 13.00)
           (bounds 200.00 200.00)
-          (event region
-            (rect (0,0) width=500 height=500)
-          )
-          (deep color 1)
           (children 1
             (GraphicsLayer
               (bounds 200.00 200.00)
@@ -26,7 +20,9 @@
                   (anchor 0.00 0.00)
                   (bounds 500.00 500.00)
                   (drawsContent 1)
-                  (deep color 1)
+                  (event region
+                    (rect (0,0) width=500 height=500)
+                  )
                 )
               )
             )
@@ -48,7 +44,6 @@
               )
             )
           )
-          (deep color 1)
         )
       )
     )
diff --git a/LayoutTests/pointerevents/ios/touch-action-region-overflow-expected.txt b/LayoutTests/pointerevents/ios/touch-action-region-overflow-expected.txt
new file mode 100644 (file)
index 0000000..c477d4b
--- /dev/null
@@ -0,0 +1,96 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 671.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 671.00)
+      (contentsOpaque 1)
+      (event region
+        (rect (0,0) width=800 height=671)
+      )
+      (children 3
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 200.00 200.00)
+          (children 1
+            (GraphicsLayer
+              (bounds 200.00 200.00)
+              (children 1
+                (GraphicsLayer
+                  (anchor 0.00 0.00)
+                  (bounds 500.00 500.00)
+                  (drawsContent 1)
+                  (event region
+                    (rect (0,0) width=500 height=500)
+                    (touch-action
+                      (none                      
+                        (rect (150,150) width=100 height=100)
+                      )
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 8.00 208.00)
+          (bounds 200.00 200.00)
+          (children 1
+            (GraphicsLayer
+              (bounds origin 150.00 150.00)
+              (bounds 200.00 200.00)
+              (children 1
+                (GraphicsLayer
+                  (scrollOffset (150,150))
+                  (anchor 0.00 0.00)
+                  (bounds 500.00 500.00)
+                  (drawsContent 1)
+                  (event region
+                    (rect (0,0) width=500 height=500)
+                    (touch-action
+                      (none                      
+                        (rect (150,150) width=100 height=100)
+                      )
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 8.00 408.00)
+          (bounds 250.00 250.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (offsetFromRenderer width=25 height=25)
+              (position 25.00 25.00)
+              (bounds origin 150.00 150.00)
+              (bounds 200.00 200.00)
+              (children 1
+                (GraphicsLayer
+                  (offsetFromRenderer width=25 height=25)
+                  (scrollOffset (150,150))
+                  (anchor 0.00 0.00)
+                  (bounds 500.00 500.00)
+                  (drawsContent 1)
+                  (event region
+                    (rect (0,0) width=500 height=500)
+                    (touch-action
+                      (none                      
+                        (rect (150,150) width=100 height=100)
+                      )
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/pointerevents/ios/touch-action-region-overflow.html b/LayoutTests/pointerevents/ios/touch-action-region-overflow.html
new file mode 100644 (file)
index 0000000..10d55c1
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<style>
+.scroll { position:relative; width:200px; height:200px; overflow:scroll }
+.scrollcontent { position:absolute; width:500px; height:500px; background:green; }
+.none { position:relative; top:150px; left:150px; width:100px; height:100px; background:blue; touch-action: none; }
+</style>
+<body>
+<div class="scroll"><div class="scrollcontent"><div class="none"></div></div></div>
+<div class="scroll target"><div class="scrollcontent"><div class="none"></div></div></div>
+<div class="scroll target" style="border:25px solid yellow"><div class="scrollcontent"><div class="none"></div></div></div>
+<pre id="results"></pre>
+<script>
+for (target of document.querySelectorAll(".target"))
+    target.scrollBy(150,150);
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+if (window.internals)
+    results.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+</script>
+</body>
+</html>
index 9f0fe6f..9fe43ae 100644 (file)
@@ -1,3 +1,30 @@
+2019-06-10  Antti Koivisto  <antti@apple.com>
+
+        Event region should be set on scrolledContentsLayer if it exists
+        https://bugs.webkit.org/show_bug.cgi?id=198717
+        <rdar://problem/51572169>
+
+        Reviewed by Simon Fraser.
+
+        Test: pointerevents/ios/touch-action-region-overflow.html
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+
+        Move to updateBackingAndHierarchy.
+
+        (WebCore::RenderLayerBacking::updateEventRegion):
+
+        - Set event region on scrolledContentsLayer if it exists
+        - Translate away the scroll offset
+        - Get the offset from renderer from the GraphicsLayer so scrolling and non-scrolling case can be handled uniformly.
+
+        * rendering/RenderLayerBacking.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
+
+        Invoke updateEventRegion after geometry update so offsets are already available on GraphicsLayer.
+
 2019-06-10  Daniel Bates  <dabates@apple.com>
 
         [CSP] Blob URLs should inherit their CSP policy
index 59bb760..1ab3486 100644 (file)
@@ -841,8 +841,6 @@ bool RenderLayerBacking::updateConfiguration()
     } else
         updateRootLayerConfiguration();
 
-    updateEventRegion();
-
     // Requires layout.
     if (contentsInfo.isDirectlyCompositedImage())
         updateImageContents(contentsInfo);
@@ -1526,10 +1524,12 @@ void RenderLayerBacking::updateEventRegion()
     for (auto& layer : m_backingSharingLayers)
         layer->paintLayerWithEffects(nullContext, paintingInfo, paintFlags);
 
-    auto contentOffset = roundedIntSize(contentOffsetInCompositingLayer());
-    eventRegion.translate(contentOffset);
-    m_graphicsLayer->setEventRegion(WTFMove(eventRegion));
+    GraphicsLayer& layerForEventRegion = m_scrolledContentsLayer ? *m_scrolledContentsLayer : *m_graphicsLayer;
+
+    auto layerOffset = toIntSize(layerForEventRegion.scrollOffset()) - roundedIntSize(layerForEventRegion.offsetFromRenderer());
+    eventRegion.translate(layerOffset);
 
+    layerForEventRegion.setEventRegion(WTFMove(eventRegion));
 #endif
 }
 
index 0030811..412b102 100644 (file)
@@ -216,6 +216,8 @@ public:
     bool setCompositedBounds(const LayoutRect&);
     // Returns true if changed.
     bool updateCompositedBounds();
+
+    void updateEventRegion();
     
     void updateAfterWidgetResize();
     void positionOverflowControlsLayers();
@@ -358,7 +360,6 @@ private:
     bool paintsContent(RenderLayer::PaintedContentRequest&) const;
 
     void updateDrawsContent(PaintedContentsInfo&);
-    void updateEventRegion();
 
     // Returns true if this compositing layer has no visible content.
     bool isSimpleContainerCompositingLayer(PaintedContentsInfo&) const;
index f633f32..a408405 100644 (file)
@@ -1210,6 +1210,11 @@ void RenderLayerCompositor::updateBackingAndHierarchy(RenderLayer& layer, Vector
         } else if (layer.needsScrollingTreeUpdate())
             scrollingNodeChanges.add(ScrollingNodeChangeFlags::LayerGeometry);
 
+        // This needs to happen after any geometry update.
+        // FIXME: Use separate bit for event region invalidation.
+        if (layerNeedsUpdate || layer.needsCompositingConfigurationUpdate())
+            layerBacking->updateEventRegion();
+
         if (auto* reflection = layer.reflectionLayer()) {
             if (auto* reflectionBacking = reflection->backing()) {
                 reflectionBacking->updateCompositedBounds();