Closed Bug 1977306 Opened 1 month ago Closed 1 month ago

Consistently getting a different value from getBoundingClientRect in Firefox compared to Chromium or Safari browsers

Categories

(Core :: Layout: Text and Fonts, defect)

Firefox 140
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: felixhabib, Unassigned)

References

Details

Attachments

(1 file)

Steps to reproduce:

Created CodePen to demonstrate bug: https://codepen.io/felixhabib/pen/ogjXZKO

Actual results:

For Bottom Value as shown in the rendered example I am getting:

  • Firefox: 109.26666259765625
  • Chrome: 107.875
  • Safari: 107.875

If I tweak certain values such as font the difference between Firefox and others may increase or decrease. It is consistently off

Expected results:

I would expect the value in all browser engines be the same, given no other difference

Summary: Consistently getting a different value from getBoundingClientRect in Firefox compared to Chromium or Safari browsers. The issue is shown in this minimal CodePen (https://codepen.io/felixhabib/pen/ogjXZKO) → Consistently getting a different value from getBoundingClientRect in Firefox compared to Chromium or Safari browsers

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Text and Fonts' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Layout: Text and Fonts

Have added h1 padding to override browser styles. new diff values are:

  • Firefox: 206.06666564941406
  • Chrome: 127.875
  • Safari: 127.875

Edit: sometimes Firefox is also showing 129.26666259765625 for the same Codepen

That seems expected given default fonts are different and so on, or what am I missing? If you use the same font and line-height: 1, I suspect that'd decrease the difference substantially. But also, we use different fixed point units (1/60th of a CSS pixel vs 1/64th) so that can also cause differences with fractional values. I think this is invalid at a glance.

Locally on Linux if I force font-family: Times; line-height: 1 (the later might not be needed) I get 122.86666870117188 in Firefox, and 122.875 in Chrome.

I think that difference is due to how we represent CSS pixels. our number is ~7372 app units (60th of a CSS pixel), and Chrome's is 7864 of their internal LayoutUnit (64th of a CSS pixel).

We have bug 1719314 open to consider switching to 1/64th of a pixel, but short of doing that (which has different trade-offs, like not being able to represent thirds exactly) this difference is expected.

Status: UNCONFIRMED → RESOLVED
Closed: 1 month ago
Resolution: --- → INVALID
See Also: → 1719314
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: