[Pointer Events] button property is -1 for pointerdown and pointerup
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 21:17:02 +0000 (21:17 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 21:17:02 +0000 (21:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198868
<rdar://problem/51758109>

Reviewed by Dean Jackson.

Source/WebCore:

A value of -1 for "button", which means there was no change of pressed button since the last event, should only ever be used for "pointermove" events.

Test: pointerevents/mouse/pointer-button-and-buttons.html

* page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::pointerEventForMouseEvent):

LayoutTests:

* pointerevents/mouse/pointer-button-and-buttons-expected.txt: Added.
* pointerevents/mouse/pointer-button-and-buttons.html: Added.
* pointerevents/utils.js:
(prototype._handlePointerEvent):

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

LayoutTests/ChangeLog
LayoutTests/pointerevents/mouse/pointer-button-and-buttons-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/mouse/pointer-button-and-buttons.html [new file with mode: 0644]
LayoutTests/pointerevents/utils.js
Source/WebCore/ChangeLog
Source/WebCore/page/PointerCaptureController.cpp

index 077bf6c..70fefad 100644 (file)
@@ -1,3 +1,16 @@
+2019-06-14  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] button property is -1 for pointerdown and pointerup
+        https://bugs.webkit.org/show_bug.cgi?id=198868
+        <rdar://problem/51758109>
+
+        Reviewed by Dean Jackson.
+
+        * pointerevents/mouse/pointer-button-and-buttons-expected.txt: Added.
+        * pointerevents/mouse/pointer-button-and-buttons.html: Added.
+        * pointerevents/utils.js:
+        (prototype._handlePointerEvent):
+
 2019-06-14  John Wilander  <wilander@apple.com>
 
         Move http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html off of testRunner.setAlwaysAcceptCookies()
diff --git a/LayoutTests/pointerevents/mouse/pointer-button-and-buttons-expected.txt b/LayoutTests/pointerevents/mouse/pointer-button-and-buttons-expected.txt
new file mode 100644 (file)
index 0000000..931b97f
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Testing that the "button" and "buttons" properties report the expected values. 
+
diff --git a/LayoutTests/pointerevents/mouse/pointer-button-and-buttons.html b/LayoutTests/pointerevents/mouse/pointer-button-and-buttons.html
new file mode 100644 (file)
index 0000000..fe836d2
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+</head>
+<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../utils.js"></script>
+<script>
+
+'use strict';
+
+target_test((target, test) => {
+    const eventTracker = new EventTracker(target, ["pointerdown", "pointerup"]);
+
+    // Click without a move.
+    eventSender.mouseMoveTo(50, 50);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    eventTracker.assertMatchesEvents([
+        { type : "pointerdown", x: 50, y: 50, button: 0, buttons: 1 },
+        { type : "pointerup", x: 50, y: 50, button: 0, buttons: 0 },
+    ]);
+    test.done();
+}, `Testing that the "button" and "buttons" properties report the expected values.`);
+
+</script>
+</body>
+</html>
\ No newline at end of file
index f2564e0..4892196 100644 (file)
@@ -69,7 +69,9 @@ class EventTracker
             y: event.clientY,
             pressure: event.pressure,
             isPrimary: event.isPrimary,
-            isTrusted: event.isTrusted
+            isTrusted: event.isTrusted,
+            button: event.button,
+            buttons: event.buttons
         });
     }
 
index 8f00ee1..f1c0f26 100644 (file)
@@ -1,3 +1,18 @@
+2019-06-14  Antoine Quint  <graouts@apple.com>
+
+        [Pointer Events] button property is -1 for pointerdown and pointerup
+        https://bugs.webkit.org/show_bug.cgi?id=198868
+        <rdar://problem/51758109>
+
+        Reviewed by Dean Jackson.
+
+        A value of -1 for "button", which means there was no change of pressed button since the last event, should only ever be used for "pointermove" events.
+
+        Test: pointerevents/mouse/pointer-button-and-buttons.html
+
+        * page/PointerCaptureController.cpp:
+        (WebCore::PointerCaptureController::pointerEventForMouseEvent):
+
 2019-06-14  Megan Gardner  <megan_gardner@apple.com>
 
         Move Synthetic Editing Commands to behind an experimental feature flag
index c50c382..f822abd 100644 (file)
@@ -241,7 +241,7 @@ RefPtr<PointerEvent> PointerCaptureController::pointerEventForMouseEvent(const M
     auto& capturingData = iterator->value;
 
     short newButton = mouseEvent.button();
-    short button = newButton == capturingData.previousMouseButton ? -1 : newButton;
+    short button = (type == names.mousemoveEvent && newButton == capturingData.previousMouseButton) ? -1 : newButton;
 
     // https://w3c.github.io/pointerevents/#chorded-button-interactions
     // Some pointer devices, such as mouse or pen, support multiple buttons. In the Mouse Event model, each button