mirror of
https://github.com/servo/servo.git
synced 2025-06-13 10:54:29 +00:00
Media query resolution (#30406)
* Add resolution and device-pixel-ratio media query * Update expectations
This commit is contained in:
parent
5d8d7c79c2
commit
aa41fbd8f6
4 changed files with 33 additions and 37 deletions
|
@ -1,4 +1,5 @@
|
||||||
-moz-content-preferred-color-scheme
|
-moz-content-preferred-color-scheme
|
||||||
|
-moz-device-pixel-ratio
|
||||||
-moz-gtk-csd-close-button-position
|
-moz-gtk-csd-close-button-position
|
||||||
-moz-gtk-csd-maximize-button-position
|
-moz-gtk-csd-maximize-button-position
|
||||||
-moz-gtk-csd-menu-radius
|
-moz-gtk-csd-menu-radius
|
||||||
|
@ -37,6 +38,7 @@ datachannel
|
||||||
date
|
date
|
||||||
datetime-local
|
datetime-local
|
||||||
dir
|
dir
|
||||||
|
device-pixel-ratio
|
||||||
durationchange
|
durationchange
|
||||||
email
|
email
|
||||||
emptied
|
emptied
|
||||||
|
@ -108,6 +110,7 @@ rejectionhandled
|
||||||
removetrack
|
removetrack
|
||||||
reset
|
reset
|
||||||
resize
|
resize
|
||||||
|
resolution
|
||||||
resourcetimingbufferfull
|
resourcetimingbufferfull
|
||||||
right
|
right
|
||||||
rtl
|
rtl
|
||||||
|
|
|
@ -12,6 +12,7 @@ use crate::media_queries::MediaType;
|
||||||
use crate::properties::ComputedValues;
|
use crate::properties::ComputedValues;
|
||||||
use crate::values::computed::CSSPixelLength;
|
use crate::values::computed::CSSPixelLength;
|
||||||
use crate::values::computed::Context;
|
use crate::values::computed::Context;
|
||||||
|
use crate::values::computed::Resolution;
|
||||||
use crate::values::specified::font::FONT_MEDIUM_PX;
|
use crate::values::specified::font::FONT_MEDIUM_PX;
|
||||||
use crate::values::specified::ViewportVariant;
|
use crate::values::specified::ViewportVariant;
|
||||||
use crate::values::KeyframesName;
|
use crate::values::KeyframesName;
|
||||||
|
@ -252,9 +253,19 @@ fn eval_scan(_: &Context, _: Option<Scan>) -> bool {
|
||||||
false
|
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! {
|
lazy_static! {
|
||||||
/// A list with all the media features that Servo supports.
|
/// 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!(
|
feature!(
|
||||||
atom!("width"),
|
atom!("width"),
|
||||||
AllowsRanges::Yes,
|
AllowsRanges::Yes,
|
||||||
|
@ -267,5 +278,23 @@ lazy_static! {
|
||||||
keyword_evaluator!(eval_scan, Scan),
|
keyword_evaluator!(eval_scan, Scan),
|
||||||
FeatureFlags::empty(),
|
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(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,24 +17,6 @@
|
||||||
[Test parsing ' color ), ( color' with matchMedia]
|
[Test parsing ' color ), ( color' with matchMedia]
|
||||||
expected: FAIL
|
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]
|
[Test parsing '(min-resolution: calc(1x))' with matchMedia]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -17,33 +17,15 @@
|
||||||
[Test parsing ' color ), ( color' with matchMedia]
|
[Test parsing ' color ), ( color' with matchMedia]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Test parsing '(min-resolution: 1x)' with matchMedia]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test parsing '(min-resolution: calc(1x))' with matchMedia]
|
[Test parsing '(min-resolution: calc(1x))' with matchMedia]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Test parsing '(resolution: 2x)' with matchMedia]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test parsing '(resolution: calc(2x))' with matchMedia]
|
[Test parsing '(resolution: calc(2x))' with matchMedia]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Test parsing '(max-resolution: 7x)' with matchMedia]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Test parsing '(max-resolution: calc(7x))' with matchMedia]
|
[Test parsing '(max-resolution: calc(7x))' with matchMedia]
|
||||||
expected: FAIL
|
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]
|
[Test parsing '(resolution: calc(1x + 2x))' with matchMedia]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue