mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +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
Notes:
sideshowbarker
2024-07-19 01:01:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d5828280401
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());
|
||||
|
||||
|
|
|
@ -58,13 +58,13 @@ private:
|
|||
void layout_block_level_children(LayoutMode);
|
||||
void layout_inline_children(LayoutMode);
|
||||
void layout_absolutely_positioned_descendants();
|
||||
void layout_floating_descendants();
|
||||
void layout_floating_children();
|
||||
|
||||
void place_block_level_replaced_element_in_normal_flow(Box&);
|
||||
void place_block_level_non_replaced_element_in_normal_flow(Box&);
|
||||
|
||||
void layout_absolutely_positioned_descendant(Box&);
|
||||
void layout_floating_descendant(Box&);
|
||||
void layout_floating_child(Box&);
|
||||
|
||||
Vector<Box*> m_left_floating_boxes;
|
||||
Vector<Box*> m_right_floating_boxes;
|
||||
|
|
Loading…
Add table
Reference in a new issue