diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 9379d0f783..b0db859a84 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1284,15 +1284,16 @@ Optional Parser::convert_to_style_property(StyleDeclarationRule& auto value_token_stream = TokenStream(declaration.m_values); auto value = parse_css_value(property_id, value_token_stream); - if (!value) { - dbgln("CSS property '{}' has no value.", property_name); + if (value.is_error()) { + if (value.error() != ParsingResult::IncludesIgnoredVendorPrefix) + dbgln("Unable to parse value for CSS property '{}'", property_name); return {}; } if (property_id == PropertyID::Custom) { - return StyleProperty { property_id, value.release_nonnull(), declaration.m_name, declaration.m_important }; + return StyleProperty { property_id, value.release_value(), declaration.m_name, declaration.m_important }; } else { - return StyleProperty { property_id, value.release_nonnull(), {}, declaration.m_important }; + return StyleProperty { property_id, value.release_value(), {}, declaration.m_important }; } } @@ -2727,10 +2728,13 @@ RefPtr Parser::parse_as_css_value(PropertyID property_id) { auto component_values = parse_as_list_of_component_values(); auto tokens = TokenStream(component_values); - return parse_css_value(property_id, tokens); + auto parsed_value = parse_css_value(property_id, tokens); + if (parsed_value.is_error()) + return {}; + return parsed_value.release_value(); } -RefPtr Parser::parse_css_value(PropertyID property_id, TokenStream& tokens) +Result, Parser::ParsingResult> Parser::parse_css_value(PropertyID property_id, TokenStream& tokens) { m_context.set_current_property_id(property_id); Vector component_values; @@ -2746,30 +2750,33 @@ RefPtr Parser::parse_css_value(PropertyID property_id, TokenStream Parser::parse_css_value(PropertyID property_id, TokenStream Parser::parse_css_value(PropertyID property_id, TokenStream Parser::parse_css_value(ParsingContext const& context, StyleComponentValueRule const& component_value) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 254db66e74..a343f5c711 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -174,7 +174,7 @@ private: static Optional parse_length(ParsingContext const&, StyleComponentValueRule const&); static Optional parse_url_function(ParsingContext const&, StyleComponentValueRule const&); - RefPtr parse_css_value(PropertyID, TokenStream&); + Result, ParsingResult> parse_css_value(PropertyID, TokenStream&); static RefPtr parse_css_value(ParsingContext const&, StyleComponentValueRule const&); static RefPtr parse_builtin_value(ParsingContext const&, StyleComponentValueRule const&); static RefPtr parse_dynamic_value(ParsingContext const&, StyleComponentValueRule const&);