Skip to content

Commit cb04a5c

Browse files
committed
LibWeb: Forget floating boxes once we've gone past them
Once we've generated enough lines to make it past all the floating boxes on either side, just forget those boxes. This simplifies the available space computation since we don't have to consider boxes that can't vertically intersect the current line anyway.
1 parent 9470169 commit cb04a5c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Libraries/LibWeb/Layout/BlockFormattingContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ void BlockFormattingContext::layout_floating_child(Box& box, Box& containing_blo
671671
} else {
672672
// This box does not touch another floating box, go all the way to the left.
673673
x = 0;
674+
// Also, forget all previous left-floating boxes while we're here since they're no longer relevant.
675+
m_left_floating_boxes.clear();
674676
}
675677
} else {
676678
// This is the first left-floating box. Go all the way to the left.
@@ -687,6 +689,8 @@ void BlockFormattingContext::layout_floating_child(Box& box, Box& containing_blo
687689
} else {
688690
// This box does not touch another floating box, go all the way to the right.
689691
x = containing_block.width() - box.width();
692+
// Also, forget all previous right-floating boxes while we're here since they're no longer relevant.
693+
m_right_floating_boxes.clear();
690694
}
691695
} else {
692696
// This is the first right-floating box. Go all the way to the right.

0 commit comments

Comments
 (0)