mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-23 09:48:56 +00:00
LibWeb: Use StringBuilder::append_repeated() for layout tree indentation
No functional changes.
This commit is contained in:
parent
e173b00db6
commit
b92764dcc0
Notes:
github-actions[bot]
2025-08-27 10:55:22 +00:00
Author: https://github.com/gmta
Commit: b92764dcc0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5999
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 4 additions and 8 deletions
|
@ -162,8 +162,7 @@ void dump_tree(Layout::Node const& layout_node, bool show_cascaded_properties)
|
||||||
void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool show_cascaded_properties, bool interactive)
|
void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool show_cascaded_properties, bool interactive)
|
||||||
{
|
{
|
||||||
static size_t indent = 0;
|
static size_t indent = 0;
|
||||||
for (size_t i = 0; i < indent; ++i)
|
builder.append_repeated(" "sv, indent);
|
||||||
builder.append(" "sv);
|
|
||||||
|
|
||||||
FlyString tag_name;
|
FlyString tag_name;
|
||||||
if (layout_node.is_anonymous())
|
if (layout_node.is_anonymous())
|
||||||
|
@ -383,8 +382,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dump_fragment = [&](auto& fragment, size_t fragment_index) {
|
auto dump_fragment = [&](auto& fragment, size_t fragment_index) {
|
||||||
for (size_t i = 0; i < indent; ++i)
|
builder.append_repeated(" "sv, indent);
|
||||||
builder.append(" "sv);
|
|
||||||
builder.appendff(" {}frag {}{} from {} ",
|
builder.appendff(" {}frag {}{} from {} ",
|
||||||
fragment_color_on,
|
fragment_color_on,
|
||||||
fragment_index,
|
fragment_index,
|
||||||
|
@ -396,8 +394,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
||||||
fragment.absolute_rect(),
|
fragment.absolute_rect(),
|
||||||
fragment.baseline());
|
fragment.baseline());
|
||||||
if (is<Layout::TextNode>(fragment.layout_node())) {
|
if (is<Layout::TextNode>(fragment.layout_node())) {
|
||||||
for (size_t i = 0; i < indent; ++i)
|
builder.append_repeated(" "sv, indent);
|
||||||
builder.append(" "sv);
|
|
||||||
auto const& layout_text = static_cast<Layout::TextNode const&>(fragment.layout_node());
|
auto const& layout_text = static_cast<Layout::TextNode const&>(fragment.layout_node());
|
||||||
auto fragment_text = layout_text.text_for_rendering().substring_view(fragment.start_offset(), fragment.length_in_code_units());
|
auto fragment_text = layout_text.text_for_rendering().substring_view(fragment.start_offset(), fragment.length_in_code_units());
|
||||||
builder.appendff(" \"{}\"\n", fragment_text);
|
builder.appendff(" \"{}\"\n", fragment_text);
|
||||||
|
@ -436,8 +433,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
||||||
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
||||||
|
|
||||||
for (auto& property : properties) {
|
for (auto& property : properties) {
|
||||||
for (size_t i = 0; i < indent; ++i)
|
builder.append_repeated(" "sv, indent);
|
||||||
builder.append(" "sv);
|
|
||||||
builder.appendff(" ({}: {})\n", property.name, property.value);
|
builder.appendff(" ({}: {})\n", property.name, property.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue