diff --git a/components/atoms/static_atoms.txt b/components/atoms/static_atoms.txt index 9ef4e7c5f94..7ecb73f05bb 100644 --- a/components/atoms/static_atoms.txt +++ b/components/atoms/static_atoms.txt @@ -1,4 +1,5 @@ -moz-content-preferred-color-scheme +-moz-device-pixel-ratio -moz-gtk-csd-close-button-position -moz-gtk-csd-maximize-button-position -moz-gtk-csd-menu-radius @@ -37,6 +38,7 @@ datachannel date datetime-local dir +device-pixel-ratio durationchange email emptied @@ -108,6 +110,7 @@ rejectionhandled removetrack reset resize +resolution resourcetimingbufferfull right rtl diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index d4a4d581b1f..6440afb45ed 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -12,6 +12,7 @@ use crate::media_queries::MediaType; use crate::properties::ComputedValues; use crate::values::computed::CSSPixelLength; use crate::values::computed::Context; +use crate::values::computed::Resolution; use crate::values::specified::font::FONT_MEDIUM_PX; use crate::values::specified::ViewportVariant; use crate::values::KeyframesName; @@ -252,9 +253,19 @@ fn eval_scan(_: &Context, _: Option) -> bool { false } +/// https://drafts.csswg.org/mediaqueries-4/#resolution +fn eval_resolution(context: &Context) -> Resolution { + Resolution::from_dppx(context.device().device_pixel_ratio.0) +} + +/// https://compat.spec.whatwg.org/#css-media-queries-webkit-device-pixel-ratio +fn eval_device_pixel_ratio(context: &Context) -> f32 { + eval_resolution(context).dppx() +} + lazy_static! { /// A list with all the media features that Servo supports. - pub static ref MEDIA_FEATURES: [QueryFeatureDescription; 2] = [ + pub static ref MEDIA_FEATURES: [QueryFeatureDescription; 5] = [ feature!( atom!("width"), AllowsRanges::Yes, @@ -267,5 +278,23 @@ lazy_static! { keyword_evaluator!(eval_scan, Scan), FeatureFlags::empty(), ), + feature!( + atom!("resolution"), + AllowsRanges::Yes, + Evaluator::Resolution(eval_resolution), + FeatureFlags::empty(), + ), + feature!( + atom!("device-pixel-ratio"), + AllowsRanges::Yes, + Evaluator::Float(eval_device_pixel_ratio), + FeatureFlags::WEBKIT_PREFIX, + ), + feature!( + atom!("-moz-device-pixel-ratio"), + AllowsRanges::Yes, + Evaluator::Float(eval_device_pixel_ratio), + FeatureFlags::empty(), + ), ]; } diff --git a/tests/wpt/meta-legacy-layout/css/mediaqueries/match-media-parsing.html.ini b/tests/wpt/meta-legacy-layout/css/mediaqueries/match-media-parsing.html.ini index b65f43a8082..4fd74ca87d4 100644 --- a/tests/wpt/meta-legacy-layout/css/mediaqueries/match-media-parsing.html.ini +++ b/tests/wpt/meta-legacy-layout/css/mediaqueries/match-media-parsing.html.ini @@ -17,24 +17,6 @@ [Test parsing ' color ), ( color' with matchMedia] expected: FAIL - [Test parsing '(min-resolution: 1x)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 2x)' with matchMedia] - expected: FAIL - - [Test parsing '(max-resolution: 7x)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 2dppx)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 600dpi)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 77dpcm)' with matchMedia] - expected: FAIL - [Test parsing '(min-resolution: calc(1x))' with matchMedia] expected: FAIL diff --git a/tests/wpt/meta/css/mediaqueries/match-media-parsing.html.ini b/tests/wpt/meta/css/mediaqueries/match-media-parsing.html.ini index d54754d9a09..4fd74ca87d4 100644 --- a/tests/wpt/meta/css/mediaqueries/match-media-parsing.html.ini +++ b/tests/wpt/meta/css/mediaqueries/match-media-parsing.html.ini @@ -17,33 +17,15 @@ [Test parsing ' color ), ( color' with matchMedia] expected: FAIL - [Test parsing '(min-resolution: 1x)' with matchMedia] - expected: FAIL - [Test parsing '(min-resolution: calc(1x))' with matchMedia] expected: FAIL - [Test parsing '(resolution: 2x)' with matchMedia] - expected: FAIL - [Test parsing '(resolution: calc(2x))' with matchMedia] expected: FAIL - [Test parsing '(max-resolution: 7x)' with matchMedia] - expected: FAIL - [Test parsing '(max-resolution: calc(7x))' with matchMedia] expected: FAIL - [Test parsing '(resolution: 2dppx)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 600dpi)' with matchMedia] - expected: FAIL - - [Test parsing '(resolution: 77dpcm)' with matchMedia] - expected: FAIL - [Test parsing '(resolution: calc(1x + 2x))' with matchMedia] expected: FAIL