mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
LibWeb: Add indentation to display list dumps
Output display list dumps with an indentation level to show balanced commands. It makes it much easier to see what is happening between e.g. PushStackingContext and PopStackingContext, or SaveLayer and Restore.
This commit is contained in:
parent
ffa6813b61
commit
f28b7064ee
Notes:
github-actions[bot]
2025-08-01 12:22:04 +00:00
Author: https://github.com/gmta
Commit: f28b7064ee
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5675
Reviewed-by: https://github.com/kalenikaliaksandr ✅
4 changed files with 46 additions and 11 deletions
|
@ -18,9 +18,28 @@ void DisplayList::append(DisplayListCommand&& command, Optional<i32> scroll_fram
|
||||||
String DisplayList::dump() const
|
String DisplayList::dump() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto const& command : m_commands) {
|
int indentation = 0;
|
||||||
command.command.visit([&builder](auto const& cmd) { cmd.dump(builder); });
|
for (auto const& command_list_item : m_commands) {
|
||||||
builder.appendff("\n");
|
auto const& command = command_list_item.command;
|
||||||
|
|
||||||
|
command.visit([&indentation](auto const& command) {
|
||||||
|
if constexpr (requires { command.nesting_level_change; }) {
|
||||||
|
if (command.nesting_level_change < 0 && indentation >= -command.nesting_level_change)
|
||||||
|
indentation += command.nesting_level_change;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (indentation > 0)
|
||||||
|
builder.append(MUST(String::repeated(" "_string, indentation)));
|
||||||
|
command.visit([&builder](auto const& cmd) { cmd.dump(builder); });
|
||||||
|
builder.append('\n');
|
||||||
|
|
||||||
|
command.visit([&indentation](auto const& command) {
|
||||||
|
if constexpr (requires { command.nesting_level_change; }) {
|
||||||
|
if (command.nesting_level_change > 0)
|
||||||
|
indentation += command.nesting_level_change;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return builder.to_string_without_validation();
|
return builder.to_string_without_validation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,14 +99,20 @@ struct DrawRepeatedImmutableBitmap {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Save {
|
struct Save {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SaveLayer {
|
struct SaveLayer {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Restore {
|
struct Restore {
|
||||||
|
static constexpr int nesting_level_change = -1;
|
||||||
|
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,6 +133,8 @@ struct AddClipRect {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PushStackingContext {
|
struct PushStackingContext {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
float opacity;
|
float opacity;
|
||||||
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
|
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
|
||||||
bool isolate;
|
bool isolate;
|
||||||
|
@ -145,6 +153,8 @@ struct PushStackingContext {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PopStackingContext {
|
struct PopStackingContext {
|
||||||
|
static constexpr int nesting_level_change = -1;
|
||||||
|
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -445,16 +455,22 @@ struct PaintScrollBar {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ApplyOpacity {
|
struct ApplyOpacity {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
float opacity;
|
float opacity;
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ApplyCompositeAndBlendingOperator {
|
struct ApplyCompositeAndBlendingOperator {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
|
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ApplyFilter {
|
struct ApplyFilter {
|
||||||
|
static constexpr int nesting_level_change = 1;
|
||||||
|
|
||||||
Gfx::Filter filter;
|
Gfx::Filter filter;
|
||||||
void dump(StringBuilder&) const;
|
void dump(StringBuilder&) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -462,7 +462,7 @@ void DisplayListRecorder::apply_opacity(float opacity)
|
||||||
void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
|
void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
|
||||||
{
|
{
|
||||||
// Implementation of this item does saveLayer(), so we need to increment the nesting level.
|
// Implementation of this item does saveLayer(), so we need to increment the nesting level.
|
||||||
m_save_nesting_level++;
|
++m_save_nesting_level;
|
||||||
APPEND(ApplyCompositeAndBlendingOperator { .compositing_and_blending_operator = compositing_and_blending_operator });
|
APPEND(ApplyCompositeAndBlendingOperator { .compositing_and_blending_operator = compositing_and_blending_operator });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
SaveLayer
|
SaveLayer
|
||||||
PushStackingContext opacity=1 isolate=false has_clip_path=false transform=[1 0 0 1 0 0]
|
PushStackingContext opacity=1 isolate=false has_clip_path=false transform=[1 0 0 1 0 0]
|
||||||
PushStackingContext opacity=1 isolate=false has_clip_path=false transform=[1 0 0 1 0 0]
|
PushStackingContext opacity=1 isolate=false has_clip_path=false transform=[1 0 0 1 0 0]
|
||||||
FillPathUsingColor
|
FillPathUsingColor
|
||||||
FillRect rect=[10,10 300x150] color=rgb(240, 128, 128)
|
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
|
DrawGlyphRun rect=[10,10 38x18] translation=[10,23.796875] color=rgb(0, 0, 0) scale=1
|
||||||
PopStackingContext
|
PopStackingContext
|
||||||
PopStackingContext
|
PopStackingContext
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue