diff --git a/Libraries/LibWeb/CSS/Parser/ErrorReporter.cpp b/Libraries/LibWeb/CSS/Parser/ErrorReporter.cpp index f5cc24181aa..dadf8dbed7f 100644 --- a/Libraries/LibWeb/CSS/Parser/ErrorReporter.cpp +++ b/Libraries/LibWeb/CSS/Parser/ErrorReporter.cpp @@ -64,4 +64,13 @@ void ErrorReporter::report(ParsingError&& error) m_errors.set(move(error), { .occurrences = 1 }); } +void ErrorReporter::dump() const +{ + // TODO: Organise this in some way? + dbgln("{} CSS errors reported:", m_errors.size()); + for (auto const& [error, metadata] : m_errors) { + dbgln("- {} ({} occurrences)", serialize_parsing_error(error), metadata.occurrences); + } +} + } diff --git a/Libraries/LibWeb/CSS/Parser/ErrorReporter.h b/Libraries/LibWeb/CSS/Parser/ErrorReporter.h index 736d2451c43..a9a3f27987c 100644 --- a/Libraries/LibWeb/CSS/Parser/ErrorReporter.h +++ b/Libraries/LibWeb/CSS/Parser/ErrorReporter.h @@ -130,6 +130,7 @@ public: static ErrorReporter& the(); void report(ParsingError&&); + void dump() const; private: explicit ErrorReporter() = default; diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index 959411027a7..f84d73f8ea4 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020-2023, Andreas Kling - * Copyright (c) 2021-2024, Sam Atkins + * Copyright (c) 2021-2025, Sam Atkins * Copyright (c) 2021-2023, Linus Groh * Copyright (c) 2022, Tobias Christiansen * Copyright (c) 2022, Tim Flynn @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -352,6 +353,11 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt return; } + if (request == "dump-all-css-errors") { + Web::CSS::Parser::ErrorReporter::the().dump(); + return; + } + if (request == "collect-garbage") { // NOTE: We use deferred_invoke here to ensure that GC runs with as little on the stack as possible. Core::deferred_invoke([] {