Commit 76a593e2 authored by Navid Zolghadr's avatar Navid Zolghadr Committed by Commit Bot

Remove selection as default action of mousemove

Selection and dragging should be done regardless
of whether js calls preventDefault on mousemove
or pointermove events according to the spec:

https://w3c.github.io/uievents/#event-type-mousemove

This cl makes Chrome to handle selection/dragging
regardless of return value of js handler to match
other browsers.

Bug: 346473
Change-Id: I71f2c808f224be23ffbc80ee25e2897a9dc9f090
Reviewed-on: https://chromium-review.googlesource.com/1112628Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571553}
parent 5f2b1f71
<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<p id="text">
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
</p>
<script>
var testElem = document.getElementById("text");
testElem.addEventListener("mousemove", function(event) {
event.preventDefault();
}, false);
var testCancelledMouseMoveSelect = async_test('Tests whether cancelled mousemove can start text selection.');
if (window.chrome && chrome.gpuBenchmarking) {
var rect = testElem.getBoundingClientRect();
var text_x = rect.left;
var text_y = rect.top + rect.height / 2;
var pointerActions =
[{source: "mouse",
actions: [
{ name: "pointerDown", x: text_x + 10, y: text_y },
{ name: "pointerMove", x: text_x + 50, y: text_y },
{ name: "pointerMove", x: text_x + 150, y: text_y },
{ name: "pointerMove", x: text_x + 200, y: text_y },
{ name: "pointerUp" }]}];
chrome.gpuBenchmarking.pointerActionSequence(pointerActions, () => {
testCancelledMouseMoveSelect.step(function() {
assert_greater_than(window.getSelection().toString().length, 0);
})
testCancelledMouseMoveSelect.done();
});
}
</script>
......@@ -980,7 +980,11 @@ WebInputEventResult EventHandler::HandleMouseMoveOrLeaveEvent(
event_result = DispatchMousePointerEvent(
WebInputEvent::kPointerMove, mev.InnerNode(), mev.CanvasRegionId(),
mev.Event(), coalesced_events);
if (event_result != WebInputEventResult::kNotHandled)
// https://w3c.github.io/uievents/#event-type-mousemove
// Since there is no default action for the mousemove event issue a
// mouse dragged event irrespective of whether the event is cancelled.
if (event_result != WebInputEventResult::kNotHandled &&
event_result != WebInputEventResult::kHandledApplication)
return event_result;
return mouse_event_manager_->HandleMouseDraggedEvent(mev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment