Closed Bug 771329 Opened 12 years ago Closed 8 years ago

unprefix device-pixel-ratio media query

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: dbaron, Assigned: dbaron)

References

(Blocks 1 open bug)

Details

Due to high author demand for the feature, and despite the bad syntax and availability of a better standard alternative (see bug 741644), we should unprefix the device-pixel-ratio media query since Apple has baked it into the minds of Web authors enough that it's not going away, and we're just going to keep getting asked about our support for it.
I have no objection to implementing 'resolution' and '-webkit-device-pixel-ratio', but I don't agree with implementing 'device-pixel-ratio' if there's no really strong Web-compat reason to do so.
Additionally, if we decide there's a really strong Web-compat reason to do so, then we should present that data to the CSSWG and get this into Media Queries Level 4. It's not helping the Web if we're the only ones implementing it.

I'll note that even our own documentation on MDC does not say anything about using 'resolution' in place of '-moz-device-pixel-ratio', so we have no claim to making *any* attempt to shift authors to using standard media queries before implementing some non-standard equivalent and encouraging authors to use that.
The problem is that because of retina displays, this is a higher-visibility feature for Web authors right now than almost anything else in CSS, and Apple has won the debate over what it's called.
(In reply to fantasai from comment #2)
> I'll note that even our own documentation on MDC does not say anything about
> using 'resolution' in place of '-moz-device-pixel-ratio', so we have no
> claim to making *any* attempt to shift authors to using standard media
> queries before implementing some non-standard equivalent and encouraging
> authors to use that.

Also, it's not equivalent until we make the change to switch 'dpi' units to be dots per CSS inch rather than dots per physical inch.
Blocks: unprefix
Did bug 1176968 fix this fully, or is it conditional on the webkit prefix pref?
Flags: needinfo?(dholbert)
Or did it only add the -webkit- version and not the unprefixed?
Er, looks like it's only the prefixed one.
Flags: needinfo?(dholbert)
Correct, we only added the prefixed one (and it's conditional on the webkit pref).

I don't think we want to support this feature, in an unprefixed form, since it's non-standard.  (I added tests to be sure we don't accidentally support it, e.g.
> expression_should_not_be_parseable("device-pixel-ratio: 1.0");
https://bugzilla.mozilla.org/attachment.cgi?id=8685148&action=diff#a/layout/style/test/test_media_queries.html_sec3

Should we WONTFIX this bug, now that we support the webkit-prefixed version (which is the version that Apple has baked into the minds of web developers, per comment 0)?  Or perhaps re-scope this bug & dupe it to bug 1176968?
I tend to think we probably should support the unprefixed version.  I think it's something where Apple's way turned out to be easier to use, and we should probably switch to it.  It's probably worth checking that we actually agree with them on behavior, though; there may actually be differences.

That said, my patch that I've had around is current.
https://hg.mozilla.org/users/dbaron_mozilla.com/patches/raw-file/bdc19e2a46df/unprefix-device-pixel-ratio

(Need to retest the patch now, though, since I just fixed up the tests.)
(In particular, I think it was by-design that Apple's query is constant per-device rather than changing with zoom.)
I'm with dbaron on supporting the unprefixed version of device-pixel-ratio. Is there really any reason to not support the unprefixed version?
Flags: needinfo?(dholbert)
Seems fine to me -- though we should probably make sure it's specced somewhere (probably via the CSS Working Group).
Flags: needinfo?(dholbert)
Thanks, that actually does yield a reason to not support it: it's already in the standard as the "resolution" media query, by using dppx units[1].

What do you think, dbaron? Since -webkit-device-pixel-ratio is in the new compatibility spec[2] as well, I'm not sure if it's worth trying to get everyone to standardize on an alias for something else that's already standard.

[1] https://www.w3.org/TR/mediaqueries-4/#resolution
[2] https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio
Flags: needinfo?(dbaron)
device-pixel-ratio is the thing developers understand.  Given that, I think we're better supporting it both with and without -webkit- prefixes rather than only with.
Flags: needinfo?(dbaron)
Sure, I'd still prefer adding it (and its min/max counterparts) as aliases, if for no other reason than to discourage the use of prefixes in general.

I've filed a new github spec issue: https://github.com/w3c/csswg-drafts/issues/417
Flags: needinfo?(dholbert)
(In reply to David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) from comment #14)
> device-pixel-ratio is the thing developers understand.  Given that, I think
> we're better supporting it both with and without -webkit- prefixes rather
> than only with.

Just to clarify -- note that we probably *aren't* shipping support for the webkit-prefixed version in the forseeable future, as long as bug 1239922 comment 0 problem "(2)" remains the case.  (It happens to opt us in to CSS that breaks Google Docs.)

So, "supporting it both with and without prefixes" is also probably not a configuration we'll be shipping anytime soon.  If we land unprefixed support, we'd be going from no support to unprefixed-only support, by default at least.

(And that's fine - just wanting to clarify the actual future possibilities here.)
Flags: needinfo?(dholbert)
(In reply to Daniel Holbert [:dholbert] from comment #16)
> If we land unprefixed support, we'd be going from no support
> to unprefixed-only support, by default at least.

Er -- correcting myself -- I suppose we *are* currently shipping support for the moz-prefixed version (as "min--moz-device-pixel-ratio" & "max-[etc]") so we'd actually be going from only-supporting-that to also supporting the unprefixed version.
Based on https://github.com/w3c/csswg-drafts/issues/417, the spec maintainers would rather just add the -webkit prefixed variant to the spec if there is enough usage of that variant, as the "resolution" media query  is the standard version already. They don't consider unprefixing this variant worthwhile unless:

>there is a strong enough compat dependency on device-pixel-ratio (without prefix) as well, we should add that name as well. But I do not think we should add it for the sake of completeness or for encouraging a non prefixed name if there is no compat dependency. A profusion of names of the same feature doesn't really help anyone (unless, again, these names are needed for compat).

In light of that, I guess unprefixed this isn't going to be accepted. I can't say that I'm a fan of legitimizing a prefix by adding the -webkit prefixed version to the official spec either, now that we have a Compatibility spec.

What do you guys think?
Flags: needinfo?(dholbert)
Flags: needinfo?(dbaron)
I don't have much to add at this point, except to say that I weakly agree with what dbaron already expressed in comment 0 and comment 18 (though I'm also curious what in-the-wild usage data says about the relative usage of '-webkit-device-pixel-ratio' vs. 'resolution').
Flags: needinfo?(dholbert)
Just a quick update; Florian B just put the matter back on the w3c agenda to wrap it up:

>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:
> 
>1. I don't think it helps to add (unprefixed) device-pixel-ratio as
>an alias, but I wouldn't object to it if others want it.
>
>2. I do not have data, but I believe there is a compat dependency on
>-webkit-device-pixel-ratio, so adding that as an alias sounds OK to
>me. It's already in the Compat spec, but I think we should internalize
>such things into our own spec. I would not object if people insisted
>on keeping the two separate.
> 
>3. if we do add device-pixel-ratio (prefixed or not) as an alias, it
>should behave exactly the same as resolution. Anything else would be
>highly confusing, and I would probably object.
> 
>4. Currently the specs (MQ + CSSOM-View) agree with everybody-but-safari
>that pinch zoom does affect device-pixel-ratio / resolution If someone
>(apple) wants to change that, I suggest a separate issue.
> 
>Agenda+ing to try to deal with 1+2+3
Final update from the CSSWG:

>The CSSWG has resolved not to add device-pixel-ratio (unprefixed). Based on this I am closing this
>issue as rejcted.
> 
>As for the other sub-topics discussed here:
> 
>- We have not reached consensus as to whether we should include -webkit-device-pixel-ratio in the
>Media Query spec or leave it in the compat spec where it currently is. A few people (at least
>@tabatkins Tab and I) think we should include it, but there are others (at least @atanassov) who
>feel quite strongly that we should not. As it doesn't seem we will agree, I'm willing to drop the
>issue and settle for the status quo. @tabatkins (or anyone else who thinks this is important), if
>you'd like to keep pushing, I suggest you open a separate issue about that.
> 
>- Apple is considering changing webkit's behavior to align with the spec and other implementations,
>and make page zoom affect resolution. If they decide against in, they should file a bug against the spec.
> 
>- If Apple changes their implementation of resolution as discussed in the previous point, they are
>unsure whether to keep -webkit-device-pixel-ratio a strict alias of resolution, or have it preserve
>the historical behavior, but lean towards the later one. If they decide that these should not be
>strict aliases, they should file a bug against the spec, which defines them to be.

Based on that, it sounds like this bug should be closed as WONTFIX/INVALID, and that just supporting 'resolution' and '-webkit-device-pixel-ratio' is indeed the way to go.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Flags: needinfo?(dholbert)
Resolution: --- → WONTFIX
Could you check that there's a bug filed on the first paragraph of comment 9 and comment 10 (if needed)?

I'm still unhappy about this, and a bit annoyed that the CSSWG decided it on a call where I wasn't present.

I don't think we should have broken our policy of adding -webkit- prefixed things that we didn't add unprefixed support for.
Flags: needinfo?(dbaron) → needinfo?(wisniewskit)
... which is the same as the last 2 bullet points of comment 21.
See Also: → 1324307
Sure, I just filed bug 1324307 (though I don't see any bugs filed against WebKit about this yet, or any posts on webkit-dev as of the 14th, so I'm not sure where/when we'll figure out what their decisions are regarding those bullet-points).
Flags: needinfo?(wisniewskit)
Flags: needinfo?(dholbert)
You need to log in before you can comment on or make changes to this bug.