Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deviceId to pointer event in blink.
This CL is the first in a series that will introduce deviceId as an attribute of pointer event. This one implements the attribute in blink and the pointer event api. Specification/Explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PointerEventDeviceId/explainer.md Design doc: https://docs.google.com/document/d/1o53mMNRcDnEnt55ftBe8pIPCS0pMlS0CVihs_I8g_UI/edit#heading=h.mx5ptksqe96w Prototype: https://chromium-review.googlesource.com/c/chromium/src/+/4225372 Change-Id: I4a8e506f2cf1602e4b521491dfed49ff036efbbf Bug: 1420685 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4298332 Reviewed-by: Chris Bookholt <bookholt@chromium.org> Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Sahir Vellani <sahir.vellani@microsoft.com> Reviewed-by: Olga Gerchikov <gerchiko@microsoft.com> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1117672}
- Loading branch information
Sahir Vellani
authored and
Chromium LUCI CQ
committed
Mar 15, 2023
1 parent
5f540a7
commit 90de24e
Showing
17 changed files
with
156 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...blink/web_tests/fast/events/pointerevents/device-id/get-device-id-from-pointer-event.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<style> | ||
div { | ||
user-select: none; // Prevents text selection on drag. | ||
} | ||
</style> | ||
<div id="logger" draggable="false"></div> | ||
<div id="console"></div> | ||
<!-- This test verifies that if the PointerEventDeviceId flag is enabled, | ||
pointerEvent.deviceId is null. If not, it is undefined. --> | ||
<script> | ||
function sendPenDragAt(x, y) { | ||
return new Promise(function(resolve, reject) { | ||
if (window.chrome && chrome.gpuBenchmarking) { | ||
var pointerActions = | ||
[{source: "pen", | ||
actions: [ | ||
{ name: "pointerDown", x: x, y: y }, | ||
{ name: "pointerMove", x: x + 3, y: y + 3}, | ||
{ name: "pointerUp" }, | ||
]}]; | ||
chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); | ||
} | ||
else { | ||
reject(); | ||
} | ||
}); | ||
} | ||
|
||
function CheckDeviceId(event) { | ||
eventFired++; | ||
if (self.internals.runtimeFlags.pointerEventDeviceIdEnabled) | ||
assert_equals(event.deviceId, -1, "deviceId is -1"); | ||
else | ||
assert_equals(event.deviceId, undefined, "deviceId is undefined") | ||
} | ||
|
||
window.addEventListener("pointerdown", CheckDeviceId, false); | ||
window.addEventListener("pointermove", CheckDeviceId, false); | ||
|
||
promise_test(async () => { | ||
if (!window.internals) | ||
return; | ||
eventFired = 0; | ||
await sendPenDragAt(100, 100); | ||
assert_true(eventFired == 2); | ||
}, 'PointerEvent.deviceId'); | ||
</script> |
54 changes: 54 additions & 0 deletions
54
...t/events/pointerevents/device-id/pointer-event-has-device-id-from-pointer-event-init.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<script src="../../../../resources/testharness.js"></script> | ||
<script src="../../../../resources/testharnessreport.js"></script> | ||
<div id="console"></div> | ||
|
||
<!-- This test verifies that if the kPointerEventDeviceId flag is enabled, | ||
pointerEvent.deviceId can be set via PointerEventInit. If not, it is | ||
undefined. --> | ||
<script> | ||
function CheckDeviceId(event) { | ||
if (internals.runtimeFlags.pointerEventDeviceIdEnabled) | ||
assert_equals(event.deviceId, 1001, "deviceId is populated"); | ||
else | ||
assert_equals(event.deviceId, undefined, "deviceId is undefined"); | ||
} | ||
|
||
promise_test(async () => { | ||
if (!window.internals) | ||
return; | ||
var downEvent = new PointerEvent("pointerdown", | ||
{pointerId: 1, | ||
bubbles: true, | ||
cancelable: true, | ||
pointerType: "pen", | ||
width: 100, | ||
height: 100, | ||
isPrimary: true, | ||
deviceId: 1001 | ||
}); | ||
CheckDeviceId(downEvent); | ||
var moveEvent = new PointerEvent("pointermove", | ||
{pointerId: 1, | ||
bubbles: true, | ||
cancelable: true, | ||
pointerType: "pen", | ||
width: 100, | ||
height: 100, | ||
isPrimary: true, | ||
deviceId: 1001 | ||
}); | ||
CheckDeviceId(moveEvent); | ||
var upEvent = new PointerEvent("pointeup", | ||
{pointerId: 1, | ||
bubbles: true, | ||
cancelable: true, | ||
pointerType: "pen", | ||
width: 100, | ||
height: 100, | ||
isPrimary: true, | ||
deviceId: 1001 | ||
}); | ||
CheckDeviceId(upEvent); | ||
}, 'PointerEvent.deviceId via PointerEventInit'); | ||
</script> |
2 changes: 2 additions & 0 deletions
2
...ts/virtual/disable-device-id-pointer-event/fast/events/pointerevents/device-id/README.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This test suite runs the tests in fast/events/pointerevents/device-id | ||
with the flag PointerEventDeviceId disabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters