LibWeb: Expand PaintNestedDisplayList in internals.dumpDisplayList()

Previously, PaintNestedDisplayList was treated as an opaque command,
printing only its name and rect without showing the nested display
list's contents. This made it impossible to debug painting issues
involving SVG masks/clips, CSS background-clip: text, and iframe
content through display list dumps.

Refactor the command dump loop into a recursive lambda that expands
nested display lists inline with increased indentation.
This commit is contained in:
Aliaksandr Kalenik
2026-02-24 12:39:49 +01:00
committed by Jelle Raaijmakers
parent 86ae5022c2
commit 1fc4c69ad8
Notes: github-actions[bot] 2026-02-24 13:40:16 +00:00
2 changed files with 33 additions and 18 deletions

View File

@@ -7609,27 +7609,38 @@ String Document::dump_display_list()
dump_context(root, 1);
builder.append("\nDisplayList:\n"sv);
int indent = 0;
for (auto const& item : display_list->commands()) {
int nesting_change = item.command.visit([](auto const& cmd) {
if constexpr (requires { cmd.nesting_level_change; })
return cmd.nesting_level_change;
return 0;
});
if (nesting_change < 0)
indent = max(0, indent + nesting_change);
Function<void(Painting::DisplayList const&, int)> dump_commands =
[&](Painting::DisplayList const& list, int base_indent) {
int indent = base_indent;
for (auto const& item : list.commands()) {
int nesting_change = item.command.visit([](auto const& cmd) {
if constexpr (requires { cmd.nesting_level_change; })
return cmd.nesting_level_change;
return 0;
});
builder.append_repeated(' ', indent * 2);
item.command.visit([&](auto const& command) {
builder.appendff("{}@{}", command.command_name, item.context ? item.context->id() : 0);
command.dump(builder);
});
builder.append('\n');
if (nesting_change < 0)
indent = max(base_indent, indent + nesting_change);
if (nesting_change > 0)
indent += nesting_change;
}
builder.append_repeated(' ', indent * 2);
item.command.visit([&](auto const& command) {
builder.appendff("{}@{}", command.command_name, item.context ? item.context->id() : 0);
command.dump(builder);
});
builder.append('\n');
if (auto const* nested = item.command.get_pointer<Painting::PaintNestedDisplayList>()) {
if (nested->display_list)
dump_commands(*nested->display_list, indent + 1);
}
if (nesting_change > 0)
indent += nesting_change;
}
};
dump_commands(*display_list, 0);
return builder.to_string_without_validation();
}