-
Notifications
You must be signed in to change notification settings - Fork 711
[mediaqueries] Consider making device-pixel-ratio a standard alias. #417
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
Comments
The "standard" name is resolution. If there is a strong enough compat dependency on If there is a strong enough compat dependency on |
I'd like to understand how window.devicePixelRatio, the device-pixel-ratio media query, and the resolution media query behave under page zoom in different UAs. There's certainly a lack of interop and we should decide if window.devicePixelRatio and the device-pixel-ratio MQ need to have matching behavior, and whether the resolution MQ and device-pixel-ratio MQ should also match. |
I know you asked about UAs, but as a start, here's the spec point of view: By spec, both window.devicePixelRatio and the resolution media query are supposed to update to reflect changes in page zoom (and not in pinch zoom). I would sure hope that the -vendor-device-pixel-ratio MQ does the same. |
WebKit's position is that window.devicePixelRatio and the device-pixel-ratio MQ are purely about the capabilities of the hardware, and should not change under user zoom. It's bizarre to have different behaviors for page zoom and pinch zoom (users don't understand the difference), and zooming should be under user control; pages should not change their layout or appearance when zoomed. If WebKit were to implement the resolution media query, we would also only do so in a way that does not change with zooming (any kind). |
Results for various UAs (tested on desktop): Chrome: updates all 3 on page zoom. Safari: Updates none of the 3 on page zoom. Firefox: Updates resolution and window.devicePixelRatio on page zoom (-webkit-device-pixel-ratio is not supported (yet)) Edge: updates all 3 on page zoom. |
The spec rationale is that page zoom is something that changes the geometry of the viewport. Its width and height (in CSS pixels) change. Since the hardware is the same, but the CSS pixel geometry is not, the device-pixel-ratio / resolution should change accordingly, otherwise it becomes non nonsensical. As listed above, all other implementations seem to agree on that.
When pinch zooming, I agree 100%. When page-zooming, pages will inevitably change their layout, since page zoom (by definition) changes the size in CSS pixels of the viewport. Page-zoom pretty much boils down to changing the device-pixel to CSS-pixel ratio, and redoing layout based on that. I would find it pretty strange if that was not reflected in the relevant MQ and OM. |
@smfr Is apple likely to want to give resolution and device-pixel-ratio different semantics with regards to page zoom? Everybody else that has both makes them equal (and makes then react to page zoom). Even though I disagree with you about whether page-zoom should affect the query, I agree it is a valid discussion to have. However, unless you're expecting to make |
I am cautiously OK with page zoom (aka Command-plus) changing the resolution and device-pixel-ratio media queries, as long as pinch zoom does not, but I still worry about authors not really understanding the difference. |
Great. And btw, I am firmly with you on pinch zoom not affecting these. Anything else would be a major headache.
I think this is one of those topics where the consequences are reasonably intuitive if you just interact with it and don't think about it, but is easily confusing when you just think a little about it. For any topic that involves the CSS pixel, that seems to be the case. It does what people want, but the why seems to be highly unintuitive to many people. I have kind of resigned myself to the idea that people who start diving into how CSS work will forever be confused about that, until they see the whole picture (which takes quite some determination, given the number of interlocking pieces in this puzzle, some of which have yet to be specified properly). |
In addition to the discussion in this bug, this was talked about at https://lists.w3.org/Archives/Public/www-style/2016Sep/0000.html We probably need to revisit to wrap up. My position:
Agenda+ing to try to deal with 1+2+3 |
I think you meant to say "page zoom" rather than "pinch zoom" here, didn't you? |
I did, sorry. (I'll fix my original comment for the benefit of those coming here later). |
+1 to both of these statements. We implemented So adding So far I've heard 2 arguments for adding it:
As a reminder, the proposal on the call was to add For 2, if we're open to alternative names in general, then I'd say both |
I doubt that it is. Regardless of their likeability, both |
Fwiw, my position 100% matches Florian's comment #417 (comment) (Also, I don't understand why you think |
Resolution is a bit ambiguous in practice. Some possible “values”:
|
@Crissov said it well, plus notice none of his examples are the recommendable To be clear I'm not suggesting we should go reopen that conversation right now -- it's not particularly productive to go duplicate functionality again. But if we're really considering adding another unprefixed duplication of functionality to the platform then we can do better than |
The CSSWG has resolved not to add As for the other sub-topics discussed here:
|
@wisniewskit As your suggestion has been rejected by the CSSWG, we would like you to confirm that you are willing to accept the conclusion. If not, you can raise a formal objection. |
Thanks for following up. I'm don't have a strong opinion on the decision, so I'm alright with it, but I'm not 100% sure if @dbaron has any objections (based on his comments in the Firefox bug I initially mentioned). |
In Firefox bug 771329 we're discussing whether it's worthwhile to add an unprefixed version of -webkit-device-pixel-ratio, since its use seems to be ingrained with web developers (instead of using resolution media-queries with dppx units).
Given that traction, it seems reasonable to discourage the use of prefixes by adding it (and its min/max counterparts) as aliases in the official spec, similarly to how it is described in the whatwg compatibility spec: https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio
The text was updated successfully, but these errors were encountered: