1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17:35 +00:00

LibWeb: Stop parsing auto as a Length

Previously, whether trying to parse a `<length>` or `<dimension>`, we
would accept `auto` and produce a `LengthStyleValue` from it. This
would fool the `property_accepts_value()` into allowing `auto` where it
does not belong, if the property did accept lengths.

Of the few places in the parser that called `parse_dimension_value()` or
`parse_length()`, none of them were expecting it to accept `auto`, so
this fixes those too. :^)
This commit is contained in:
Sam Atkins 2023-04-17 20:03:12 +01:00 committed by Andreas Kling
parent 7458cf4231
commit 5647d37d42

View file

@ -3382,10 +3382,6 @@ Optional<Length> Parser::parse_length(ComponentValue const& component_value)
if (dimension->is_length())
return dimension->length();
// FIXME: auto isn't a length!
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_ascii_case("auto"sv))
return Length::make_auto();
return {};
}
@ -3678,9 +3674,6 @@ RefPtr<StyleValue> Parser::parse_dimension_value(ComponentValue const& component
if (component_value.is(Token::Type::Number) && !(m_context.in_quirks_mode() && property_has_quirk(m_context.current_property_id(), Quirk::UnitlessLength)))
return {};
if (component_value.is(Token::Type::Ident) && component_value.token().ident().equals_ignoring_ascii_case("auto"sv))
return LengthStyleValue::create(Length::make_auto());
auto dimension = parse_dimension(component_value);
if (!dimension.has_value())
return {};