Skip to content

Commit 56ceb6a

Browse files
kalenikaliaksandrawesomekling
authored andcommitted
LibWeb: Fix floats y offset calculation
There is a difference in y offset position calculation for floats when LineBuilder provides final y position while for blocks it needs to be adjusted by `y_offset`. This difference already accounted in floating box position calculation and this patch also makes it accounted in check whether a floating boxes on the same line intersect between each other.
1 parent 63cf9b9 commit 56ceb6a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,11 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
773773

774774
if (fits_on_line) {
775775
auto const previous_rect = margin_box_rect_in_ancestor_coordinate_space(previous_box.box, root(), m_state);
776-
if (previous_rect.contains_vertically(y_in_root + side_data.y_offset)) {
776+
// NOTE: If we're in inline layout, the LineBuilder has already provided the right Y offset.
777+
// In block layout, we adjust by the side's current Y offset here.
778+
if (!line_builder)
779+
y_in_root += side_data.y_offset;
780+
if (previous_rect.contains_vertically(y_in_root)) {
777781
// This box touches another already floating box. Stack after others.
778782
offset_from_edge = wanted_offset_from_edge;
779783
} else {

0 commit comments

Comments
 (0)