mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +00:00
LibWeb: Introduce structure that maintains collapsible margins in BFC
Previously y position of boxes in block formatting context was calculated by looking at y position of previous in-flow sibling and adding collapsed margin of "collapse through" boxes lying between box currently being laid out and it's previous in-flow sibling. Here introduced BlockMarginState structure that maintains array of currently collapsible margins hence we no longer need to look at previous sibling to calculate y position of a box.
This commit is contained in:
parent
e3d5b67eaf
commit
fe8304d5de
5 changed files with 93 additions and 89 deletions
|
@ -44,9 +44,9 @@ public:
|
|||
|
||||
virtual float greatest_child_width(Box const&) override;
|
||||
|
||||
void layout_floating_box(Box const& child, BlockContainer const& containing_block, LayoutMode, AvailableSpace const&, LineBuilder* = nullptr);
|
||||
void layout_floating_box(Box const& child, BlockContainer const& containing_block, LayoutMode, AvailableSpace const&, float y, LineBuilder* = nullptr);
|
||||
|
||||
void layout_block_level_box(Box const&, BlockContainer const&, LayoutMode, float& bottom_of_lowest_margin_box, AvailableSpace const&);
|
||||
void layout_block_level_box(Box const&, BlockContainer const&, LayoutMode, float& bottom_of_lowest_margin_box, AvailableSpace const&, float& current_y);
|
||||
|
||||
virtual bool can_determine_size_of_child() const override { return true; }
|
||||
virtual void determine_width_of_child(Box const&, AvailableSpace const&) override;
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
|
||||
static void resolve_vertical_box_model_metrics(Box const& box, LayoutState&);
|
||||
void place_block_level_element_in_normal_flow_horizontally(Box const& child_box, AvailableSpace const&);
|
||||
void place_block_level_element_in_normal_flow_vertically(Box const&);
|
||||
void place_block_level_element_in_normal_flow_vertically(Box const&, float y);
|
||||
|
||||
void layout_list_item_marker(ListItemBox const&);
|
||||
|
||||
|
@ -111,6 +111,24 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
struct BlockMarginState {
|
||||
Vector<float> current_collapsible_margins;
|
||||
|
||||
void add_margin(float margin)
|
||||
{
|
||||
current_collapsible_margins.append(margin);
|
||||
}
|
||||
|
||||
float current_collapsed_margin() const;
|
||||
|
||||
void reset()
|
||||
{
|
||||
current_collapsible_margins.clear();
|
||||
}
|
||||
};
|
||||
|
||||
BlockMarginState m_margin_state;
|
||||
|
||||
FloatSideData m_left_floats;
|
||||
FloatSideData m_right_floats;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue