LibWeb: Layout floating children per block instead of whole BFC at once

Instead of plowing through all the floating boxes within a BFC and
doing all the layout up front, do the children of each block as we go.
This will allow us to know the vertical position of the containing
block when placing floats.
This commit is contained in:
Andreas Kling 2020-12-06 16:15:35 +01:00
commit d582828040
Notes: sideshowbarker 2024-07-19 01:01:12 +09:00
2 changed files with 9 additions and 10 deletions

View file

@ -65,7 +65,7 @@ void BlockFormattingContext::run(LayoutMode layout_mode)
if (layout_mode == LayoutMode::Default)
compute_width(context_box());
layout_floating_descendants();
layout_floating_children();
if (context_box().children_are_inline()) {
layout_inline_children(layout_mode);
@ -615,7 +615,7 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
icb.set_width(viewport_rect.width());
layout_floating_descendants();
layout_floating_children();
layout_block_level_children(layout_mode);
@ -651,17 +651,16 @@ void BlockFormattingContext::layout_absolutely_positioned_descendants()
});
}
void BlockFormattingContext::layout_floating_descendants()
void BlockFormattingContext::layout_floating_children()
{
context_box().for_each_in_subtree_of_type<Box>([&](auto& box) {
if (box.is_floating() && box.containing_block() == &context_box()) {
layout_floating_descendant(box);
}
context_box().for_each_child_of_type<Box>([&](auto& box) {
if (box.is_floating())
layout_floating_child(box);
return IterationDecision::Continue;
});
}
void BlockFormattingContext::layout_floating_descendant(Box& box)
void BlockFormattingContext::layout_floating_child(Box& box)
{
ASSERT(box.is_floating());