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 {