[Pointer Events] The button and buttons properties are incorrect on iOS
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jul 2019 19:12:58 +0000 (19:12 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Jul 2019 19:12:58 +0000 (19:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199910
<rdar://problem/52778374>

Reviewed by Dean Jackson.

Source/WebCore:

The button and buttons properties were always set to 0 on iOS. We now use the correct values such that
button is always 0 except for "pointermove" where it's -1, and "buttons" is 1 as long as the pointer is
in contact with the touch surface.

Tests: pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html
       pointerevents/ios/pointer-event-button-and-buttons.html

* dom/ios/PointerEventIOS.cpp:
(WebCore::buttonForType):
(WebCore::buttonsForType):
(WebCore::PointerEvent::PointerEvent):

LayoutTests:

* pointerevents/ios/pointer-event-button-and-buttons-expected.txt: Added.
* pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel-expected.txt: Added.
* pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html: Added.
* pointerevents/ios/pointer-event-button-and-buttons.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html [new file with mode: 0644]
LayoutTests/pointerevents/ios/pointer-event-button-and-buttons.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/ios/PointerEventIOS.cpp

index 33c3b03..6969fb1 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-18  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] The button and buttons properties are incorrect on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=199910
+        <rdar://problem/52778374>
+
+        Reviewed by Dean Jackson.
+
+        * pointerevents/ios/pointer-event-button-and-buttons-expected.txt: Added.
+        * pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel-expected.txt: Added.
+        * pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html: Added.
+        * pointerevents/ios/pointer-event-button-and-buttons.html: Added.
+
 2019-07-18  Alex Christensen  <achristensen@webkit.org>
 
         Rebase fast/forms/ios/delete-in-input-in-iframe.html after r244141
diff --git a/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-expected.txt b/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-expected.txt
new file mode 100644 (file)
index 0000000..999e89c
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Testing the values of the button and buttons properties. 
+
diff --git a/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel-expected.txt b/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel-expected.txt
new file mode 100644 (file)
index 0000000..9c0045a
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Testing the values of the button and buttons properties with cancelation. 
+
diff --git a/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html b/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html
new file mode 100644 (file)
index 0000000..b8056cd
--- /dev/null
@@ -0,0 +1,38 @@
+<!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", "pointercancel", "pointerout", "pointerover", "pointerup"]);
+
+    const one = ui.finger();
+    ui.sequence([
+        one.begin({ x: 10, y: 10 }),
+        one.move({ x: 100, y: 100 }),
+        one.end()
+    ]).then(() => {
+        eventTracker.assertMatchesEvents([
+            { type: "pointerover", button: 0, buttons: 1 },
+            { type: "pointerenter", button: 0, buttons: 1 },
+            { type: "pointerdown", button: 0, buttons: 1 },
+            { type: "pointercancel", button: 0, buttons: 0 },
+            { type: "pointerout", button: 0, buttons: 0 },
+            { type: "pointerleave", button: 0, buttons: 0 },
+        ]);
+        test.done();
+    });
+}, `Testing the values of the button and buttons properties with cancelation.`);
+
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons.html b/LayoutTests/pointerevents/ios/pointer-event-button-and-buttons.html
new file mode 100644 (file)
index 0000000..8bcdeae
--- /dev/null
@@ -0,0 +1,40 @@
+<!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"]);
+    target.style.touchAction = "none";
+
+    const one = ui.finger();
+    ui.sequence([
+        one.begin({ x: 10, y: 10 }),
+        one.move({ x: 100, y: 100 }),
+        one.end()
+    ]).then(() => {
+        eventTracker.assertMatchesEvents([
+            { type: "pointerover", button: 0, buttons: 1 },
+            { type: "pointerenter", button: 0, buttons: 1 },
+            { type: "pointerdown", button: 0, buttons: 1 },
+            { type: "pointermove", button: -1, buttons: 1 },
+            { type: "pointerup", button: 0, buttons: 0 },
+            { type: "pointerout", button: 0, buttons: 0 },
+            { type: "pointerleave", button: 0, buttons: 0 },
+        ]);
+        test.done();
+    });
+}, `Testing the values of the button and buttons properties.`);
+
+</script>
+</body>
+</html>
\ No newline at end of file
index 96ce931..43c9b78 100644 (file)
@@ -1,5 +1,25 @@
 2019-07-18  Antoine Quint  <graouts@apple.com>
 
+        [Pointer Events] The button and buttons properties are incorrect on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=199910
+        <rdar://problem/52778374>
+
+        Reviewed by Dean Jackson.
+
+        The button and buttons properties were always set to 0 on iOS. We now use the correct values such that
+        button is always 0 except for "pointermove" where it's -1, and "buttons" is 1 as long as the pointer is
+        in contact with the touch surface.
+
+        Tests: pointerevents/ios/pointer-event-button-and-buttons-pointer-cancel.html
+               pointerevents/ios/pointer-event-button-and-buttons.html
+
+        * dom/ios/PointerEventIOS.cpp:
+        (WebCore::buttonForType):
+        (WebCore::buttonsForType):
+        (WebCore::PointerEvent::PointerEvent):
+
+2019-07-18  Antoine Quint  <graouts@apple.com>
+
         REGRESSION: Unable to enable simulated mouse events using the runtime flag
         https://bugs.webkit.org/show_bug.cgi?id=199909
         <rdar://problem/53254895>
index 11f82fe..71c9373 100644 (file)
@@ -50,6 +50,17 @@ static const AtomString& pointerEventType(PlatformTouchPoint::TouchPhaseType pha
     return nullAtom();
 }
 
+static short buttonForType(const AtomString& type)
+{
+    return type == eventNames().pointermoveEvent ? -1 : 0;
+}
+
+static unsigned short buttonsForType(const AtomString& type)
+{
+    // We have contact with the touch surface for most events except when we've released the touch or canceled it.
+    return (type == eventNames().pointerupEvent || type == eventNames().pointeroutEvent || type == eventNames().pointerleaveEvent || type == eventNames().pointercancelEvent) ? 0 : 1;
+}
+
 Ref<PointerEvent> PointerEvent::create(const PlatformTouchEvent& event, unsigned index, bool isPrimary, Ref<WindowProxy>&& view)
 {
     const auto& type = pointerEventType(event.touchPhaseAtIndex(index));
@@ -62,7 +73,7 @@ Ref<PointerEvent> PointerEvent::create(const String& type, const PlatformTouchEv
 }
 
 PointerEvent::PointerEvent(const AtomString& type, const PlatformTouchEvent& event, IsCancelable isCancelable, unsigned index, bool isPrimary, Ref<WindowProxy>&& view)
-    : MouseEvent(type, typeCanBubble(type), isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.touchLocationAtIndex(index), event.touchLocationAtIndex(index), { }, event.modifiers(), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::No, IsTrusted::Yes)
+    : MouseEvent(type, typeCanBubble(type), isCancelable, typeIsComposed(type), event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.touchLocationAtIndex(index), event.touchLocationAtIndex(index), { }, event.modifiers(), buttonForType(type), buttonsForType(type), nullptr, 0, 0, nullptr, IsSimulated::No, IsTrusted::Yes)
     , m_pointerId(event.touchIdentifierAtIndex(index))
     , m_width(2 * event.radiusXAtIndex(index))
     , m_height(2 * event.radiusYAtIndex(index))