mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 04:07:35 +00:00
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:
parent
5eb1f752ab
commit
d582828040
2 changed files with 9 additions and 10 deletions
|
@ -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());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue