瀏覽代碼

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.
Andreas Kling 4 年之前
父節點
當前提交
cb04a5c52c
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Libraries/LibWeb/Layout/BlockFormattingContext.cpp

+ 4 - 0
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.