Bug 78087 - Enable the 'resolution' media query by default
Summary: Enable the 'resolution' media query by default
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Sam Sneddon [:gsnedders]
URL:
Keywords: BrowserCompat, InRadar
Depends on: 99077 100231 100382 229776 229777 236734
Blocks: 16832 93304
  Show dependency treegraph
 
Reported: 2012-02-08 01:26 PST by Simon Fraser (smfr)
Modified: 2022-05-26 09:52 PDT (History)
23 users (show)

See Also:


Attachments
Patch (1.46 KB, patch)
2021-12-10 10:33 PST, Sam Sneddon [:gsnedders]
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2012-02-08 01:26:57 PST
Need to implement
http://dev.w3.org/csswg/css3-mediaqueries/#resolution0

See FIXME in MediaQueryEvaluator.cpp:
FIXME: following media features are not implemented: color_index, scan, resolution
Comment 1 Simon Fraser (smfr) 2012-02-08 01:28:11 PST
This should do the right thing when printing too (report printer output resolution).
Comment 2 Simon Fraser (smfr) 2012-02-08 01:43:21 PST
Also need to match what other browsers do when pageScale changes.
Comment 3 Radar WebKit Bug Importer 2012-02-08 12:03:32 PST
<rdar://problem/10829378>
Comment 4 Eric Meyer 2012-04-17 07:14:09 PDT
If you want a quick initial test, http://meyerweb.com/eric/css/tests/mq-valueless.html includes valueless, iPhone 4S value (I think), and min/max queries.  See test 11.  If not, no harm done.
Comment 5 Theresa O'Connor 2012-06-27 10:20:59 PDT
General comment: It's not clear to me why we would implement the resolution media query, considering how broken it is.

