diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index 2a1b5229d99..0fbf6ec8cd5 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -436,6 +436,8 @@ private: RefPtr parse_grid_area_shorthand_value(TokenStream&); RefPtr parse_grid_shorthand_value(TokenStream&); + RefPtr parse_list_of_time_values(PropertyID, TokenStream&); + RefPtr convert_to_calculation_node(CalcParsing::Node const&, CalculationContext const&); RefPtr parse_a_calculation(Vector const&, CalculationContext const&); diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index fc5cf49f778..328c0af1a60 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::TransitionDelay: + if (auto parsed_value = parse_list_of_time_values(property_id, 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(); @@ -3783,6 +3787,26 @@ RefPtr Parser::parse_transition_value(TokenStream Parser::parse_list_of_time_values(PropertyID property_id, TokenStream& tokens) +{ + auto transaction = tokens.begin_transaction(); + auto time_values = parse_a_comma_separated_list_of_component_values(tokens); + StyleValueVector time_value_list; + for (auto const& value : time_values) { + TokenStream time_value_tokens { value }; + auto time_style_value = parse_time_value(time_value_tokens); + if (!time_style_value) + return nullptr; + if (time_value_tokens.has_next_token()) + return nullptr; + if (!time_style_value->is_calculated() && !property_accepts_time(property_id, time_style_value->as_time().time())) + return nullptr; + time_value_list.append(*time_style_value); + } + + transaction.commit(); + return StyleValueList::create(move(time_value_list), StyleValueList::Separator::Comma); +} RefPtr Parser::parse_transition_property_value(TokenStream& tokens) { // https://drafts.csswg.org/css-transitions/#transition-property-property diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-delay-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-delay-valid.txt new file mode 100644 index 00000000000..4acdaf390de --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/parsing/transition-delay-valid.txt @@ -0,0 +1,9 @@ +Harness status: OK + +Found 4 tests + +4 Pass +Pass e.style['transition-delay'] = "0s" should set the property value +Pass e.style['transition-delay'] = "500ms" should set the property value +Pass e.style['transition-delay'] = "1s, 2s" should set the property value +Pass e.style['transition-delay'] = "-1s, -2s" 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-delay-valid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-delay-valid.html new file mode 100644 index 00000000000..72a40b8ffd0 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-transitions/parsing/transition-delay-valid.html @@ -0,0 +1,20 @@ + + + + +CSS Transitions: parsing transition-delay with valid values + + + + + + + + + +