Skip to content

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

@foolip

Description

@foolip

The Screen Interface define screen.width and screen.height in terms of the Web-exposed screen area.

It looks like this has not changed in a long time, since dc36ecd.

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:

<!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?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Regular agenda

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions