diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 71a630edbd6..2a1b5229d99 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -423,6 +423,7 @@ private: RefPtr parse_transform_value(TokenStream&); RefPtr parse_transform_origin_value(TokenStream&); RefPtr parse_transition_value(TokenStream&); + RefPtr parse_transition_property_value(TokenStream&); RefPtr parse_translate_value(TokenStream&); RefPtr parse_scale_value(TokenStream&); RefPtr parse_grid_track_size_list(TokenStream&, bool allow_separate_line_name_blocks = false); diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 26e0af0c1e1..657bcbc0f41 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -670,6 +670,10 @@ Parser::ParseErrorOr> Parser::parse_css_value if (auto parsed_value = parse_transition_value(tokens); parsed_value && !tokens.has_next_token()) return parsed_value.release_nonnull(); return ParseError::SyntaxError; + case PropertyID::TransitionProperty: + if (auto parsed_value = parse_transition_property_value(tokens); parsed_value && !tokens.has_next_token()) + return parsed_value.release_nonnull(); + return ParseError::SyntaxError; case PropertyID::Translate: if (auto parsed_value = parse_translate_value(tokens); parsed_value && !tokens.has_next_token()) return parsed_value.release_nonnull(); @@ -3775,6 +3779,33 @@ RefPtr Parser::parse_transition_value(TokenStream Parser::parse_transition_property_value(TokenStream& tokens) +{ + // https://drafts.csswg.org/css-transitions/#transition-property-property + // none | # + + // none + if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None)) + return none; + + // # + // = all | + auto transaction = tokens.begin_transaction(); + auto transition_property_values = parse_a_comma_separated_list_of_component_values(tokens); + + StyleValueVector transition_properties; + for (auto const& value : transition_property_values) { + TokenStream transition_property_tokens { value }; + auto custom_ident = parse_custom_ident_value(transition_property_tokens, { { "none"sv } }); + if (!custom_ident || transition_property_tokens.has_next_token()) + return nullptr; + + transition_properties.append(custom_ident.release_nonnull()); + } + transaction.commit(); + return StyleValueList::create(move(transition_properties), StyleValueList::Separator::Comma); +} + RefPtr Parser::parse_translate_value(TokenStream& tokens) { if (tokens.remaining_token_count() == 1) { diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-property-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-property-valid.txt new file mode 100644 index 00000000000..996be87fa3d --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-property-valid.txt @@ -0,0 +1,11 @@ +Harness status: OK + +Found 6 tests + +6 Pass +Pass e.style['transition-property'] = "none" should set the property value +Pass e.style['transition-property'] = "all" should set the property value +Pass e.style['transition-property'] = "one" should set the property value +Pass e.style['transition-property'] = "one-two-three" should set the property value +Pass e.style['transition-property'] = "one, two, three" should set the property value +Pass e.style['transition-property'] = "width, all" should set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-property-valid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-property-valid.html new file mode 100644 index 00000000000..382f4beb380 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-property-valid.html @@ -0,0 +1,22 @@ + + + + +CSS Transitions: parsing transition-property with valid values + + + + + + + + + +