mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
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:
committed by
Jelle Raaijmakers
parent
86ae5022c2
commit
1fc4c69ad8
Notes:
github-actions[bot]
2026-02-24 13:40:16 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/1fc4c69ad81 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8128 Reviewed-by: https://github.com/gmta ✅
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user