LibWeb/CSS: Reject negative <resolution> values

Gets us 3 more WPT passes.
This commit is contained in:
Sam Atkins 2025-05-22 16:35:59 +01:00
parent fb975cc156
commit e251b451ef
Notes: github-actions[bot] 2025-05-23 09:18:54 +00:00
2 changed files with 10 additions and 5 deletions

View file

@ -964,6 +964,11 @@ RefPtr<CSSStyleValue const> Parser::parse_resolution_value(TokenStream<Component
if (tokens.next_token().is(Token::Type::Dimension)) {
auto transaction = tokens.begin_transaction();
auto& dimension_token = tokens.consume_a_token().token();
// The allowed range of <resolution> values always excludes negative values, in addition to any explicit
// ranges that might be specified.
// https://drafts.csswg.org/css-values-4/#resolution
if (dimension_token.dimension_value() < 0)
return nullptr;
if (auto resolution_type = Resolution::unit_from_name(dimension_token.dimension_unit()); resolution_type.has_value()) {
transaction.commit();
return ResolutionStyleValue::create(Resolution { (dimension_token.dimension_value()), resolution_type.release_value() });