From 23f0fddeabe0e6fdddb131cce652c65f2acc859c Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Tue, 1 Apr 2025 11:44:23 +0200 Subject: [PATCH] LibWeb: Let LineBuilder decide on Y-coordinate for float insertion Instead of reaching into the IFC of the LineBuilder from the BFC, we should let LineBuilder determine how to deal with the running vertical float clearance. No functional changes. --- Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 2 +- Libraries/LibWeb/Layout/LineBuilder.cpp | 2 +- Libraries/LibWeb/Layout/LineBuilder.h | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 2fb3c120d62..aa93dbbbfcc 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -1051,7 +1051,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer // First we place the box normally (to get the right y coordinate.) // If we have a LineBuilder, we're in the middle of inline layout, otherwise this is block layout. if (line_builder) { - auto y = max(line_builder->y_for_float_to_be_inserted_here(box), line_builder->inline_formatting_context().vertical_float_clearance()); + auto y = line_builder->y_for_float_to_be_inserted_here(box); box_state.set_content_y(y + box_state.margin_box_top()); } else { place_block_level_element_in_normal_flow_vertically(box, y + box_state.margin_top); diff --git a/Libraries/LibWeb/Layout/LineBuilder.cpp b/Libraries/LibWeb/Layout/LineBuilder.cpp index 1f70212f466..a02f516e07a 100644 --- a/Libraries/LibWeb/Layout/LineBuilder.cpp +++ b/Libraries/LibWeb/Layout/LineBuilder.cpp @@ -162,7 +162,7 @@ CSSPixels LineBuilder::y_for_float_to_be_inserted_here(Box const& box) candidate_block_offset = highest_intersection_bottom.value(); } - return candidate_block_offset; + return max(candidate_block_offset, m_context.vertical_float_clearance()); } bool LineBuilder::should_break(CSSPixels next_item_width) diff --git a/Libraries/LibWeb/Layout/LineBuilder.h b/Libraries/LibWeb/Layout/LineBuilder.h index 0f4f971d2dc..9e1f2f03ca4 100644 --- a/Libraries/LibWeb/Layout/LineBuilder.h +++ b/Libraries/LibWeb/Layout/LineBuilder.h @@ -46,8 +46,6 @@ public: void recalculate_available_space(); CSSPixels y_for_float_to_be_inserted_here(Box const&); - auto& inline_formatting_context() { return m_context; } - void did_introduce_clearance(CSSPixels); private: