diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index f065de8a30..688e056b2b 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -3967,7 +3967,7 @@ static bool is_generic_font_family(ValueID identifier) } } -RefPtr Parser::parse_font_value(Vector const& component_values) +RefPtr Parser::parse_font_value(TokenStream& tokens) { RefPtr font_stretch; RefPtr font_style; @@ -3983,8 +3983,8 @@ RefPtr Parser::parse_font_value(Vector const& compon // So, we have to handle that separately. int normal_count = 0; - auto tokens = TokenStream { component_values }; auto remaining_longhands = Vector { PropertyID::FontSize, PropertyID::FontStretch, PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight }; + auto transaction = tokens.begin_transaction(); while (tokens.has_next_token()) { auto& peek_token = tokens.peek_token(); @@ -4071,6 +4071,7 @@ RefPtr Parser::parse_font_value(Vector const& compon if (!line_height) line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight); + transaction.commit(); return ShorthandStyleValue::create(PropertyID::Font, { PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight, PropertyID::FontStretch, PropertyID::FontSize, PropertyID::LineHeight, PropertyID::FontFamily }, { font_style.release_nonnull(), font_variant.release_nonnull(), font_weight.release_nonnull(), font_stretch.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull() }); @@ -5810,7 +5811,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::Font: - if (auto parsed_value = parse_font_value(component_values)) + if (auto parsed_value = parse_font_value(tokens); parsed_value && !tokens.has_next_token()) return parsed_value.release_nonnull(); return ParseError::SyntaxError; case PropertyID::FontFamily: { diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 61f32ae3ef..fb4a4916f7 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -238,7 +238,7 @@ private: RefPtr parse_display_value(TokenStream&); RefPtr parse_flex_value(TokenStream&); RefPtr parse_flex_flow_value(TokenStream&); - RefPtr parse_font_value(Vector const&); + RefPtr parse_font_value(TokenStream&); RefPtr parse_font_family_value(TokenStream&); RefPtr parse_list_style_value(Vector const&); RefPtr parse_math_depth_value(Vector const&);