Bug 163648 - MouseEvent's coordinates should be 0 for simulated clicks
Summary: MouseEvent's coordinates should be 0 for simulated clicks
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
Keywords: WebExposed
: 130301 (view as bug list)
Depends on:
Reported: 2016-10-18 20:45 PDT by Chris Dumez
Modified: 2019-02-06 22:07 PST (History)
13 users (show)

See Also:

Patch (4.99 KB, patch)
2016-10-18 22:52 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (10.05 KB, patch)
2016-10-18 23:22 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.87 KB, patch)
2016-10-18 23:59 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-10-18 20:45:31 PDT
MouseEvent.screenX / screenY should be 0 / 0 for simulated clicks. This is the behavior of Chrome and Firefox.
However, WebKit computes actual screenX / screenY values which requires a synchronous IPC with the UI process.

Demo: https://jsfiddle.net/7nc7ufkh/1/
Comment 1 Chris Dumez 2016-10-18 20:48:52 PDT
https://jsfiddle.net/7nc7ufkh/3/ shows that clientX / clientY are also 0 for simulated clicks in Firefox and Chrome.
Comment 2 Chris Dumez 2016-10-18 20:53:44 PDT
All coordinates (screenX, clientX, x, layerX, offsetX, pageX) are 0 in Firefox and Chrome for simulated clicks. However, they are all populated in Safari.
Comment 3 Chris Dumez 2016-10-18 22:17:31 PDT
Seems to have been caused by <https://trac.webkit.org/changeset/160032>.
Comment 4 Chris Dumez 2016-10-18 22:52:24 PDT
Created attachment 292048 [details]
Comment 5 Darin Adler 2016-10-18 22:55:17 PDT
Comment on attachment 292048 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=292048&action=review

> Source/WebCore/dom/SimulatedClick.cpp:70
> +        } else if (AXObjectCache::accessibilityEnabled()) {
> +            // We apparently need coordinates when accessibility is enabled (see Bug 76677).
> +            // In other cases, the coordinates will be 0, which matches the behavior of Firefox and Chrome.
> +            // Note that the call to screenRect() causes a synchronous IPC with the UI process.

This really doesn’t make sense. It’s OK to decide that accessibility-driven clicks need to include coordinates to be more like clicks done in other ways, but clicks created by JavaScript on the webpage don’t need them. We should not be checking globally whether accessibility is enabled. Instead we should have that code path pass a different argument or call a different function.
Comment 6 Chris Dumez 2016-10-18 23:22:38 PDT
Created attachment 292049 [details]
Comment 7 Chris Dumez 2016-10-18 23:59:20 PDT
Created attachment 292052 [details]
Comment 8 Darin Adler 2016-10-19 10:27:00 PDT
*** Bug 130301 has been marked as a duplicate of this bug. ***
Comment 9 WebKit Commit Bot 2016-10-19 10:49:26 PDT
Comment on attachment 292052 [details]

Clearing flags on attachment: 292052

Committed r207544: <http://trac.webkit.org/changeset/207544>
Comment 10 WebKit Commit Bot 2016-10-19 10:49:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Chris Dumez 2016-10-19 19:28:34 PDT
Looks like a 4% progression on Speedometer.
Comment 12 Lucas Forschler 2019-02-06 09:18:42 PST
Mass move bugs into the DOM component.