From 9711e1b303a420d3a2cdf70db2f808b7f6c6ab4f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 29 Mar 2022 12:35:31 +0200 Subject: [PATCH] LibWeb: Make floating boxes in IFC occupy horizontal margin box Previously, we only allowed floats to take up its own border box's worth of horizontal space when laid out inside an IFC. We should instead consume the full margin box horizonally. This fixes an issue where a floated box on Acid3 had {width:20px; margin-right:-20px;} but still consumed 20px of the previously available space, despite being moved out of the way by its own negative margin. --- Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index b96592e53b..e8e4cc63eb 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -606,9 +606,9 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer // If we have a LineBuilder, we're in the middle of inline layout, otherwise this is block layout. if (line_builder) { float y_offset = box_state.margin_box_top(); - line_builder->break_if_needed(layout_mode, box_state.border_box_width()); + line_builder->break_if_needed(layout_mode, box_state.margin_box_width()); box_state.offset.set_y(line_builder->current_y() + y_offset); - line_builder->adjust_last_line_after_inserting_floating_box({}, box.computed_values().float_(), box_state.border_box_width()); + line_builder->adjust_last_line_after_inserting_floating_box({}, box.computed_values().float_(), box_state.margin_box_width()); } else { place_block_level_element_in_normal_flow_vertically(box, containing_block); place_block_level_element_in_normal_flow_horizontally(box, containing_block);