diff --git a/Libraries/LibWeb/Animations/AnimationEffect.cpp b/Libraries/LibWeb/Animations/AnimationEffect.cpp index cdd20ba039d..b22cde087ca 100644 --- a/Libraries/LibWeb/Animations/AnimationEffect.cpp +++ b/Libraries/LibWeb/Animations/AnimationEffect.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -609,11 +610,16 @@ Optional AnimationEffect::transformed_progress() const Optional AnimationEffect::parse_easing_string(StringView value) { if (auto style_value = parse_css_value(CSS::Parser::ParsingParams(), value, CSS::PropertyID::AnimationTimingFunction)) { - if (style_value->is_unresolved() || style_value->is_value_list() || style_value->is_css_wide_keyword()) + if (style_value->is_unresolved() || style_value->is_css_wide_keyword()) return {}; - // FIXME: We should absolutize style_value to resolve relative lengths within calcs - return CSS::EasingFunction::from_style_value(style_value.release_nonnull()); + auto easing_values = style_value->as_value_list().values(); + + if (easing_values.size() != 1) + return {}; + + // FIXME: We should absolutize the style value to resolve relative lengths within calcs + return CSS::EasingFunction::from_style_value(easing_values[0]); } return {}; diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index 6241d62ac8d..70ae0e3dbe2 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -879,7 +879,7 @@ RefPtr CSSStyleProperties::style_value_for_computed_property(L auto const& animation_timeline_computed_value = get_computed_value(PropertyID::AnimationTimeline); auto const& animation_duration_computed_value = get_computed_value(PropertyID::AnimationDuration); - if (animation_timeline_computed_value.to_keyword() == Keyword::Auto) { + if (animation_timeline_computed_value.as_value_list().size() == 1 && animation_timeline_computed_value.as_value_list().values()[0]->to_keyword() == Keyword::Auto) { // FIXME: We can remove these two branches once parse_comma_separated_value_list always returns StyleValueList. if (animation_duration_computed_value.to_keyword() == Keyword::Auto) diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 02bb1f433b1..f860ccf0a43 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -448,8 +448,8 @@ private: RefPtr parse_view_function_value(TokenStream&); using ParseFunction = AK::Function(TokenStream&)>; - RefPtr parse_comma_separated_value_list(TokenStream&, ParseFunction); - RefPtr parse_simple_comma_separated_value_list(PropertyID, TokenStream&); + RefPtr parse_comma_separated_value_list(TokenStream&, ParseFunction); + RefPtr parse_simple_comma_separated_value_list(PropertyID, TokenStream&); RefPtr parse_coordinating_value_list_shorthand(TokenStream&, PropertyID shorthand_id, Vector const& longhand_ids, Vector const& reset_only_longhand_ids); RefPtr parse_all_as_single_keyword_value(TokenStream&, Keyword); diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 96f48663de9..6a1db917838 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -88,7 +88,7 @@ RefPtr Parser::parse_all_as_single_keyword_value(TokenStream Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream& tokens) +RefPtr Parser::parse_simple_comma_separated_value_list(PropertyID property_id, TokenStream& tokens) { return parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) -> RefPtr { if (auto value = parse_css_value_for_property(property_id, tokens)) @@ -149,15 +149,8 @@ RefPtr Parser::parse_coordinating_value_list_shorthand(TokenSt longhand_ids_including_reset_only_longhands.extend(reset_only_longhand_ids); StyleValueVector longhand_values {}; - // FIXME: This is for compatibility with parse_comma_separated_value_list(), which returns a single value directly - // instead of a list if there's only one, it would be nicer if we always returned a list. - if (longhand_vectors.get(longhand_ids[0])->size() == 1) { - for (auto const& longhand_id : longhand_ids) - longhand_values.append((*longhand_vectors.get(longhand_id))[0]); - } else { - for (auto const& longhand_id : longhand_ids) - longhand_values.append(StyleValueList::create(move(*longhand_vectors.get(longhand_id)), StyleValueList::Separator::Comma)); - } + for (auto const& longhand_id : longhand_ids) + longhand_values.append(StyleValueList::create(move(*longhand_vectors.get(longhand_id)), StyleValueList::Separator::Comma)); for (auto reset_only_longhand_id : reset_only_longhand_ids) longhand_values.append(property_initial_value(reset_only_longhand_id)); @@ -5079,7 +5072,7 @@ RefPtr Parser::parse_transition_property_value(TokenStream# // = all | diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 14b95fa2b78..0bc75f43d85 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -80,13 +80,13 @@ namespace Web::CSS::Parser { -RefPtr Parser::parse_comma_separated_value_list(TokenStream& tokens, ParseFunction parse_one_value) +RefPtr Parser::parse_comma_separated_value_list(TokenStream& tokens, ParseFunction parse_one_value) { tokens.discard_whitespace(); auto first = parse_one_value(tokens); tokens.discard_whitespace(); - if (!first || !tokens.has_next_token()) - return first; + if (!first) + return nullptr; StyleValueVector values; values.append(first.release_nonnull());