Open Bug 1870662 Opened 1 year ago Updated 11 months ago

"rectToScreenRect()" in LayoutUtils.sys.mjs has to return pixels in CSS units

Categories

(Toolkit :: General, defect)

defect

Tracking

()

People

(Reporter: whimboo, Unassigned)

Details

While the getElementBoundingScreenRect() method in this module returns already CSS pixels, the rectToScreenRect method doesn't. This means that based on the device's pixel ratio different results are returned.

Filing this because it's needed for our work on dispatch async events through the parent process in Remote Agent (bug 1773393).

The severity field is not set for this bug.
:mossop, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(dtownsend)

It's not terribly clear why this would block bug 1773393

Severity: -- → S4
Flags: needinfo?(dtownsend)

(In reply to Dave Townsend [:mossop] from comment #2)

It's not terribly clear why this would block bug 1773393

Event specific methods in DOMWindowUtils like for mouse, touch and wheel expect all CSS pixels as input for the coordinates of the event. As such we would need a way to get the CSS pixels from a given rect or point similar to the getElementBoundingScreenRect() method which already returns that.

Are there any reasons why rectToScreenRect actually returns device pixels instead of CSS pixels?

Flags: needinfo?(dtownsend)

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #3)

(In reply to Dave Townsend [:mossop] from comment #2)

It's not terribly clear why this would block bug 1773393

Event specific methods in DOMWindowUtils like for mouse, touch and wheel expect all CSS pixels as input for the coordinates of the event. As such we would need a way to get the CSS pixels from a given rect or point similar to the getElementBoundingScreenRect() method which already returns that.

Are there any reasons why rectToScreenRect actually returns device pixels instead of CSS pixels?

Makoto wrote it so maybe they know but I suspect it is just what was needed at the time. There are very few consumers so you could possibly change the method and all the callers or just add another method there.

Flags: needinfo?(dtownsend)

Interesting that all the existing references for rectToScreenRect are only used under /mobile.

I wonder how changing the result to CSS pixel would affect real Firefox builds on Android. For all the wpt tests we force the layout.css.devPixelsPerPx preference to 1 so we might not see a difference.

Makoto, do you think that we can just change it or do we have to take care of other code as well? Thanks.

Flags: needinfo?(m_kato)

This converts the rectangle to device's pixel scale. Since GeckoView will use mobile viewport.

getElementBoundingScreenRect uses ToScreenRectInCSSUnits, but rectToScreenRect uses ToScreenRect. See both code what different.

Flags: needinfo?(m_kato)
Blocks: 1885073
No longer blocks: parent-actions
No longer blocks: 1885073
You need to log in before you can comment on or make changes to this bug.