Commit 3dce8758 authored by donnd@chromium.org's avatar donnd@chromium.org

First-cut at fixing unhandled Tap event returns in Blink.

We want to be able to recognize tap events that the page has not handled and provide some useful default behavior for those events.  Currently taps are considered handled in many cases when they really have not been handled by the page or default behavior.  This CL is a beginning at correcting this.  We plan to also check if the tap interacted with an element with an ARIA role that indicates it was interactive.

BUG=355154

Review URL: https://codereview.chromium.org/267313008

git-svn-id: svn://svn.chromium.org/blink/trunk@175514 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5b5fbb21
This is plain text with no handler
This text consumes events using preventDefault()
Clicking or tapping on the "consumes" section should have no effect on the selection, but clicking in the plain section should clear it.
This tests Tap events being consumed by a handler.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
PASS consumesResult is true
PASS window.getSelection().toString() is not
PASS plainResult is false
PASS window.getSelection().toString() is ""
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test.js"></script>
</head>
<body onload="runTest();">
<input id="input" type="text" value="editable text"><br>
<span id="plain">This is plain text with no handler</span><br>
<span id="consumes">This text consumes events using preventDefault()</span><br><br>
Clicking or tapping on the "consumes" section should have no effect on the selection,
but clicking in the plain section should clear it.
<p id="description"></p>
<div id="console"></div>
<script>
var plainResult = null;
var consumesResult = null;
function plainCallback() {
}
function consumeCallback(event) {
event.preventDefault();
}
function runTest() {
document.getElementById('input').select();
var consumes = document.getElementById('consumes');
consumes.addEventListener("mousedown", consumeCallback, false);
var plain = document.getElementById('plain');
plain.addEventListener("mousedown", plainCallback, false);
if (window.testRunner) {
testRunner.dumpAsText();
}
if (window.eventSender) {
description("This tests Tap events being consumed by a handler.");
// A 'tap' gesture event should generate a sequence of mouse events,
// which do not affect the selection when consumed.
var consumesRect = document.getElementById('consumes').getBoundingClientRect();
consumesResult = eventSender.gestureTap(consumesRect.left, consumesRect.top);
shouldBe('consumesResult', 'true');
shouldNotBe('window.getSelection().toString()', '');
// Tapping on plain text does not consume the event, and clears the selection.
var plainRect = document.getElementById('plain').getBoundingClientRect();
plainResult = eventSender.gestureTap(plainRect.left, plainRect.top);
shouldBe('plainResult', 'false');
shouldBeEmptyString('window.getSelection().toString()');
} else {
debug("This test requires DumpRenderTree. Tap on the text to log.")
}
}
</script>
</body>
</html>
......@@ -538,8 +538,9 @@ bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleSelection(visiblePos));
}
bool handled = updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity);
return handled;
// Updating the selection is considered side-effect of the event and so it doesn't impact the handled state.
updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, granularity);
return false;
}
static inline bool canMouseDownStartSelect(Node* node)
......
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