[iOS] Redundant pointer events causes material design buttons to flush twice
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 08:03:56 +0000 (08:03 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Apr 2019 08:03:56 +0000 (08:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196914
<rdar://problem/49571860>

Reviewed by Dean Jackson.

Source/WebCore:

Test: pointerevents/ios/pointer-event-order.html

Do not dispatch pointer events for mouse events on iOS since we're already dispatching them when processing touch events.

* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent):

LayoutTests:

Add a new test that listens to all pointer event types as well as click, which forces the dispatch of compatibility mouse events
along with the click which would trigger duplicated pointer events prior to the source changes.

To ensure the new test added runs smoothly with a preceeding test that also uses ui.tap(), we add a delay to guarantee that no
double-taps are seen rather two successive single taps.

* pointerevents/ios/pointer-event-order-expected.txt: Added.
* pointerevents/ios/pointer-event-order.html: Added.
* pointerevents/utils.js:
(const.ui.new.UIController.prototype.tap):

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

LayoutTests/ChangeLog
LayoutTests/pointerevents/ios/pointer-event-order-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/pointer-event-order.html [new file with mode: 0644]
LayoutTests/pointerevents/utils.js
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp

index f6a765a..9049ba7 100644 (file)
@@ -1,3 +1,22 @@
+2019-04-15  Antoine Quint  <graouts@apple.com>
+
+        [iOS] Redundant pointer events causes material design buttons to flush twice
+        https://bugs.webkit.org/show_bug.cgi?id=196914
+        <rdar://problem/49571860>
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that listens to all pointer event types as well as click, which forces the dispatch of compatibility mouse events
+        along with the click which would trigger duplicated pointer events prior to the source changes.
+
+        To ensure the new test added runs smoothly with a preceeding test that also uses ui.tap(), we add a delay to guarantee that no
+        double-taps are seen rather two successive single taps.
+
+        * pointerevents/ios/pointer-event-order-expected.txt: Added.
+        * pointerevents/ios/pointer-event-order.html: Added.
+        * pointerevents/utils.js:
+        (const.ui.new.UIController.prototype.tap):
+
 2019-04-15  John Wilander  <wilander@apple.com>
 
         Add a query string nonce to LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html to address flakiness
diff --git a/LayoutTests/pointerevents/ios/pointer-event-order-expected.txt b/LayoutTests/pointerevents/ios/pointer-event-order-expected.txt
new file mode 100644 (file)
index 0000000..1751b3e
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Testing the order in which pointer events are dispatched and that only one of each event is dispatched, even when a click event is registered. 
+
diff --git a/LayoutTests/pointerevents/ios/pointer-event-order.html b/LayoutTests/pointerevents/ios/pointer-event-order.html
new file mode 100644 (file)
index 0000000..6157630
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../utils.js"></script>
+<script>
+
+'use strict';
+
+target_test({ width: "200px", height: "200px" }, (target, test) => {
+    const eventTracker = new EventTracker(target, ["pointerdown", "pointerenter", "pointerleave", "pointermove", "pointerout", "pointerover", "pointerup", "click"]);
+
+    ui.tap({ x: 100, y: 100 }).then(() => {
+        eventTracker.assertMatchesEvents([
+            { type: "pointerover", x: 100, y: 100, isPrimary: true },
+            { type: "pointerenter", x: 100, y: 100, isPrimary: true },
+            { type: "pointerdown", x: 100, y: 100, isPrimary: true },
+            { type: "pointerup", x: 100, y: 100, isPrimary: false },
+            { type: "pointerout", x: 100, y: 100, isPrimary: false },
+            { type: "pointerleave", x: 100, y: 100, isPrimary: false },
+            { type: "click", x: 100, y: 100 },
+        ]);
+        test.done();
+    });
+}, `Testing the order in which pointer events are dispatched and that only one of each event is dispatched, even when a click event is registered.`);
+
+</script>
+</body>
+</html>
\ No newline at end of file
index 9e31f8b..e836778 100644 (file)
@@ -120,7 +120,11 @@ const ui = new (class UIController {
 
     tap(options)
     {
-        return this._run(`uiController.singleTapAtPoint(${options.x}, ${options.y})`);
+        // Add a delay to ensure sequence of tap() calls don't yield double taps.
+        const delay = 1000;
+        return this._run(`uiController.singleTapAtPoint(${options.x}, ${options.y})`).then(() => {
+            return new Promise(resolve => setTimeout(resolve, delay));
+        });
     }
 
     pinchOut(options)
index cbc275c..5df621b 100644 (file)
@@ -1,3 +1,18 @@
+2019-04-15  Antoine Quint  <graouts@apple.com>
+
+        [iOS] Redundant pointer events causes material design buttons to flush twice
+        https://bugs.webkit.org/show_bug.cgi?id=196914
+        <rdar://problem/49571860>
+
+        Reviewed by Dean Jackson.
+
+        Test: pointerevents/ios/pointer-event-order.html
+
+        Do not dispatch pointer events for mouse events on iOS since we're already dispatching them when processing touch events.
+
+        * dom/Element.cpp:
+        (WebCore::Element::dispatchMouseEvent):
+
 2019-04-15  John Wilander  <wilander@apple.com>
 
         Add a query string nonce to LayoutTests/http/tests/adClickAttribution/send-attribution-conversion-request.html to address flakiness
index 635c7f2..108e824 100644 (file)
@@ -302,7 +302,7 @@ bool Element::dispatchMouseEvent(const PlatformMouseEvent& platformEvent, const
 
     bool didNotSwallowEvent = true;
 
-#if ENABLE(POINTER_EVENTS)
+#if ENABLE(POINTER_EVENTS) && !ENABLE(TOUCH_EVENTS)
     if (RuntimeEnabledFeatures::sharedFeatures().pointerEventsEnabled()) {
         if (auto pointerEvent = PointerEvent::create(mouseEvent)) {
             if (auto* page = document().page())