Elements with wheel event handlers inside overflow:scroll are missing from the event...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 May 2020 04:30:07 +0000 (04:30 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 30 May 2020 04:30:07 +0000 (04:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212545

Reviewed by Zalan Bujtas.

Source/WebCore:

RenderBlock::paintObject() needs to traverse into descendants if there are are
wheel event handlers on the document, just as it does for elements with touch-action.

Test: fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html

* dom/Document.h:
(WebCore::Document::hasTouchEventHandlers const):
(WebCore::Document::hasWheelEventHandlers const):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):

LayoutTests:

* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt: Added.
* fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebCore/rendering/RenderBlock.cpp

index 3b8dc8e..662e11e 100644 (file)
@@ -1,3 +1,13 @@
+2020-05-29  Simon Fraser  <simon.fraser@apple.com>
+
+        Elements with wheel event handlers inside overflow:scroll are missing from the event region
+        https://bugs.webkit.org/show_bug.cgi?id=212545
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt: Added.
+        * fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html: Added.
+
 2020-05-29  Rob Buis  <rbuis@igalia.com>
 
         Disallow responses when a response contains invalid header values
diff --git a/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt b/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt
new file mode 100644 (file)
index 0000000..ba0091d
--- /dev/null
@@ -0,0 +1,81 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (event region
+        (rect (0,0) width=800 height=600)
+      )
+      (children 1
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 204.00 204.00)
+          (drawsContent 1)
+          (event region
+            (rect (0,0) width=204 height=204)
+            (rect (2,204) width=185 height=188)
+            (rect (22,392) width=100 height=30)
+          (wheel event listener region
+            (rect (22,22) width=100 height=400)
+            (non-passive
+              (rect (22,22) width=100 height=400)
+            )
+          )
+          )
+          (children 2
+            (GraphicsLayer
+              (offsetFromRenderer width=2 height=2)
+              (position 2.00 2.00)
+              (bounds 185.00 185.00)
+              (event region
+                (rect (0,0) width=185 height=185)
+              )
+              (children 1
+                (GraphicsLayer
+                  (offsetFromRenderer width=2 height=2)
+                  (anchor 0.00 0.00)
+                  (bounds 185.00 420.00)
+                  (drawsContent 1)
+                  (event region
+                    (rect (-2,-2) width=204 height=204)
+                    (rect (0,202) width=185 height=218)
+                  (wheel event listener region
+                    (rect (22,22) width=100 height=400)
+                    (non-passive
+                      (rect (22,22) width=100 height=400)
+                    )
+                  )
+                  )
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 200.00 200.00)
+              (children 3
+                (GraphicsLayer
+                  (position 0.00 185.00)
+                  (bounds 185.00 15.00)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 185.00 0.00)
+                  (bounds 15.00 185.00)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 185.00 185.00)
+                  (bounds 15.00 15.00)
+                  (drawsContent 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html b/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html
new file mode 100644 (file)
index 0000000..aac6908
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<style>
+    .scroller {
+        margin: 10px;
+        width: 200px;
+        height: 200px;
+        border: 2px solid gray;
+        overflow: scroll;
+    }
+    .contents {
+        height: 200%;
+    }
+    .handler {
+        background-color: silver;
+        margin: 20px;
+        width: 100px;
+        height: 400px;
+    }
+    </style>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+    
+    window.addEventListener('load', () => {
+        if (window.internals)
+            results.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+    }, false);
+</script>
+<body>
+    <div class="scroller">
+        <div class="contents">
+            <div class="handler" onmousewheel="(void)0">
+            </div>
+        </div>
+    </div>
+<pre id="results"></pre>
+</body>
+</html>
index 72022bc..95d54f5 100644 (file)
@@ -1,3 +1,21 @@
+2020-05-29  Simon Fraser  <simon.fraser@apple.com>
+
+        Elements with wheel event handlers inside overflow:scroll are missing from the event region
+        https://bugs.webkit.org/show_bug.cgi?id=212545
+
+        Reviewed by Zalan Bujtas.
+
+        RenderBlock::paintObject() needs to traverse into descendants if there are are
+        wheel event handlers on the document, just as it does for elements with touch-action.
+
+        Test: fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html
+
+        * dom/Document.h:
+        (WebCore::Document::hasTouchEventHandlers const):
+        (WebCore::Document::hasWheelEventHandlers const):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+
 2020-05-29  Rob Buis  <rbuis@igalia.com>
 
         Disallow responses when a response contains invalid header values
index 948ae46..f2629d2 100644 (file)
@@ -1251,7 +1251,7 @@ public:
     WEBCORE_EXPORT unsigned styleRecalcCount() const;
 
 #if ENABLE(TOUCH_EVENTS)
-    bool hasTouchEventHandlers() const { return (m_touchEventTargets.get()) ? m_touchEventTargets->size() : false; }
+    bool hasTouchEventHandlers() const { return m_touchEventTargets.get() ? m_touchEventTargets->size() : false; }
     bool touchEventTargetsContain(Node& node) const { return m_touchEventTargets ? m_touchEventTargets->contains(&node) : false; }
 #else
     bool hasTouchEventHandlers() const { return false; }
@@ -1280,6 +1280,7 @@ public:
 #endif
     }
 
+    bool hasWheelEventHandlers() const { return m_wheelEventTargets.get() ? m_wheelEventTargets->size() : false; }
     const EventTargetSet* wheelEventTargets() const { return m_wheelEventTargets.get(); }
 
     typedef std::pair<Region, bool> RegionFixedPair;
index 4d29c24..567125e 100644 (file)
@@ -1256,6 +1256,9 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
 #if PLATFORM(IOS_FAMILY)
         needsTraverseDescendants |= document().mayHaveElementsWithNonAutoTouchAction();
 #endif
+#if !PLATFORM(IOS_FAMILY)
+        needsTraverseDescendants |= document().hasWheelEventHandlers();
+#endif
 #if ENABLE(EDITABLE_REGION)
         // We treat the entire text control as editable to match users' expectation even
         // though it's actually the inner text element of the control that is editable.