Mouse release on AutoFill button activates it; should only activate on click
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2015 00:23:45 +0000 (00:23 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2015 00:23:45 +0000 (00:23 +0000)
commitf4ef491f2a35cb70f2d7cc03cef5cbf5a6e3f521
tree99f60d034f9e12cbca26e539480e62db480bb47a
parentb7a559a6e7760d1787c603ba275663198c65e779
Mouse release on AutoFill button activates it; should only activate on click
https://bugs.webkit.org/show_bug.cgi?id=145774
<rdar://problem/21069245>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Fixes an issue where a click event was dispatched to a shadow tree node regardless of whether
both the mouse press and mouse release were targeted at it. In particular, releasing the mouse
on the AutoFill button activates it regardless of whether the mouse was pressed on it.

Currently we always dispatch a click event to a node n where the mouse was released when n is
in a shadow tree regardless of whether the mouse was pressed on n. Instead we should only
dispatch a click event to n if the mouse was pressed and released on n. If n is a shadow tree
descendant, the mouse was released on n, and n never received a mouse press then we should
dispatch the click event at the shadow host element of n to preserve the illusion to web
developers that the shadow host element is a single element.

Test: fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button.html

* page/EventHandler.cpp:
(WebCore::targetNodeForClickEvent): Added; returns the target node for the DOM click event.
(WebCore::EventHandler::handleMouseReleaseEvent): Modified to use dispatch the DOM click event
at the node returned by targetNodeForClickEvent().
(WebCore::mouseIsReleasedOnPressedElement): Deleted.

LayoutTests:

Add test to ensure we only dispatch a click event at the HTML input element when pressing
on the editable portion of the input element and releasing the mouse on the AutoFill button.

* fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button-expected.txt: Added.
* fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185341 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp