LibWeb: Properly handle auto when parsing background-size

This code assumed that `auto` was always stored as a LengthStyleValue,
which will not be true in the next commit. (And was not a safe
assumption to make anyway.)
This commit is contained in:
Sam Atkins 2023-04-17 19:53:08 +01:00 committed by Andreas Kling
commit 22cb74d9ff
Notes: sideshowbarker 2024-07-17 08:55:54 +09:00

View file

@ -4579,6 +4579,8 @@ RefPtr<StyleValue> Parser::parse_single_background_size_value(TokenStream<Compon
auto transaction = tokens.begin_transaction();
auto get_length_percentage = [](StyleValue& style_value) -> Optional<LengthPercentage> {
if (style_value.has_auto())
return LengthPercentage { Length::make_auto() };
if (style_value.is_percentage())
return LengthPercentage { style_value.as_percentage().percentage() };
if (style_value.has_length())