MouseEvent.screenX/Y coordinate space is weird.
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox99 | --- | fixed |
People
(Reporter: emilio, Assigned: emilio)
References
(Blocks 1 open bug)
Details
Attachments
(8 files, 3 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/x-phabricator-request
|
Details | |
(deleted),
text/html
|
Details | |
(deleted),
text/x-phabricator-request
|
Details |
It converts device pixels to CSS-but-without-zoom pixels. This is a rather odd coordinate space, which causes issues like bug 1741830.
We should probably use CSS pixels consistently (in terms of stuff being web observable), but that probably involves fixing callers that pass screenX/screenY from the child to the parent process to either convert to global screen coordinates, or at least to undo the full zoom conversion.
Then nsIScreenManager could be a bit more explicit about stuff being on global coordinates, to avoid stuff like bug 1741830, but not sure how that would work...
I've seen some related bugs (see the see also field).
Comment 1•3 years ago
|
||
How do other browsers behave? We can't change them just for our own convenience.
Assignee | ||
Comment 2•3 years ago
|
||
Sure, I agree. But at least we should be internally consistent. screen.height / screen.width / etc account for zoom, while screenX doesn't.
Assignee | ||
Comment 3•3 years ago
|
||
The current behavior of not accounting for zoom clearly makes no sense. On a zoomed page I can trivially get screenX/screenY values outside of screen dimensions.
Assignee | ||
Comment 4•3 years ago
|
||
So stuff here is a mess. Chrome changes DPR on zoom like we do but doesn't adjust screen coordinates. But unzoomed does expose CSS pixels.
Safari doesn't change DPR not screen coords on zoom, but does change outerWidth and inner window coords.
So I think making event.screenX/Y return CSS coords consistently is better (but then we need to expose a way of converting to desktop pixels to chrome JS somehow). That said, that's clearly a pre-existing issue, see bug 1741830 comment 21.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 5•3 years ago
|
||
Depends on D138021
Assignee | ||
Comment 6•3 years ago
|
||
Depends on D138024
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 7•3 years ago
|
||
We report window.screen coordinates in CSS space, so it makes sense to do
the same for screen-relative offsets. This requires some front-end fixes
incoming in following patches.
Depends on D138021
Assignee | ||
Comment 8•3 years ago
|
||
If the page is zoomed, its devicePixelRatio will differ from the browser
chrome's. Account for this by converting to device pixels before starting to
scroll.
Depends on D138035
Assignee | ||
Comment 9•3 years ago
|
||
If the page is zoomed, its devicePixelRatio will differ from the browser
chrome's. Account for this by converting to device pixels before starting to
scroll.
Depends on D138036
Assignee | ||
Comment 10•3 years ago
|
||
Android has no full-page zoom, so we are not meaningfully changing behavior.
However, these values are exposed to the GeckoView JS api, surprisingly, yet
viewport scaling and so on can change the CSS to device pixel ratio...
Shouldn't we expose device pixels there instead? Or do the api consumers assume
that those CSS pixels are scaled to the device scale factor somehow (and that's
not working)?
Depends on D138037
Assignee | ||
Comment 11•3 years ago
|
||
Device pixels and desktop pixels are not the same on macOS and Win7.
Expose the desktop-to-device scale to JS and use it appropriately.
Depends on D138038
Comment 12•3 years ago
|
||
Assignee | ||
Comment 13•3 years ago
|
||
This basically undoes bug 1246346. The current behavior is pretty bizarre,
the screenX origin / position doesn't match the mouse event coordinates,
because on windows we return device pixels rather than CSS pixels for the
window coordinates.
This makes behavior consistent with how other browsers report these coordinates
at least on Windows in non-mixed DPI mode, and I think is fine.
In mixed DPI mode, there might indeed be overlapping coordinates, but again I
think that's fine, because the CSS coordinate space of the different monitors
is different. You need to multiply by the devicePixelRatio if you want
coordinates not to overlap.
Depends on D138039
Updated•3 years ago
|
Comment 14•3 years ago
|
||
Comment 15•3 years ago
|
||
Backed out 6 changesets (bug 1753836) for causing mochitest failures in test_event_screenXY_with_zoom
Backout link: https://hg.mozilla.org/integration/autoland/rev/70b17d77834692747e860c50dad2d9dd0d8c1ff2
WARNING - TEST-UNEXPECTED-FAIL | dom/events/test/test_event_screenXY_with_zoom.html | Test timed out. -
[task 2022-02-15T23:06:49.099Z] 23:06:49 WARNING - TEST-UNEXPECTED-FAIL | dom/events/test/test_event_screenXY_with_zoom.html | [SimpleTest.finish()] No checks actually run. (You need to call ok(), is(), or similar functions at least once. Make sure you use SimpleTest.waitForExplicitFinish() if you need it.)
[task 2022-02-15T23:06:49.100Z] 23:06:49 INFO - SimpleTest.ok@SimpleTest/SimpleTest.js:417:16
[task 2022-02-15T23:06:49.100Z] 23:06:49 INFO - afterCleanup@SimpleTest/SimpleTest.js:1416:18
[task 2022-02-15T23:06:49.100Z] 23:06:49 INFO - executeCleanupFunction@SimpleTest/SimpleTest.js:1481:7
[task 2022-02-15T23:06:49.100Z] 23:06:49 INFO - SimpleTest.finish@SimpleTest/SimpleTest.js:1501:3
[task 2022-02-15T23:06:49.100Z] 23:06:49 INFO - killTest@SimpleTest/TestRunner.js:194:22
Assignee | ||
Updated•3 years ago
|
Comment 16•3 years ago
|
||
Comment 17•3 years ago
|
||
Updated•3 years ago
|
Comment 18•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c6094f3a20bd
https://hg.mozilla.org/mozilla-central/rev/893602e4d374
https://hg.mozilla.org/mozilla-central/rev/b5a79abda144
https://hg.mozilla.org/mozilla-central/rev/52840794d1ab
https://hg.mozilla.org/mozilla-central/rev/d1efe8bdd1af
https://hg.mozilla.org/mozilla-central/rev/808f848af710
https://hg.mozilla.org/mozilla-central/rev/d0345eaae543
Description
•