Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom-view] Should browser zoom affect screen.width? #399

Open
theres-waldo opened this issue Aug 11, 2016 · 9 comments
Open

[cssom-view] Should browser zoom affect screen.width? #399

theres-waldo opened this issue Aug 11, 2016 · 9 comments

Comments

@theres-waldo
Copy link
Contributor

In Firefox and IE/Edge, the browser's zoom level affects screen.width (so that as you increase the zoom, the reported value of screen.width decreases). In Chrome and Safari, it does not.

The spec says:

The width attribute must return the width of the output device, in CSS pixels.

My reading of this is that, since it says "in CSS pixels", Firefox and IE/Edge's behaviour is correct (since zooming in decreases the number of CSS pixels that fit onto the screen).

Due to the implementation divergence, I'd like to double check: is this the intended interpretation?

@theres-waldo
Copy link
Contributor Author

@zcorpan, any opinion on this?

@frivoal
Copy link
Collaborator

frivoal commented Sep 1, 2016

Changing with page zoom but not with pinch zoom would make most sense to me. I have no idea if that's web compatible though.

@zcorpan
Copy link
Member

zcorpan commented Sep 1, 2016

Yes, I intended zooming to affect this. However I would be OK with changing the spec as follows, if implementors think that would be better/more compatible:

  • In the legacy compatible Web-exposed screen mode, report device pixels of the screen (like Chrome/Safari).
  • In the privacy Web-exposed screen mode, report CSS pixel size of the layout viewport

(see https://drafts.csswg.org/cssom-view/#web-exposed-screen-information )

Note that these terms (will) also affect the device-width and related media features; see #426

@theres-waldo
Copy link
Contributor Author

  • In the legacy compatible Web-exposed screen mode, report device pixels of the screen (like Chrome/Safari).
  • In the privacy Web-exposed screen mode, report CSS pixel size of the layout viewport

I'm not sure I follow. Shouldn't the value exposed in privacy mode be the one that doesn't depend on the zoom (so it doesn't expose the zoom level)?

@zcorpan
Copy link
Member

zcorpan commented Sep 5, 2016

Making it not respond to layout zoom changes would actually expose the zoom level. Since you can get the width of the layout viewport (in various ways, e.g. getComputedStyle(someDiv).width), it is better to report the same information from screen.width. Then the site can't tell if the user zoomed or resized the window.

However, I believe there are probably other means already to get the zoom level.

@Demitrius
Copy link

I study task to get the zoom level.

Where is no universal, simple way.

I found one simple way to get zoom factor, just screen.width / window.innerWidth
This works in Chrome and Safari couse screen.width not affects while zooming at this browsers.

In IE, developers use screen.deviceXDPI / screen.logicalXDPI

For FireFox developers use CSS.
Add new style sheet, add media rule, check element, remove all back, details can be found here
Detect Zoom

It would be better to make more ease way to get zoom factor.
For example, window.zoomFactor variable.

@zcorpan
Copy link
Member

zcorpan commented Sep 6, 2016

@Demitrius thank you; please file a new issue with "[cssom-view]" in the title with your feature request. :-)

@theres-waldo
Copy link
Contributor Author

Ok, thanks. I understand now why reporting the CSS pixel size of the viewport (i.e. the spec'd behaviour, and the behaviour implemented by Firefox) is the more privacy-friendly one.

Given that, an alternative suggestion would be:

  • Leave the spec for screen.width as-is (reporting a CSS pixel value)
  • Add a new variable, such as window.pageZoom, to expose the page zoom separately. This would also address [cssom-view] New feature - Zoom factor #449. In privacy mode, this could always report 1.

Looping in @jacobrossi to see what the IE team thinks about the various options.

@hexalys
Copy link

hexalys commented Oct 6, 2016

Right, browser zoom should not affect screen.width nor should it affect screen.outerWidth. In addition to being a pain-point to detect zoom levels. Keep in mind, it also affects the size of a new window, becoming inaccurate when a user has a zoom scale on desktop. I filed that mozilla bug to do just that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants