diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index b6286bbcbe..5c6eab238d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4510,19 +4510,17 @@ RefPtr Parser::parse_overflow_value(TokenStream& tok { *maybe_x_value, *maybe_x_value }); } -RefPtr Parser::parse_place_content_value(Vector const& component_values) +RefPtr Parser::parse_place_content_value(TokenStream& tokens) { - if (component_values.size() > 2) - return nullptr; - - auto tokens = TokenStream { component_values }; + auto transaction = tokens.begin_transaction(); auto maybe_align_content_value = parse_css_value_for_property(PropertyID::AlignContent, tokens); if (!maybe_align_content_value) return nullptr; - if (component_values.size() == 1) { + if (!tokens.has_next_token()) { if (!property_accepts_identifier(PropertyID::JustifyContent, maybe_align_content_value->to_identifier())) return nullptr; + transaction.commit(); return ShorthandStyleValue::create(PropertyID::PlaceContent, { PropertyID::AlignContent, PropertyID::JustifyContent }, { *maybe_align_content_value, *maybe_align_content_value }); @@ -4531,6 +4529,7 @@ RefPtr Parser::parse_place_content_value(Vector cons auto maybe_justify_content_value = parse_css_value_for_property(PropertyID::JustifyContent, tokens); if (!maybe_justify_content_value) return nullptr; + transaction.commit(); return ShorthandStyleValue::create(PropertyID::PlaceContent, { PropertyID::AlignContent, PropertyID::JustifyContent }, { maybe_align_content_value.release_nonnull(), maybe_justify_content_value.release_nonnull() }); @@ -5912,7 +5911,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::PlaceContent: - if (auto parsed_value = parse_place_content_value(component_values)) + if (auto parsed_value = parse_place_content_value(tokens); parsed_value && !tokens.has_next_token()) return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::PlaceItems: diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index d52934d843..5ade813536 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -243,7 +243,7 @@ private: RefPtr parse_list_style_value(TokenStream&); RefPtr parse_math_depth_value(TokenStream&); RefPtr parse_overflow_value(TokenStream&); - RefPtr parse_place_content_value(Vector const&); + RefPtr parse_place_content_value(TokenStream&); RefPtr parse_place_items_value(Vector const&); RefPtr parse_place_self_value(Vector const&); RefPtr parse_quotes_value(TokenStream&);