LibWeb: Use new StyleValue parsing for background-size

This commit is contained in:
Sam Atkins 2023-05-18 15:49:46 +01:00 committed by Andreas Kling
parent 8e34bdc123
commit 021fd15434
Notes: sideshowbarker 2024-07-17 02:42:21 +09:00

View file

@ -4678,8 +4678,8 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_size_value(TokenStre
return {}; return {};
}; };
auto maybe_x_value = TRY(parse_css_value(tokens.next_token())); auto maybe_x_value = TRY(parse_css_value_for_property(PropertyID::BackgroundSize, tokens));
if (!maybe_x_value || !property_accepts_value(PropertyID::BackgroundSize, *maybe_x_value)) if (!maybe_x_value)
return nullptr; return nullptr;
auto x_value = maybe_x_value.release_nonnull(); auto x_value = maybe_x_value.release_nonnull();
@ -4688,8 +4688,8 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_size_value(TokenStre
return x_value; return x_value;
} }
auto maybe_y_value = TRY(parse_css_value(tokens.peek_token())); auto maybe_y_value = TRY(parse_css_value_for_property(PropertyID::BackgroundSize, tokens));
if (!maybe_y_value || !property_accepts_value(PropertyID::BackgroundSize, *maybe_y_value)) { if (!maybe_y_value) {
auto y_value = LengthPercentage { Length::make_auto() }; auto y_value = LengthPercentage { Length::make_auto() };
auto x_size = get_length_percentage(*x_value); auto x_size = get_length_percentage(*x_value);
if (!x_size.has_value()) if (!x_size.has_value())
@ -4698,7 +4698,6 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_size_value(TokenStre
transaction.commit(); transaction.commit();
return BackgroundSizeStyleValue::create(x_size.value(), y_value); return BackgroundSizeStyleValue::create(x_size.value(), y_value);
} }
tokens.next_token();
auto y_value = maybe_y_value.release_nonnull(); auto y_value = maybe_y_value.release_nonnull();
auto x_size = get_length_percentage(*x_value); auto x_size = get_length_percentage(*x_value);