Input element gains focus when a selectstart event listener on document prevents...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2018 00:12:25 +0000 (00:12 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2018 00:12:25 +0000 (00:12 +0000)
commite40f6993e4fb0a1a7142782b223cfdfe6c17931b
tree73313b4a13da5428870505dc3d45a21f641b89ca
parentc3aca9116774c47372ad13e035f0aa5922a07ff3
Input element gains focus when a selectstart event listener on document prevents the default action
https://bugs.webkit.org/show_bug.cgi?id=191714
<rdar://problem/46174389>

Reviewed by Antti Koivisto.

Source/WebCore:

The bug was caused by WebKit keep firing selectstart upon mousemove after the drag had already started
when preventDefault had been called in the previous firings of selectstart event. Because input element
has its own editable element and fires selectstart on the input element itself, which won't be prevented
by selectstart on docuemnt, this allowed the selection to be set inside the input element even though
the mouse cursor was simply passing over the input element after the drag had already started.

Fixed the bug by not firing selectstart if the default action had been prevented by the initial firing
of selectstart by setting m_mouseDownMayStartDrag to false. This also matches the behaviors of Chrome
and Firefox.

Test: fast/events/selectstart-prevent-default-should-not-focus-input.html

* page/EventHandler.cpp:
(WebCore::EventHandler::updateSelectionForMouseDownDispatchingSelectStart):
(WebCore::EventHandler::updateSelectionForMouseDrag):

LayoutTests:

Added a regression test.

* fast/events/selectstart-prevent-default-should-not-focus-input-expected.txt: Added.
* fast/events/selectstart-prevent-default-should-not-focus-input.html: Added.
* platform/ios/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238409 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/events/selectstart-prevent-default-should-not-focus-input-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/selectstart-prevent-default-should-not-focus-input.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp