From 66e9dde86f723303209bbe1d038188082262512b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 12 Dec 2020 19:31:46 +0100 Subject: [PATCH] LibWeb: Don't place floating boxes before everything else Instead, just handle them as we go about laying out block-level boxes. --- .../LibWeb/Layout/BlockFormattingContext.cpp | 17 +++-------------- .../LibWeb/Layout/BlockFormattingContext.h | 1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 6691d4c637..f448e37b62 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -65,8 +65,6 @@ void BlockFormattingContext::run(Box& box, LayoutMode layout_mode) if (layout_mode == LayoutMode::Default) compute_width(box); - layout_floating_children(box); - if (box.children_are_inline()) { layout_inline_children(box, layout_mode); } else { @@ -458,8 +456,10 @@ void BlockFormattingContext::layout_block_level_children(Box& box, LayoutMode la return IterationDecision::Continue; } - if (child_box.is_floating()) + if (child_box.is_floating()) { + layout_floating_child(child_box, box); return IterationDecision::Continue; + } compute_width(child_box); layout_inside(child_box, layout_mode); @@ -604,8 +604,6 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m icb.set_width(viewport_rect.width()); - layout_floating_children(context_box()); - layout_block_level_children(context_box(), layout_mode); ASSERT(!icb.children_are_inline()); @@ -626,15 +624,6 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m }); } -void BlockFormattingContext::layout_floating_children(Box& box) -{ - box.for_each_child_of_type([&](auto& child_box) { - if (child_box.is_floating()) - layout_floating_child(child_box, box); - return IterationDecision::Continue; - }); -} - static Gfx::FloatRect rect_in_coordinate_space(const Box& box, const Box& context_box) { Gfx::FloatRect rect { box.effective_offset(), box.size() }; diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.h b/Libraries/LibWeb/Layout/BlockFormattingContext.h index d4d830a8f7..1fbb4a857f 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.h +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.h @@ -61,7 +61,6 @@ private: void layout_block_level_children(Box&, LayoutMode); void layout_inline_children(Box&, LayoutMode); - void layout_floating_children(Box&); void place_block_level_replaced_element_in_normal_flow(Box& child, Box& container); void place_block_level_non_replaced_element_in_normal_flow(Box& child, Box& container);