LibWeb: Clean up parse_css_value_for_properties

We no longer rely on parsing easing functions before keywords so this
can be moved down with the other parse_for_type calls.

`parse_for_type` is used for more than just parsing easing functions so
the variable name `maybe_easing_function` was misleading
This commit is contained in:
Callum Law 2025-10-13 15:07:44 +13:00 committed by Sam Atkins
commit 26b82986c4
Notes: github-actions[bot] 2025-10-20 10:28:56 +00:00

View file

@ -125,15 +125,12 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
auto parse_for_type = [&](ValueType const type) -> Optional<PropertyAndValue> {
if (auto property = any_property_accepts_type(property_ids, type); property.has_value()) {
auto context_guard = push_temporary_value_parsing_context(*property);
if (auto maybe_easing_function = parse_value(type, tokens))
return PropertyAndValue { *property, maybe_easing_function };
if (auto maybe_parsed_value = parse_value(type, tokens))
return PropertyAndValue { *property, maybe_parsed_value };
}
return OptionalNone {};
};
if (auto parsed = parse_for_type(ValueType::EasingFunction); parsed.has_value())
return parsed.release_value();
if (peek_token.is(Token::Type::Ident)) {
// NOTE: We do not try to parse "CSS-wide keywords" here. https://www.w3.org/TR/css-values-4/#common-keywords
// These are only valid on their own, and so should be parsed directly in `parse_css_value()`.
@ -161,6 +158,8 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
return parsed.release_value();
if (auto parsed = parse_for_type(ValueType::Counter); parsed.has_value())
return parsed.release_value();
if (auto parsed = parse_for_type(ValueType::EasingFunction); parsed.has_value())
return parsed.release_value();
if (auto parsed = parse_for_type(ValueType::Image); parsed.has_value())
return parsed.release_value();
if (auto parsed = parse_for_type(ValueType::Position); parsed.has_value())