LibWeb/CSS: Implement device-aspect-ratio media feature

Gets us 8 WPT passes, and prevents a regression in the following commit.
This commit is contained in:
Sam Atkins 2025-05-22 12:02:01 +01:00
parent b577302f07
commit 72f50217b0
Notes: github-actions[bot] 2025-05-23 09:19:23 +00:00
2 changed files with 14 additions and 11 deletions

View file

@ -323,7 +323,10 @@ Optional<CSS::MediaFeatureValue> Window::query_media_feature(CSS::MediaFeatureID
return CSS::MediaFeatureValue(CSS::Keyword::Srgb); return CSS::MediaFeatureValue(CSS::Keyword::Srgb);
case CSS::MediaFeatureID::ColorIndex: case CSS::MediaFeatureID::ColorIndex:
return CSS::MediaFeatureValue(0); return CSS::MediaFeatureValue(0);
// FIXME: device-aspect-ratio case CSS::MediaFeatureID::DeviceAspectRatio: {
auto screen_area = page().client().screen_rect();
return CSS::MediaFeatureValue(CSS::Ratio(screen_area.width().value(), screen_area.height().value()));
}
case CSS::MediaFeatureID::DeviceHeight: case CSS::MediaFeatureID::DeviceHeight:
return CSS::MediaFeatureValue(CSS::Length::make_px(page().web_exposed_screen_area().height())); return CSS::MediaFeatureValue(CSS::Length::make_px(page().web_exposed_screen_area().height()));
case CSS::MediaFeatureID::DeviceWidth: case CSS::MediaFeatureID::DeviceWidth:

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 1345 tests Found 1345 tests
1257 Pass 1265 Pass
88 Fail 80 Fail
Pass query_should_be_parseable: (orientation) Pass query_should_be_parseable: (orientation)
Pass query_should_be_parseable: not (orientation) Pass query_should_be_parseable: not (orientation)
Pass expression_should_be_known: (orientation) Pass expression_should_be_known: (orientation)
@ -1015,22 +1015,22 @@ Fail should_apply: (max-aspect-ratio: 60/80)
Fail should_apply: (max-aspect-ratio: 59/79) Fail should_apply: (max-aspect-ratio: 59/79)
Pass expression_should_be_parseable: max-aspect-ratio Pass expression_should_be_parseable: max-aspect-ratio
Pass expression_should_be_unknown: max-aspect-ratio Pass expression_should_be_unknown: max-aspect-ratio
Fail should_apply: (device-aspect-ratio: ${real_dar}) Pass should_apply: (device-aspect-ratio: ${real_dar})
Pass should_apply: not all and (device-aspect-ratio: ${high_dar_1}) Pass should_apply: not all and (device-aspect-ratio: ${high_dar_1})
Pass should_not_apply: all and (device-aspect-ratio: ${high_dar_2}) Pass should_not_apply: all and (device-aspect-ratio: ${high_dar_2})
Pass should_not_apply: all and (device-aspect-ratio: ${low_dar_1}) Pass should_not_apply: all and (device-aspect-ratio: ${low_dar_1})
Pass should_apply: not all and (device-aspect-ratio: ${low_dar_2}) Pass should_apply: not all and (device-aspect-ratio: ${low_dar_2})
Fail should_apply: (device-aspect-ratio) Pass should_apply: (device-aspect-ratio)
Fail should_apply: (min-device-aspect-ratio: ${real_dar}) Pass should_apply: (min-device-aspect-ratio: ${real_dar})
Pass should_not_apply: all and (min-device-aspect-ratio: ${high_dar_1}) Pass should_not_apply: all and (min-device-aspect-ratio: ${high_dar_1})
Pass should_apply: not all and (min-device-aspect-ratio: ${high_dar_2}) Pass should_apply: not all and (min-device-aspect-ratio: ${high_dar_2})
Fail should_not_apply: not all and (min-device-aspect-ratio: ${low_dar_1}) Pass should_not_apply: not all and (min-device-aspect-ratio: ${low_dar_1})
Fail should_apply: all and (min-device-aspect-ratio: ${low_dar_2}) Pass should_apply: all and (min-device-aspect-ratio: ${low_dar_2})
Pass expression_should_be_parseable: min-device-aspect-ratio Pass expression_should_be_parseable: min-device-aspect-ratio
Pass expression_should_be_unknown: min-device-aspect-ratio Pass expression_should_be_unknown: min-device-aspect-ratio
Fail should_apply: all and (max-device-aspect-ratio: ${real_dar}) Pass should_apply: all and (max-device-aspect-ratio: ${real_dar})
Fail should_apply: (max-device-aspect-ratio: ${high_dar_1}) Pass should_apply: (max-device-aspect-ratio: ${high_dar_1})
Fail should_apply: (max-device-aspect-ratio: ${high_dar_2}) Pass should_apply: (max-device-aspect-ratio: ${high_dar_2})
Pass should_not_apply: all and (max-device-aspect-ratio: ${low_dar_1}) Pass should_not_apply: all and (max-device-aspect-ratio: ${low_dar_1})
Pass should_apply: not all and (max-device-aspect-ratio: ${low_dar_2}) Pass should_apply: not all and (max-device-aspect-ratio: ${low_dar_2})
Pass expression_should_be_parseable: max-device-aspect-ratio Pass expression_should_be_parseable: max-device-aspect-ratio