diff --git a/Libraries/LibWeb/CSS/Parser/DescriptorParsing.cpp b/Libraries/LibWeb/CSS/Parser/DescriptorParsing.cpp index 476cfe97146..3435343ea2c 100644 --- a/Libraries/LibWeb/CSS/Parser/DescriptorParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/DescriptorParsing.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -19,7 +20,10 @@ namespace Web::CSS::Parser { Parser::ParseErrorOr> Parser::parse_descriptor_value(AtRuleID at_rule_id, DescriptorID descriptor_id, TokenStream& unprocessed_tokens) { if (!at_rule_supports_descriptor(at_rule_id, descriptor_id)) { - dbgln_if(CSS_PARSER_DEBUG, "Unsupported descriptor '{}' in '{}'", to_string(descriptor_id), to_string(at_rule_id)); + ErrorReporter::the().report(UnknownPropertyError { + .rule_name = to_string(at_rule_id), + .property_name = to_string(descriptor_id), + }); return ParseError::SyntaxError; } @@ -212,10 +216,12 @@ Parser::ParseErrorOr> Parser::parse_descripto return parsed_style_value.release_nonnull(); } - if constexpr (CSS_PARSER_DEBUG) { - dbgln("Failed to parse descriptor '{}' in '{}'", to_string(descriptor_id), to_string(at_rule_id)); - tokens.dump_all_tokens(); - } + ErrorReporter::the().report(InvalidPropertyError { + .rule_name = to_string(at_rule_id), + .property_name = to_string(descriptor_id), + .value_string = tokens.dump_string(), + .description = "Failed to parse."_string, + }); return ParseError::SyntaxError; } diff --git a/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Libraries/LibWeb/CSS/Parser/Parser.cpp index f13372a08f4..59e22cdcac4 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1624,7 +1624,7 @@ Optional Parser::convert_to_style_property(Declaration const& dec } else if (has_ignored_vendor_prefix(property_name)) { return {}; } else { - dbgln_if(CSS_PARSER_DEBUG, "Unrecognized CSS property '{}'", property_name); + ErrorReporter::the().report(UnknownPropertyError { .property_name = property_name }); return {}; } } @@ -1633,10 +1633,11 @@ Optional Parser::convert_to_style_property(Declaration const& dec auto value = parse_css_value(property_id.value(), value_token_stream, declaration.original_text); if (value.is_error()) { if (value.error() == ParseError::SyntaxError) { - dbgln_if(CSS_PARSER_DEBUG, "Unable to parse value for CSS property '{}'.", property_name); - if constexpr (CSS_PARSER_DEBUG) { - value_token_stream.dump_all_tokens(); - } + ErrorReporter::the().report(InvalidPropertyError { + .property_name = property_name, + .value_string = value_token_stream.dump_string(), + .description = "Failed to parse."_string, + }); } return {}; } diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 970edc2f632..bdb8545b6eb 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -2798,20 +2798,40 @@ RefPtr Parser::parse_font_language_override_value(TokenStre auto string_value = string->string_value(); tokens.discard_whitespace(); if (tokens.has_next_token()) { - dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Failed to parse font-language-override: unexpected trailing tokens"); + ErrorReporter::the().report(InvalidPropertyError { + .rule_name = "style"_fly_string, + .property_name = "font-language-override"_fly_string, + .value_string = tokens.dump_string(), + .description = "Unexpected trailing tokens"_string, + }); return nullptr; } auto length = string_value.bytes().size(); if (length == 0) { - dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Failed to parse font-language-override: value is empty"); + ErrorReporter::the().report(InvalidPropertyError { + .rule_name = "style"_fly_string, + .property_name = "font-language-override"_fly_string, + .value_string = tokens.dump_string(), + .description = " value is empty"_string, + }); return nullptr; } if (!string_value.is_ascii()) { - dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Failed to parse font-language-override: value \"{}\" contains non-ascii characters", string_value); + ErrorReporter::the().report(InvalidPropertyError { + .rule_name = "style"_fly_string, + .property_name = "font-language-override"_fly_string, + .value_string = tokens.dump_string(), + .description = MUST(String::formatted(" value \"{}\" contains non-ascii characters", string_value)), + }); return nullptr; } if (length > 4) { - dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Failed to parse font-language-override: value \"{}\" is too long", string_value); + ErrorReporter::the().report(InvalidPropertyError { + .rule_name = "style"_fly_string, + .property_name = "font-language-override"_fly_string, + .value_string = tokens.dump_string(), + .description = MUST(String::formatted(" value \"{}\" is too long", string_value)), + }); return nullptr; } transaction.commit(); @@ -3227,7 +3247,11 @@ RefPtr Parser::parse_font_variant_alternates_value(TokenStr if (auto historical_forms = parse_all_as_single_keyword_value(tokens, Keyword::HistoricalForms)) return historical_forms; - dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-variant-alternate: parsing {} not implemented.", tokens.next_token().to_debug_string()); + ErrorReporter::the().report(InvalidPropertyError { + .property_name = "font-variant-alternates"_fly_string, + .value_string = tokens.next_token().to_string(), + .description = "Invalid or not yet implemented"_string, + }); return nullptr; } @@ -4168,7 +4192,11 @@ RefPtr Parser::parse_transition_value(TokenStream Parser::parse_transition_value(TokenStream Parser::parse_transition_value(TokenStreamto_keyword() == Keyword::All); if (transition.property_name) { - dbgln_if(CSS_PARSER_DEBUG, "Transition property has multiple property identifiers"); + ErrorReporter::the().report(InvalidPropertyError { + .property_name = "transition"_fly_string, + .value_string = tokens.dump_string(), + .description = "Contains multiple property identifiers"_string, + }); return {}; } transition.property_name = transition_keyword.release_nonnull(); @@ -4206,7 +4242,11 @@ RefPtr Parser::parse_transition_value(TokenStream Parser::parse_transition_value(TokenStream