mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 06:27:34 +00:00
LibWeb: Unify placement of replaced and non-replaced elements in BFC
Seems like we can share the code for these.
This commit is contained in:
parent
9a48368280
commit
bb6af641d4
2 changed files with 5 additions and 22 deletions
|
@ -413,10 +413,8 @@ void BlockFormattingContext::layout_block_level_children(BlockContainer& block_c
|
||||||
if (child_box.computed_values().position() == CSS::Position::Relative)
|
if (child_box.computed_values().position() == CSS::Position::Relative)
|
||||||
compute_position(child_box);
|
compute_position(child_box);
|
||||||
|
|
||||||
if (is<ReplacedBox>(child_box))
|
if (is<ReplacedBox>(child_box) || is<BlockContainer>(child_box))
|
||||||
place_block_level_replaced_element_in_normal_flow(child_box, block_container);
|
place_block_level_element_in_normal_flow(child_box, block_container);
|
||||||
else if (is<BlockContainer>(child_box))
|
|
||||||
place_block_level_non_replaced_element_in_normal_flow(child_box, block_container);
|
|
||||||
|
|
||||||
// FIXME: This should be factored differently. It's uncool that we mutate the tree *during* layout!
|
// FIXME: This should be factored differently. It's uncool that we mutate the tree *during* layout!
|
||||||
// Instead, we should generate the marker box during the tree build.
|
// Instead, we should generate the marker box during the tree build.
|
||||||
|
@ -448,20 +446,7 @@ void BlockFormattingContext::compute_vertical_box_model_metrics(Box& child_box,
|
||||||
box_model.padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
|
box_model.padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFormattingContext::place_block_level_replaced_element_in_normal_flow(Box& child_box, BlockContainer const& containing_block)
|
void BlockFormattingContext::place_block_level_element_in_normal_flow(Box& child_box, BlockContainer const& containing_block)
|
||||||
{
|
|
||||||
VERIFY(!containing_block.is_absolutely_positioned());
|
|
||||||
auto& box_model = child_box.box_model();
|
|
||||||
|
|
||||||
compute_vertical_box_model_metrics(child_box, containing_block);
|
|
||||||
|
|
||||||
float x = box_model.margin_box().left + box_model.offset.left;
|
|
||||||
float y = box_model.margin_box().top + box_model.offset.top;
|
|
||||||
|
|
||||||
child_box.set_offset(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_flow(Box& child_box, BlockContainer const& containing_block)
|
|
||||||
{
|
{
|
||||||
auto& box_model = child_box.box_model();
|
auto& box_model = child_box.box_model();
|
||||||
auto const& computed_values = child_box.computed_values();
|
auto const& computed_values = child_box.computed_values();
|
||||||
|
@ -574,7 +559,7 @@ void BlockFormattingContext::layout_floating_child(Box& box, BlockContainer cons
|
||||||
compute_height(box);
|
compute_height(box);
|
||||||
|
|
||||||
// First we place the box normally (to get the right y coordinate.)
|
// First we place the box normally (to get the right y coordinate.)
|
||||||
place_block_level_non_replaced_element_in_normal_flow(box, containing_block);
|
place_block_level_element_in_normal_flow(box, containing_block);
|
||||||
|
|
||||||
auto float_box = [&](FloatSide side, FloatSideData& side_data) {
|
auto float_box = [&](FloatSide side, FloatSideData& side_data) {
|
||||||
auto first_edge = [&](PixelBox const& thing) { return side == FloatSide::Left ? thing.left : thing.right; };
|
auto first_edge = [&](PixelBox const& thing) { return side == FloatSide::Left ? thing.left : thing.right; };
|
||||||
|
|
|
@ -50,9 +50,7 @@ private:
|
||||||
void layout_inline_children(BlockContainer&, LayoutMode);
|
void layout_inline_children(BlockContainer&, LayoutMode);
|
||||||
|
|
||||||
void compute_vertical_box_model_metrics(Box& child_box, BlockContainer const& containing_block);
|
void compute_vertical_box_model_metrics(Box& child_box, BlockContainer const& containing_block);
|
||||||
|
void place_block_level_element_in_normal_flow(Box& child_box, BlockContainer const&);
|
||||||
void place_block_level_replaced_element_in_normal_flow(Box& child, BlockContainer const&);
|
|
||||||
void place_block_level_non_replaced_element_in_normal_flow(Box& float_side, BlockContainer const&);
|
|
||||||
|
|
||||||
void layout_floating_child(Box& child, BlockContainer const& containing_block);
|
void layout_floating_child(Box& child, BlockContainer const& containing_block);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue