aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-08-17 21:25:37 +0000
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-08-18 17:54:54 +0200
commit67f2185f547efae56c881d6d028fcb36a1c6a9bf (patch)
treed679527f7add372a4e6c8381b1d5c24e5a4e442a
parentc9c5e560791591c02bd1dda0648898229830ad45 (diff)
downloadservo-67f2185f547efae56c881d6d028fcb36a1c6a9bf.tar.gz
servo-67f2185f547efae56c881d6d028fcb36a1c6a9bf.zip
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
-rw-r--r--components/style/gecko/media_features.rs10
-rw-r--r--components/style/values/computed/resolution.rs6
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<f32>,
range_or_operator: Option<RangeOrOperator>,
) -> 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 {