This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1485205 [wpt PR 12607] - Direct dispatch mouse pointer event by M…
…EM and PEM, a=testonly Automatic update from web-platform-testsDirect dispatch mouse pointer event by MEM and PEM We used to direct dispatch mouse pointer events by a different code path in node.cc. Unlike normal events, these events are created separately and didn't went through EventHandler. This causes extra complexity. This CL changes the direct dispatch code path to dispatch events through PointerEventManager and MouseEventManager, so we can have only one place to create events and further merge the event code path in the future. This patch should cause no change for direct dispatched events other then the click count. The new direct dispatch code path will also update click_count stored in MEM by the WebMouseEvent.click_count. This CL also fixes two issue caused by different code path, 1. direct dispatched pointermove events, (eg. when pointerlocked), didn't havbe getCoalescedEvents. 2. pointer move on chorded mouse button when pointer is locked. Bug: 859132, 665924 Change-Id: Iead9c8135ef58c2bf8e45bd7787cf14334c2e139 Reviewed-on: https://chromium-review.googlesource.com/1134219 Commit-Queue: Ella Ge <eirage@chromium.org> Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/master@{#591834} -- wpt-commits: d4c197a71c0777e839b65c17a59da12b6ddd8d0d wpt-pr: 12607
- Loading branch information
1 parent
84b96ff
commit ebb6385
Showing
6 changed files
with
288 additions
and
4 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
62 changes: 62 additions & 0 deletions
62
...ts/pointerevents/extension/pointerevent_getCoalescedEvents_when_pointerlocked-manual.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,62 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Pointer Events pointer lock tests</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script type="text/javascript" src="../pointerevent_support.js"></script> | ||
<style> | ||
#testContainer { | ||
touch-action: none; | ||
user-select: none; | ||
position: relative; | ||
} | ||
</style> | ||
<script> | ||
var lock_change_count = 0; | ||
var mouseeventMovements = [] | ||
var pointereventMovements = [] | ||
|
||
function resetTestState() { | ||
} | ||
|
||
function run() { | ||
var test_pointerEvent = setup_pointerevent_test("pointermove getCoalescedEvents when lock test", ['mouse']); | ||
var div1 = document.getElementById("target"); | ||
|
||
on_event(div1, 'pointerdown', function(event) { | ||
div1.requestPointerLock(); | ||
}); | ||
on_event(div1, 'pointermove', function(event) { | ||
if (document.pointerLockElement == div1) { | ||
test_pointerEvent.step(function() { | ||
assert_greater_than(event.getCoalescedEvents().length, 0, "document.pointerLockElement should have coalesced events."); | ||
document.exitPointerLock(); | ||
test_pointerEvent.done(); | ||
}); | ||
} | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body onload="run()"> | ||
<h1>PointerMove getCoalescedEvent in locked state test</h1> | ||
<h2 id="pointerTypeDescription"></h2> | ||
<h4> | ||
Test Description: This test checks if pointerevent.getCoalescedEvent work correctly when pointer is locked. | ||
<ol> | ||
<li>Press left button down on the green rectangle to lock pointer.</li> | ||
<li>Move the mouse</li> | ||
</ol> | ||
</ol> | ||
|
||
Test passes if the proper behavior of the events is observed. | ||
</h4> | ||
<div id="testContainer"> | ||
<div id="target" style="width:800px;height:250px;background:green"></div> | ||
</div> | ||
<div class="spacer"></div> | ||
</body> | ||
</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
70 changes: 70 additions & 0 deletions
70
...tform/tests/pointerevents/pointerlock/pointerevent_pointermove_in_pointerlock-manual.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,70 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>pointermove</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- Additional helper script for common checks across event types --> | ||
<script type="text/javascript" src="../pointerevent_support.js"></script> | ||
</head> | ||
<body onload="run()"> | ||
<h2>pointerlock</h2> | ||
<h4>Test Description: This test checks if pointermove is dispatched correctly while in pointerlock mode. | ||
<ol> | ||
<li>Click in the black box (and accept the pointerlock permission if asked).</li> | ||
<li>Move your mouse.</li> | ||
<li>Click in the purple box inside the iframe</li> | ||
<li>Move your mouse.</li> | ||
</ol> | ||
</h4> | ||
<div id="target0"></div> | ||
<iframe id="innerframe" src="resources/pointerevent_pointermove_in_pointerlock-iframe.html"></iframe> | ||
<script> | ||
window.name="outerframe"; | ||
var test_pointermove = async_test("pointermove event received"); | ||
|
||
function run() { | ||
var target0 = document.getElementById("target0"); | ||
var innerframe = document.getElementById('innerframe'); | ||
var target1 = innerframe.contentDocument.getElementById('target1'); | ||
innerframe.contentWindow.name = "innerframe"; | ||
|
||
on_event(document, "pointerlockchange", function(event) { | ||
if (document.pointerLockElement == target0) { | ||
on_event(target0, "pointermove", function (event) { | ||
test_pointermove.step(function() { | ||
assert_equals(event.view.name, "outerframe", "View attribute of pointermove should be the target frame."); | ||
}, "View attribute of pointermove should be the target frame."); | ||
document.exitPointerLock(); | ||
|
||
on_event(target1, "click", function(event) { | ||
target1.requestPointerLock(); | ||
}); | ||
|
||
on_event(innerframe.contentDocument, "pointerlockchange", function(event) { | ||
if (innerframe.contentDocument.pointerLockElement == target1) { | ||
on_event(target1, "pointermove", function (event) { | ||
innerframe_pointermoveReceived = true; | ||
test_pointermove.step(function() { | ||
assert_equals(event.view.name, "innerframe", "View attribute of pointermove should be the target frame."); | ||
}, "View attribute of pointermove should be the target frame."); | ||
innerframe.contentDocument.exitPointerLock(); | ||
test_pointermove.done(); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
on_event(target0, "click", function(event) { | ||
target0.requestPointerLock(); | ||
}); | ||
} | ||
|
||
</script> | ||
<div id="complete-notice"> | ||
</div> | ||
</body> | ||
</html> |
98 changes: 98 additions & 0 deletions
98
...ents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked-manual.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,98 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Pointermove on button state changes</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta name="assert" content="When a pointer changes button state and does not produce a different event, the pointermove event must be dispatched."/> | ||
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- Additional helper script for common checks across event types --> | ||
<script type="text/javascript" src="../pointerevent_support.js"></script> | ||
</head> | ||
<body onload="run()"> | ||
<h2>PointerMove</h2> | ||
<h4>Test Description: This test checks if pointermove event are triggered by button state changes | ||
<ol> | ||
<li>Lick on the black rectangle to lock the pointer </li> | ||
<li>Press a button and hold it</li> | ||
<li>Press a second button</li> | ||
<li>Release the second button</li> | ||
<li>Release the first button to complete the test</li> | ||
</ol> | ||
</h4> | ||
<div id="target0" style="background:black"></div> | ||
<script> | ||
var eventTested = false; | ||
var detected_pointertypes = {}; | ||
var test_pointermove = async_test("pointer locked pointermove events received for button state changes"); | ||
add_completion_callback(showPointerTypes); | ||
|
||
var step = 0; | ||
var firstButton = 0; | ||
var pointer_locked = false; | ||
|
||
function run() { | ||
var target0 = document.getElementById("target0"); | ||
|
||
// When a pointer changes button state and the circumstances produce no other pointer event, the pointermove event must be dispatched. | ||
// 5.2.6 | ||
|
||
on_event(target0, "pointerdown", function (event) { | ||
if (pointer_locked) { | ||
detected_pointertypes[event.pointerType] = true; | ||
test_pointermove.step(function() {assert_true(step === 0, "There must not be more than one pointer down event.");}); | ||
if (step == 0) { | ||
step = 1; | ||
firstButton = event.buttons; | ||
} | ||
} | ||
}); | ||
on_event(target0, "pointermove", function (event) { | ||
if (pointer_locked) { | ||
detected_pointertypes[event.pointerType] = true; | ||
|
||
if (step == 1 && event.button != -1) { // second button pressed | ||
test_pointermove.step(function() {assert_true(event.buttons !== firstButton, "The pointermove event must be triggered by pressing a second button.");}); | ||
test_pointermove.step(function() {assert_true((event.buttons & firstButton) != 0, "The first button must still be reported pressed.");}); | ||
step = 2; | ||
} else if (step == 2 && event.button != -1) { // second button released | ||
test_pointermove.step(function() {assert_true(event.buttons === firstButton, "The pointermove event must be triggered by releasing the second button.");}); | ||
step = 3; | ||
} | ||
} | ||
}); | ||
on_event(target0, "pointerup", function (event) { | ||
if (pointer_locked) { | ||
detected_pointertypes[event.pointerType] = true; | ||
test_pointermove.step(function() {assert_true(step === 3, "The pointerup event must be triggered after pressing and releasing the second button.");}); | ||
test_pointermove.step(function() {assert_true(event.buttons === 0, "The pointerup event must be triggered by releasing the last pressed button.");}); | ||
document.exitPointerLock(); | ||
test_pointermove.done(); | ||
eventTested = true; | ||
} else { | ||
target0.requestPointerLock(); | ||
} | ||
}); | ||
on_event(document, 'pointerlockchange', function(event) { | ||
if (document.pointerLockElement == target0) | ||
pointer_locked = true; | ||
else | ||
pointer_locked = false; | ||
}); | ||
on_event(target0, "mouseup", function (event) { | ||
event.preventDefault(); | ||
}); | ||
on_event(target0, "contextmenu", function (event) { | ||
event.preventDefault(); | ||
}); | ||
} | ||
</script> | ||
<h1>Pointer Lock Pointer Events pointermove on button state changes Tests</h1> | ||
<div id="complete-notice"> | ||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p> | ||
<p>Refresh the page to run the tests again.</p> | ||
</div> | ||
<div id="log"></div> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
...s/pointerevents/pointerlock/resources/pointerevent_pointermove_in_pointerlock-iframe.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,10 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="../../pointerevent_styles.css"> | ||
</head> | ||
<body> | ||
<div id="target1"></div> | ||
</body> | ||
</html> |