W3C home > Mailing lists > Public > public-css-archive@w3.org > May 2021

[csswg-drafts] [cssom-view] Should CSS pixels * devicePixelRatio match OS pixels or screen pixels? (#6314)

From: Jake Archibald via GitHub <sysbot+gh@w3.org>
Date: Wed, 26 May 2021 14:01:02 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-902439575-1622037661-sysbot+gh@w3.org>
jakearchibald has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] Should CSS pixels * devicePixelRatio match OS pixels or screen pixels?  ==
On my 2016 MacBook pro's screen, `screen.width * devicePixelRatio` is 3360, but the screen resolution width is 2880.

On my attached 4k monitor, `screen.width * devicePixelRatio` is 6016, but the screen resolution width is 3840.

This is because OSX doesn't handle devicePixelRatios > 1 but < 2, so the OS renders at a much larger resolution than the screen, and scales down. Other operating systems have a similar issue.

Right now, things like `screen.width` and `devicePixelRatio` represent OS pixels rather than screen pixels.

This discrepancy means websites will create canvases bigger than necessary, and browsers will download images larger than necessary.

Is this something that could be fixed? @smfr is the 'real' devicePixelRatio exposed in OSX?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6314 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 26 May 2021 14:01:07 UTC

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