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

[csswg-drafts] [cssom-view] should screen.width and screen.height reflect orientation? (#5204)

From: Philip Jägenstedt via GitHub <sysbot+gh@w3.org>
Date: Fri, 12 Jun 2020 12:11:45 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-637706330-1591963904-sysbot+gh@w3.org>
foolip has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] should screen.width and screen.height reflect orientation? ==
[The `Screen` Interface](https://drafts.csswg.org/cssom-view/#the-screen-interface) define `screen.width` and `screen.height` in terms of the [Web-exposed screen area](https://drafts.csswg.org/cssom-view/#web-exposed-screen-area).

It looks like this has not changed in a long time, since https://github.com/w3c/csswg-drafts/commit/dc36ecd7a46b173f958dafa736a84eb9753afb7b.

A web developer reported having to work around something around screen width/height in combination with orientation, and it looks like implementations disagree here. My test was simply:
```html
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<pre></pre>
<script>
setInterval(() => {
  document.querySelector('pre').textContent = `screen.width = ${screen.width}
screen.height = ${screen.height}
window.orientation = ${window.orientation}`;
}, 100);
</script>
```

Testing this on Chrome for Android and Safari on iOS, I observe that:
- On Chrome, `screen.width` and `screen.height` flip when rotating the phone
- On Safari, `screen.width` and `screen.height` stay the same
- Chrome and Safari agree on what `window.orientation` should be, happily

Is the spec unambiguous on this point? I ask because I can't find any open WebKit bug about this, so I'm doubting the right behavior. (In my reading of the spec, maybe both are allowed?)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5204 using your GitHub account
Received on Friday, 12 June 2020 12:11:46 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:31:27 UTC