Bug 1483808 - Make webkit device-pixel-ratio media queries a proper alias to resolution. r=dholbert

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2018-08-17 21:25:37 +00:00
Родитель f90bca5e29
Коммит 94eb4ee48e
3 изменённых файлов: 9 добавлений и 27 удалений

Просмотреть файл

@ -216,26 +216,6 @@ Gecko_MediaFeatures_GetDisplayMode(nsIDocument* aDocument)
return static_cast<StyleDisplayMode>(displayMode);
}
float
Gecko_MediaFeatures_GetDevicePixelRatio(nsIDocument* aDocument)
{
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
return 1.0;
}
nsIPresShell* presShell = aDocument->GetShell();
if (!presShell) {
return 1.0;
}
nsPresContext* pc = presShell->GetPresContext();
if (!pc) {
return 1.0;
}
return pc->CSSPixelsToDevPixels(1.0f);
}
bool
Gecko_MediaFeatures_HasSystemMetric(nsIDocument* aDocument,
nsAtom* aMetric,

Просмотреть файл

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

Просмотреть файл

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