Eric, that isn't the correct iPhone 4S value per the spec, because the CSS dpi unit is "physical pixels per CSS inch" and a CSS inch is 96 CSS pixels. So "resolution: 192dpi" should match on an iPhone 4S.
Comment 6 Seo Sanghyeon 2012-06-27 21:46:32 PDT
How does this relate to bug 85262?
Comment 7 Simon Fraser (smfr) 2012-06-27 21:59:37 PDT
(In reply to comment #6)
> How does this relate to bug 85262?

That is about a new CSS property based on the resolution of image resources. This is about a media query based on screen resolution.
Comment 8 Adele Peterson 2012-10-23 10:01:19 PDT
Should we dupe this to https://bugs.webkit.org/show_bug.cgi?id=99077?
Comment 9 Kenneth Rohde Christiansen 2012-10-23 10:05:06 PDT
(In reply to comment #8)
> Should we dupe this to https://bugs.webkit.org/show_bug.cgi?id=99077?

It still need some special handling when printing as smfr pointed out, but maybe that is another bug
Comment 10 Kenneth Rohde Christiansen 2012-10-24 05:12:04 PDT
(In reply to comment #2)
> Also need to match what other browsers do when pageScale changes.

According to https://bugzilla.mozilla.org/show_bug.cgi?id=662061 zooming ( and I assume pageScale) should not affect the resolution values.

It currently does in Firefox 16, at least full page zoom, though not text size zoom.
Comment 11 Simon Fraser (smfr) 2013-09-09 14:04:01 PDT
Support for the 'resolution'  media query was added behind ENABLE(RESOLUTION_MEDIA_QUERY) via bug 99077.
Comment 12 Albert Scheiner 2014-12-13 20:26:10 PST
Are there any plans to enable it by default any time soon? Once dppx support lands in IE (it's currently in preview built) all other major browser have added full support.

http://dabblet.com/gist/7166616
https://status.modern.ie/dppxunitfortheresolutionmediaquery?term=dppx
Comment 13 Chris Rebert 2015-10-05 12:39:13 PDT
MS Edge has shipped this (see http://caniuse.com/#feat=css-media-resolution ), so now only WebKit doesn't support this.
Comment 14 Mattia Astorino 2020-07-23 12:22:19 PDT
This bug was filed 8 years ago, even IE 9 supports this important media query. What happened here? 😕
Comment 15 Brent Fulgham 2021-08-24 15:43:36 PDT
(In reply to Mattia Astorino from comment #14)
> This bug was filed 8 years ago, even IE 9 supports this important media
> query. What happened here? 😕

The media query has existed in WebKit since 2012. It looks like some details specific to printing were not completed

@Mattia: What issues have you had when you used the 'resolution' media query in Webkit? Were you attempting printing?
Comment 16 Brent Fulgham 2021-08-24 17:22:26 PDT
(In reply to Brent Fulgham from comment #15)
> (In reply to Mattia Astorino from comment #14)
> > This bug was filed 8 years ago, even IE 9 supports this important media
> > query. What happened here? 😕
> 
> The media query has existed in WebKit since 2012. It looks like some details
> specific to printing were not completed
> 
> @Mattia: What issues have you had when you used the 'resolution' media query
> in Webkit? Were you attempting printing?

I see - it's present but apparently not enabled by default? I'm trying to see what the correct state of this flag should be.
Comment 17 Sam Sneddon [:gsnedders] 2021-08-25 00:35:19 PDT
(In reply to Brent Fulgham from comment #16)
> (In reply to Brent Fulgham from comment #15)
> > (In reply to Mattia Astorino from comment #14)
> > > This bug was filed 8 years ago, even IE 9 supports this important media
> > > query. What happened here? 😕
> > 
> > The media query has existed in WebKit since 2012. It looks like some details
> > specific to printing were not completed
> > 
> > @Mattia: What issues have you had when you used the 'resolution' media query
> > in Webkit? Were you attempting printing?
> 
> I see - it's present but apparently not enabled by default? I'm trying to
> see what the correct state of this flag should be.

Correct; ENABLE_RESOLUTION_MEDIA_QUERY is not defined for any current port, as far as I can tell (and that's likely been the case since the Blink fork). It doesn't look like there's anything too likely to have bitrotted or is missing there, at least.

(In reply to Theresa O'Connor from comment #5)
> General comment: It's not clear to me why we would implement the resolution
> media query, considering how broken it is.

The thread starting at https://lists.w3.org/Archives/Public/www-style/2012Apr/0674.html is about this brokenness, and summarised in Maciej's response in https://lists.w3.org/Archives/Public/www-style/2012Apr/0747.html:

> For comparison, device-pixel-ratio was first implemented as a vendor extension in 2006[1] and exists (prefixed) in at least WebKit, Presto and Gecko. So I wondered why device-pixel-ratio counts as "add[ing] anything new" but the [first defined in late 2011/early 2012] dppx unit does not. I don't follow closely, so maybe there is some reason for diverging from content and implementations here.

Regardless, while it might be the case that resolution: [n]dppx (and the other <resolution> units, aside from dppx, are confusing) is redundant with -webkit-device-pixel-ratio: n (which is itself now standardised in https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio), I think it's pretty clear the ship here has sailed.
Comment 18 Sam Sneddon [:gsnedders] 2021-12-10 10:33:48 PST
Created attachment 446755 [details]
Patch
Comment 19 EWS 2021-12-10 13:57:34 PST
Committed r286874 (245104@main): <https://commits.webkit.org/245104@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446755 [details].
Comment 20 WebKit Commit Bot 2022-02-16 14:37:49 PST
Re-opened since this is blocked by bug 236734
Comment 21 Sam Sneddon [:gsnedders] 2022-02-18 05:50:02 PST
bug 236804 reverted the revert; this shouldn't have been reverted on trunk for that breakage
Comment 22 matthew.wade 2022-05-25 09:58:28 PDT
I'm having trouble understanding the recent commits / reverts on this.

Is there an intent to *enable* the 'resolution' media query by default in Webkit (Safari)?

Or when we say "that ship has sailed," are we saying that Safari will continue to *not* support the 'resolution' media query in lieu of the '-webkit-device-pixel-ratio' feature?
Comment 23 Sam Sneddon [:gsnedders] 2022-05-25 11:03:28 PDT
(In reply to matthew.wade from comment #22)
> I'm having trouble understanding the recent commits / reverts on this.
> 
> Is there an intent to *enable* the 'resolution' media query by default in
> Webkit (Safari)?
> 
> Or when we say "that ship has sailed," are we saying that Safari will
> continue to *not* support the 'resolution' media query in lieu of the
> '-webkit-device-pixel-ratio' feature?

It is enabled by default, and has been on trunk since December. It was disabled on one Safari release branch (and, inadvertently also on trunk briefly) due to site breakage caused by enabling it (mostly sites using `@media not all and (min-resolution:.001dpcm)` to specifically target WebKit, which inevitably stops matching with support for the resolution feature).

As for Safari, Apple does not comment on future releases.
Comment 24 matthew.wade 2022-05-26 09:52:13 PDT
(In reply to Sam Sneddon [:gsnedders] from comment #23)
> (In reply to matthew.wade from comment #22)
> > I'm having trouble understanding the recent commits / reverts on this.
> > 
> > Is there an intent to *enable* the 'resolution' media query by default in
> > Webkit (Safari)?
> > 
> > Or when we say "that ship has sailed," are we saying that Safari will
> > continue to *not* support the 'resolution' media query in lieu of the
> > '-webkit-device-pixel-ratio' feature?
> 
> It is enabled by default, and has been on trunk since December. It was
> disabled on one Safari release branch (and, inadvertently also on trunk
> briefly) due to site breakage caused by enabling it (mostly sites using
> `@media not all and (min-resolution:.001dpcm)` to specifically target
> WebKit, which inevitably stops matching with support for the resolution
> feature).
> 
> As for Safari, Apple does not comment on future releases.

Thanks, this is very helpful! Also, you practically read my mind with the `@media not all and (min-resolution: .001dpcm)` hack, I was essentially asking how "safe" that is to continue using as a way to detect Safari. Based on all this, my guess is the answer is basically "it still works in the latest Safari, but could stop working at any time."

I didn't realize the split between Webkit and how Apple uses it in Safari releases, so thanks for that context as well.