WebContent+LibWeb/CSS: Add debug request to dump CSS errors

This commit is contained in:
Sam Atkins 2025-07-23 11:29:03 +01:00
commit 1adddb158a
Notes: github-actions[bot] 2025-08-04 09:51:44 +00:00
3 changed files with 17 additions and 1 deletions

View file

@ -64,4 +64,13 @@ void ErrorReporter::report(ParsingError&& error)
m_errors.set(move(error), { .occurrences = 1 }); 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);
}
}
} }

View file

@ -130,6 +130,7 @@ public:
static ErrorReporter& the(); static ErrorReporter& the();
void report(ParsingError&&); void report(ParsingError&&);
void dump() const;
private: private:
explicit ErrorReporter() = default; explicit ErrorReporter() = default;

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2020-2023, Andreas Kling <andreas@ladybird.org> * Copyright (c) 2020-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org> * Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org> * Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org> * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
@ -22,6 +22,7 @@
#include <LibWeb/ARIA/RoleType.h> #include <LibWeb/ARIA/RoleType.h>
#include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/CSS/ComputedProperties.h> #include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Parser/ErrorReporter.h>
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/DOM/Attr.h> #include <LibWeb/DOM/Attr.h>
#include <LibWeb/DOM/CharacterData.h> #include <LibWeb/DOM/CharacterData.h>
@ -352,6 +353,11 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
return; return;
} }
if (request == "dump-all-css-errors") {
Web::CSS::Parser::ErrorReporter::the().dump();
return;
}
if (request == "collect-garbage") { if (request == "collect-garbage") {
// NOTE: We use deferred_invoke here to ensure that GC runs with as little on the stack as possible. // NOTE: We use deferred_invoke here to ensure that GC runs with as little on the stack as possible.
Core::deferred_invoke([] { Core::deferred_invoke([] {