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
This commit is contained in:
Emilio Cobos Álvarez 2018-08-17 21:25:37 +00:00
parent c9c5e56079
commit 67f2185f54
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 9 additions and 7 deletions

View file

@ -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,
)
}

View file

@ -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 {