1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:57:35 +00:00

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.
This commit is contained in:
Aliaksandr Kalenik 2023-01-17 11:57:00 +01:00 committed by Andreas Kling
parent 63cf9b973d
commit 56ceb6a106

View file

@ -773,7 +773,11 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
if (fits_on_line) {
auto const previous_rect = margin_box_rect_in_ancestor_coordinate_space(previous_box.box, root(), m_state);
if (previous_rect.contains_vertically(y_in_root + side_data.y_offset)) {
// NOTE: If we're in inline layout, the LineBuilder has already provided the right Y offset.
// In block layout, we adjust by the side's current Y offset here.
if (!line_builder)
y_in_root += side_data.y_offset;
if (previous_rect.contains_vertically(y_in_root)) {
// This box touches another already floating box. Stack after others.
offset_from_edge = wanted_offset_from_edge;
} else {