LibWeb: Use entire margin box of floats when testing for intrusions

This commit is contained in:
Andreas Kling 2022-09-22 14:12:05 +02:00
parent 389f47f6fe
commit 54fb5af9ee
Notes: sideshowbarker 2024-07-17 06:43:45 +09:00

View File

@ -642,7 +642,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
}
if (fits_on_line) {
auto const previous_rect = border_box_rect_in_ancestor_coordinate_space(previous_box.box, root(), m_state);
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)) {
// This box touches another already floating box. Stack after others.
offset_from_edge = wanted_offset_from_edge;
@ -759,7 +759,7 @@ BlockFormattingContext::SpaceUsedByFloats BlockFormattingContext::space_used_by_
auto const& floating_box = *floating_box_ptr;
auto const& floating_box_state = m_state.get(floating_box.box);
// NOTE: The floating box is *not* in the final horizontal position yet, but the size and vertical position is valid.
auto rect = border_box_rect_in_ancestor_coordinate_space(floating_box.box, root(), m_state);
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box.box, root(), m_state);
if (rect.contains_vertically(y)) {
space_used_by_floats.left = floating_box.offset_from_edge
+ floating_box_state.content_width()
@ -772,7 +772,7 @@ BlockFormattingContext::SpaceUsedByFloats BlockFormattingContext::space_used_by_
auto const& floating_box = *floating_box_ptr;
auto const& floating_box_state = m_state.get(floating_box.box);
// NOTE: The floating box is *not* in the final horizontal position yet, but the size and vertical position is valid.
auto rect = border_box_rect_in_ancestor_coordinate_space(floating_box.box, root(), m_state);
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box.box, root(), m_state);
if (rect.contains_vertically(y)) {
space_used_by_floats.right = floating_box.offset_from_edge
+ floating_box_state.margin_box_left();