Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 1bbaac8

Browse files
EiraGechromium-wpt-export-bot
authored andcommitted
Turn on flag kConsolidatedMovementXY
This CL turns on the kConsolidatedMovementXY by default and fix some related tests. This will makes mouse/touch events movementX/Y be calculated in blink instead of in browser. With this change, events other than mousemove/pointermove will have movementX/Y be 0 as per the spec. Also, first event entering an iframe will have 0 movement. Bug: 802067, 977575 Change-Id: Ib3b36aec14240a5c4b8beb4ae4bf9b6156c06d73 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618308 Commit-Queue: Ella Ge <[email protected]> Reviewed-by: Avi Drissman <[email protected]> Reviewed-by: Navid Zolghadr <[email protected]> Reviewed-by: Mustaq Ahmed <[email protected]> Cr-Commit-Position: refs/heads/master@{#684511}
1 parent 67aa02f commit 1bbaac8

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

pointerevents/pointerlock/pointerevent_movementxy.html

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,34 @@
3838
</style>
3939
<script>
4040
var expectedPointerId = NaN;
41-
var startSummation = false;
42-
var lastScreenX = 0;
43-
var lastScreenY = 0;
41+
var lastScreenX = null;
42+
var lastScreenY = null;
4443

4544
function resetTestState() {
46-
startSummation = false;
47-
lastScreenX = 0;
48-
lastScreenY = 0;
45+
lastScreenX = null;
46+
lastScreenY = null;
4947
}
5048

49+
var nonPointermoveEventList = [
50+
"pointerover",
51+
"pointerenter",
52+
"pointerdown",
53+
"pointerup",
54+
"pointerout",
55+
"pointerleave",
56+
"gotpointercapture",
57+
"lostpointercapture"];
58+
5159
function injectInput(pointerType) {
5260
var pointerId = pointerType + "Pointer1";
5361
return new test_driver.Actions()
5462
.addPointer(pointerId, pointerType)
5563
.pointerMove(0, 0, {origin: box1})
5664
.pointerDown()
5765
.pointerMove(20, 30, {origin: box1})
58-
.pointerMove(60, 40, {origin: box1})
66+
.pointerMove(50, 40, {origin: box1})
67+
.pointerMove(80, 30, {origin: box1})
68+
.pointerMove(110, 20, {origin: box1})
5969
.pointerMove(0, 0, {origin: box2})
6070
.pointerUp()
6171
.send();
@@ -65,28 +75,42 @@
6575
var test_pointerEvent = setup_pointerevent_test("pointerevent attributes", ALL_POINTERS);
6676

6777
[document, document.getElementById('innerFrame').contentDocument].forEach(function(element) {
78+
nonPointermoveEventList.forEach(function(eventName) {
79+
on_event(element, eventName, function (event) {
80+
if (lastScreenX && lastScreenY) {
81+
test_pointerEvent.step(function() {
82+
assert_equals(event.movementX, 0, "movementX should be 0 for event other than pointermove.");
83+
assert_equals(event.movementY, 0, "movementY should be 0 for event other than pointermove.");
84+
});
85+
// Reset when entering the new frame.
86+
if (event.type == "pointerenter") {
87+
lastScreenX = null;
88+
lastScreenY = null;
89+
}
90+
}
91+
});
92+
});
93+
6894
on_event(element, 'pointermove', function (event) {
69-
if (startSummation) {
70-
test_pointerEvent.step(function() {
95+
test_pointerEvent.step(function() {
96+
if (lastScreenX && lastScreenY) {
7197
assert_equals(event.movementX, event.screenX - lastScreenX, "movementX should be the delta between current event's and last event's screenX");
7298
assert_equals(event.movementY, event.screenY - lastScreenY, "movementY should be the delta between current event's and last event's screenY");
73-
});
74-
lastScreenX = event.screenX;
75-
lastScreenY = event.screenY;
76-
}
99+
}
100+
});
101+
lastScreenX = event.screenX;
102+
lastScreenY = event.screenY;
77103
});
78104
});
79105
on_event(document.querySelector('#box1'), 'pointerdown', function(event) {
80106
event.target.releasePointerCapture(event.pointerId);
81107
test_pointerEvent.step(function() {
82108
assert_equals(event.pointerType, expectedPointerType, "Use the instructed pointer type.");
83109
});
84-
startSummation = true;
85110
lastScreenX = event.screenX;
86111
lastScreenY = event.screenY;
87112
});
88113
on_event(document.querySelector('#box2'), 'pointerup', function(event) {
89-
startSummation = false;
90114
test_pointerEvent.done();
91115
});
92116

0 commit comments

Comments
 (0)