LibWeb: Make LengthBox hold LengthPercentageOrAuto

Not every user of this requires an `auto` state, but most do.

This has quite a big diff but most of that is mechanical:
LengthPercentageOrAuto has `resolved_or_auto()` instead of `resolved()`,
and `to_px_or_zero()` instead of `to_px()`, to make their output
clearer.
This commit is contained in:
Sam Atkins 2025-09-01 12:51:52 +01:00
commit dd122e2f74
Notes: github-actions[bot] 2025-09-04 12:32:43 +00:00
17 changed files with 199 additions and 215 deletions

View file

@ -3310,15 +3310,13 @@ RefPtr<StyleValue const> Parser::parse_basic_shape_value(TokenStream<ComponentVa
// FIXME: Parse the border-radius.
auto arguments_tokens = TokenStream { component_value.function().value };
auto parse_length_percentage_or_auto = [this](TokenStream<ComponentValue>& tokens) -> Optional<LengthPercentage> {
auto parse_length_percentage_or_auto = [this](TokenStream<ComponentValue>& tokens) -> Optional<LengthPercentageOrAuto> {
tokens.discard_whitespace();
auto value = parse_length_percentage(tokens);
if (!value.has_value()) {
if (tokens.consume_a_token().is_ident("auto"sv)) {
value = Length::make_auto();
}
}
return value;
if (auto value = parse_length_percentage(tokens); value.has_value())
return value.release_value();
if (tokens.consume_a_token().is_ident("auto"sv))
return LengthPercentageOrAuto::make_auto();
return {};
};
auto top = parse_length_percentage_or_auto(arguments_tokens);