Update event region when toggling pointer-events:none
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 19:53:00 +0000 (19:53 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 19:53:00 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195902
<rdar://problem/48988384>

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/scrolling/ios/event-region-pointer-events.html

Normally paint invalidation requests compositing configuration update whenever anything that would
affect event region changes. However mutating 'pointer-events' property does not cause paint invalidation.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):

Request compositing update explicitly from the containing layer.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::invalidateEventRegion):
* rendering/RenderLayer.h:

LayoutTests:

* fast/scrolling/ios/event-region-pointer-events-expected.txt: Added.
* fast/scrolling/ios/event-region-pointer-events.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/scrolling/ios/event-region-pointer-events-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/ios/event-region-pointer-events.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h

index 5867777..7680ef8 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-01  Antti Koivisto  <antti@apple.com>
+
+        Update event region when toggling pointer-events:none
+        https://bugs.webkit.org/show_bug.cgi?id=195902
+        <rdar://problem/48988384>
+
+        Reviewed by Simon Fraser.
+
+        * fast/scrolling/ios/event-region-pointer-events-expected.txt: Added.
+        * fast/scrolling/ios/event-region-pointer-events.html: Added.
+
 2019-04-01  Chris Dumez  <cdumez@apple.com>
 
         Support "noreferrer" for window.open()
diff --git a/LayoutTests/fast/scrolling/ios/event-region-pointer-events-expected.txt b/LayoutTests/fast/scrolling/ios/event-region-pointer-events-expected.txt
new file mode 100644 (file)
index 0000000..9389b6f
--- /dev/null
@@ -0,0 +1,99 @@
+ Before:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 200.00 200.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 212.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 416.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+After setting 'pointer-events:auto':
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 673.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 673.00)
+      (contentsOpaque 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 200.00 200.00)
+          (drawsContent 1)
+          (event region
+            (rect (0,0) width=200 height=200)
+          )
+        )
+        (GraphicsLayer
+          (position 212.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+          (event region
+            (rect (2,2) width=200 height=200)
+          )
+        )
+        (GraphicsLayer
+          (position 416.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+          (event region
+            (rect (2,2) width=200 height=200)
+          )
+        )
+      )
+    )
+  )
+)
+After setting 'pointer-events:none':
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 1205.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 1205.00)
+      (contentsOpaque 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 200.00 200.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 212.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 416.00 8.00)
+          (bounds 202.00 202.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/fast/scrolling/ios/event-region-pointer-events.html b/LayoutTests/fast/scrolling/ios/event-region-pointer-events.html
new file mode 100644 (file)
index 0000000..f5e4fed
--- /dev/null
@@ -0,0 +1,58 @@
+<html>
+<style>
+.testdiv {
+    display: inline-block;
+    box-sizing: border-box;
+    border: 2px solid blue;
+    position: relative;
+    height: 200px;
+    width: 200px;
+    will-change: transform;
+}
+.inner {
+    height: 200px;
+    width: 200px;
+    background-color: green;
+}
+
+</style>
+<script>
+window.onload = function () {
+    if (!window.internals)
+        return;
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    results.innerText = "Before:\n\n"
+    results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+
+    test1.style.pointerEvents = "auto";
+    test2.style.pointerEvents = "auto";
+    test3.style.pointerEvents = "auto";
+
+    results.innerText += "After setting 'pointer-events:auto':\n\n"
+    results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+
+    test1.style.pointerEvents = "none";
+    test2.style.pointerEvents = "none";
+    test3.style.pointerEvents = "none";
+
+    results.innerText += "After setting 'pointer-events:none':\n\n"
+    results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+}
+</script>
+<body>
+<div class="testdiv" id="test1" style="pointer-events:none">
+</div>
+<div class="testdiv" style="pointer-events:none">
+    <div id="test2" class="inner"></div>
+</div>
+<div class="testdiv" style="pointer-events:none">
+    <div class="inner" style="position:relative">
+        <div id="test3" class="inner"></div>
+    </div>
+</div>
+
+<pre id="results"></pre>
+</body>
+</html>
index 9df44ec..42488f7 100644 (file)
@@ -1,3 +1,25 @@
+2019-04-01  Antti Koivisto  <antti@apple.com>
+
+        Update event region when toggling pointer-events:none
+        https://bugs.webkit.org/show_bug.cgi?id=195902
+        <rdar://problem/48988384>
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/scrolling/ios/event-region-pointer-events.html
+
+        Normally paint invalidation requests compositing configuration update whenever anything that would
+        affect event region changes. However mutating 'pointer-events' property does not cause paint invalidation.
+
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleWillChange):
+
+        Request compositing update explicitly from the containing layer.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::invalidateEventRegion):
+        * rendering/RenderLayer.h:
+
 2019-04-01  Chris Dumez  <cdumez@apple.com>
 
         Support "noreferrer" for window.open()
index 0b0aa53..5ae8e0f 100644 (file)
@@ -730,6 +730,12 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
             }
         }
 
+        if (m_style.pointerEvents() != newStyle.pointerEvents()) {
+            // Usually the event region gets updated as a result of paint invalidation. Here we need to request an update explicitly.
+            if (auto* layer = enclosingLayer())
+                layer->invalidateEventRegion();
+        }
+
         if (m_parent && (newStyle.outlineSize() < m_style.outlineSize() || shouldRepaintForStyleDifference(diff)))
             repaint();
 
index 5c78fb7..e0107d8 100644 (file)
@@ -6662,6 +6662,12 @@ bool RenderLayer::isTransparentOrFullyClippedRespectingParentFrames() const
     return false;
 }
 
+void RenderLayer::invalidateEventRegion()
+{
+    if (auto* compositingLayer = enclosingCompositingLayerForRepaint())
+        compositingLayer->setNeedsCompositingConfigurationUpdate();
+}
+
 TextStream& operator<<(TextStream& ts, const RenderLayer& layer)
 {
     ts << "RenderLayer " << &layer << " " << layer.size();
index 1db0941..7069c83 100644 (file)
@@ -865,6 +865,8 @@ public:
 
     WEBCORE_EXPORT bool isTransparentOrFullyClippedRespectingParentFrames() const;
 
+    void invalidateEventRegion();
+
 private:
 
     void setNextSibling(RenderLayer* next) { m_next = next; }