1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

LibWeb: Show formatting context roots in layout tree dumps

This patch does three things:

- Factors out the code that determines whether a box will create a new
  formatting context for its children (and which type of context)

- Uses that code to mark all formatting context roots in layout tree
  dumps. This makes it much easier to follow along with layout since
  you can now see exactly where control is transferred to a new
  formatting context.

- Rebaselines all existing layout tests, since the output format has
  changed slightly.
This commit is contained in:
Andreas Kling 2023-05-03 10:32:23 +02:00
parent 42e118e6a9
commit 968db96101
117 changed files with 905 additions and 851 deletions

View file

@ -24,6 +24,7 @@
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/HTMLTemplateElement.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/FrameBox.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/SVGBox.h>
@ -128,6 +129,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
StringView line_box_color_on = ""sv;
StringView fragment_color_on = ""sv;
StringView flex_color_on = ""sv;
StringView formatting_context_color_on = ""sv;
StringView color_off = ""sv;
if (interactive) {
@ -140,6 +142,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
line_box_color_on = "\033[34;1m"sv;
fragment_color_on = "\033[35;1m"sv;
flex_color_on = "\033[34;1m"sv;
formatting_context_color_on = "\033[37;1m"sv;
color_off = "\033[0m"sv;
}
@ -225,6 +228,28 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
box.box_model().margin.bottom);
}
if (auto formatting_context_type = Layout::FormattingContext::formatting_context_type_created_by_box(box); formatting_context_type.has_value()) {
switch (formatting_context_type.value()) {
case Layout::FormattingContext::Type::Block:
builder.appendff(" [{}BFC{}]", formatting_context_color_on, color_off);
break;
case Layout::FormattingContext::Type::Flex:
builder.appendff(" [{}FFC{}]", formatting_context_color_on, color_off);
break;
case Layout::FormattingContext::Type::Grid:
builder.appendff(" [{}GFC{}]", formatting_context_color_on, color_off);
break;
case Layout::FormattingContext::Type::Table:
builder.appendff(" [{}TFC{}]", formatting_context_color_on, color_off);
break;
case Layout::FormattingContext::Type::SVG:
builder.appendff(" [{}SVG{}]", formatting_context_color_on, color_off);
break;
default:
break;
}
}
builder.appendff(" children: {}", box.children_are_inline() ? "inline" : "not-inline");
if (is<Layout::FrameBox>(box)) {