W3C home > Mailing lists > Public > public-css-archive@w3.org > June 2020

[csswg-drafts] [cssom-view] Need to define how fractional lengths are converted to integers. (#5259)

From: Emilio Cobos Álvarez via GitHub <sysbot+gh@w3.org>
Date: Thu, 25 Jun 2020 00:09:40 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-645054390-1593043778-sysbot+gh@w3.org>
emilio has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] Need to define how fractional lengths are converted to integers. ==
There are various APIs in the OM which return integer sizes. Some of them:

 * `Window.{inner,outer}{Width,Height}`.
 * `Window.screen{X,Y,Top,Left}`.
 * `Screen.avail{Width,Height}`.
 * `Screen.{width,height}`.
 * `Element.offset{Top,Left,Bottom,Right}`.
 * `Element.scroll{Width,Height}`.

These return CSS pixels, and that means that in the current world of HiDPI screens and different screen resolutions, are all lossy.

Browsers do different things when converting these from fractional CSS pixels to an integer:

 * Gecko rounds.
 * WebKit (and Blink, inherited) [truncate, unless you're very close to the next pixel, in which case they round](https://webkit-search.igalia.com/webkit/rev/1a21ea4f0412c19723191e5cfec93ea075870810/Source/WebCore/css/CSSPrimitiveValue.h#57-62). Which is a bit odd but hey.

It seems ideally we should have interop. I think some (if not all) of these (specially window sizes) would benefit from returning doubles, will file an issue on this. But it seems some agreement on what to do here would be on point.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5259 using your GitHub account
Received on Thursday, 25 June 2020 00:09:41 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:09 UTC