Skip to content

Commit a08c175

Browse files
LibWeb: Display clip rectangles when dumping display list
1 parent 005e965 commit a08c175

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Libraries/LibWeb/Painting/DisplayList.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ String DisplayList::dump() const
2121
int indentation = 0;
2222
for (auto const& command_list_item : m_commands) {
2323
auto const& command = command_list_item.command;
24+
auto clip_frame = command_list_item.clip_frame;
2425

2526
command.visit([&indentation](auto const& command) {
2627
if constexpr (requires { command.nesting_level_change; }) {
@@ -32,6 +33,18 @@ String DisplayList::dump() const
3233
if (indentation > 0)
3334
builder.append(MUST(String::repeated(" "_string, indentation)));
3435
command.visit([&builder](auto const& cmd) { cmd.dump(builder); });
36+
37+
if (clip_frame && clip_frame->clip_rects().size() > 0) {
38+
builder.append(", clip_rects=["sv);
39+
auto first = true;
40+
for (auto const& clip_rect : clip_frame->clip_rects()) {
41+
if (!first)
42+
builder.append(", "sv);
43+
first = false;
44+
builder.appendff("{}", clip_rect.rect);
45+
}
46+
builder.append("]"sv);
47+
}
3548
builder.append('\n');
3649

3750
command.visit([&indentation](auto const& command) {

Tests/LibWeb/Text/expected/display_list/simple-overflow-hidden.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Save
22
ApplyTransform matrix=[1 0 0 1 0 0]
33
SaveLayer
44
FillPath path_bounding_rect=[8,8 204x104]
5-
FillRect rect=[10,10 300x150] color=rgb(240, 128, 128)
6-
DrawGlyphRun rect=[10,10 38x18] translation=[10,23.796875] color=rgb(0, 0, 0) scale=1
5+
FillRect rect=[10,10 300x150] color=rgb(240, 128, 128), clip_rects=[[10,10 200x100]]
6+
DrawGlyphRun rect=[10,10 38x18] translation=[10,23.796875] color=rgb(0, 0, 0) scale=1, clip_rects=[[10,10 200x100]]
77
Restore
88
Restore
99

0 commit comments

Comments
 (0)