From cb04a5c52cbcbe614f09ef27c34bca4c537fd3d1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 6 Dec 2020 21:11:28 +0100 Subject: [PATCH] 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. --- Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 975ac13e75..648ed27f76 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -671,6 +671,8 @@ void BlockFormattingContext::layout_floating_child(Box& box, Box& containing_blo } else { // This box does not touch another floating box, go all the way to the left. x = 0; + // Also, forget all previous left-floating boxes while we're here since they're no longer relevant. + m_left_floating_boxes.clear(); } } else { // 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 } else { // This box does not touch another floating box, go all the way to the right. x = containing_block.width() - box.width(); + // Also, forget all previous right-floating boxes while we're here since they're no longer relevant. + m_right_floating_boxes.clear(); } } else { // This is the first right-floating box. Go all the way to the right.