From 67f2185f547efae56c881d6d028fcb36a1c6a9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 17 Aug 2018 21:25:37 +0000 Subject: [PATCH] style: Make webkit device-pixel-ratio media queries a proper alias to resolution. According to the spec: https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio And to the Chromium implementation: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/media_query_evaluator.cc?l=366&rcl=1d7328865bcf06a687aafc18ff95d55317030672 They're no different than resolution. In our implementation `resolution` does slightly different stuff. Given we still haven't shipped -webkit-device-pixel-ratio, making this match resolution looks better than the opposite. Differential Revision: https://phabricator.services.mozilla.com/D3588 --- components/style/gecko/media_features.rs | 10 +++------- components/style/values/computed/resolution.rs | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index 58afc901f48..3595133f55c 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -150,14 +150,10 @@ fn eval_device_pixel_ratio( query_value: Option, range_or_operator: Option, ) -> bool { - let ratio = unsafe { - bindings::Gecko_MediaFeatures_GetDevicePixelRatio(device.document()) - }; - - RangeOrOperator::evaluate( + eval_resolution( + device, + query_value.map(Resolution::from_dppx), range_or_operator, - query_value, - ratio, ) } diff --git a/components/style/values/computed/resolution.rs b/components/style/values/computed/resolution.rs index 817ba082236..d90bdf4867d 100644 --- a/components/style/values/computed/resolution.rs +++ b/components/style/values/computed/resolution.rs @@ -21,6 +21,12 @@ impl Resolution { pub fn dppx(&self) -> CSSFloat { self.0 } + + /// Return a computed `resolution` value from a dppx float value. + #[inline] + pub fn from_dppx(dppx: CSSFloat) -> Self { + Resolution(dppx) + } } impl ToComputedValue for specified::Resolution {