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

LibWeb: LayoutNodes know whether they are flex-items

This is useful for debugging when dumping the layout tree.
This commit is contained in:
Tobias Christiansen 2021-05-29 22:36:15 +02:00 committed by Ali Mohammad Pur
parent 2205239d9a
commit 7f81c8fba2
3 changed files with 10 additions and 1 deletions

View file

@ -165,7 +165,9 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
if (box.is_inline_block())
builder.appendff(" {}inline-block{}", inline_block_color_on, color_off);
if (box.computed_values().display() == CSS::Display::Flex)
builder.appendff(" {}flex{}", flex_color_on, color_off);
builder.appendff(" {}flex-container{}", flex_color_on, color_off);
if (box.is_flex_item())
builder.appendff(" {}flex-item{}", flex_color_on, color_off);
if (show_box_model) {
// Dump the horizontal box properties

View file

@ -42,6 +42,8 @@ void FlexFormattingContext::run(Box& box, LayoutMode layout_mode)
float tallest_child_height = 0;
float widest_child_width = 0;
box.for_each_child_of_type<Box>([&](Box& child_box) {
child_box.set_flex_item(true);
child_box.set_offset(x, y);
tallest_child_height = max(tallest_child_height, child_box.height());
widest_child_width = max(widest_child_width, child_box.width());

View file

@ -109,6 +109,9 @@ public:
bool is_absolutely_positioned() const;
bool is_fixed_position() const;
bool is_flex_item() const { return m_is_flex_item; }
void set_flex_item(bool b) { m_is_flex_item = b; }
const BlockBox* containing_block() const;
BlockBox* containing_block() { return const_cast<BlockBox*>(const_cast<const Node*>(this)->containing_block()); }
@ -182,6 +185,8 @@ private:
bool m_visible { true };
bool m_children_are_inline { false };
SelectionState m_selection_state { SelectionState::None };
bool m_is_flex_item { false };
};
class NodeWithStyle : public Node {