LibWeb: Display clip rectangles when dumping display list

This commit is contained in:
InvalidUsernameException 2025-11-26 13:29:06 +01:00 committed by Alexander Kalenik
parent 005e965380
commit a08c175da2
Notes: github-actions[bot] 2025-12-01 16:48:05 +00:00
2 changed files with 15 additions and 2 deletions

View file

@ -21,6 +21,7 @@ String DisplayList::dump() const
int indentation = 0;
for (auto const& command_list_item : m_commands) {
auto const& command = command_list_item.command;
auto clip_frame = command_list_item.clip_frame;
command.visit([&indentation](auto const& command) {
if constexpr (requires { command.nesting_level_change; }) {
@ -32,6 +33,18 @@ String DisplayList::dump() const
if (indentation > 0)
builder.append(MUST(String::repeated(" "_string, indentation)));
command.visit([&builder](auto const& cmd) { cmd.dump(builder); });
if (clip_frame && clip_frame->clip_rects().size() > 0) {
builder.append(", clip_rects=["sv);
auto first = true;
for (auto const& clip_rect : clip_frame->clip_rects()) {
if (!first)
builder.append(", "sv);
first = false;
builder.appendff("{}", clip_rect.rect);
}
builder.append("]"sv);
}
builder.append('\n');
command.visit([&indentation](auto const& command) {

View file

@ -2,8 +2,8 @@ Save
ApplyTransform matrix=[1 0 0 1 0 0]
SaveLayer
FillPath path_bounding_rect=[8,8 204x104]
FillRect rect=[10,10 300x150] color=rgb(240, 128, 128)
DrawGlyphRun rect=[10,10 38x18] translation=[10,23.796875] color=rgb(0, 0, 0) scale=1
FillRect rect=[10,10 300x150] color=rgb(240, 128, 128), clip_rects=[[10,10 200x100]]
DrawGlyphRun rect=[10,10 38x18] translation=[10,23.796875] color=rgb(0, 0, 0) scale=1, clip_rects=[[10,10 200x100]]
Restore
Restore