Skip to content

Commit

Permalink
LibWeb: Use correct coordinate space when measuring space between floats
Browse files Browse the repository at this point in the history
When calculating how much space is available for inline content between
left and right floated elements, we have to use coordinates in the
containing block's coordinate space, since that's what floats use.

This fixes an issue where text would sometimes overlap floats.
  • Loading branch information
awesomekling committed Feb 21, 2022
1 parent 8c2a4a2 commit bb1f26c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ InlineFormattingContext::AvailableSpaceForLineInfo InlineFormattingContext::avai

for (ssize_t i = bfc.left_side_floats().boxes.size() - 1; i >= 0; --i) {
auto const& floating_box = bfc.left_side_floats().boxes.at(i);
auto rect = margin_box_rect(floating_box, m_state);
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box, parent().root(), m_state);
if (rect.contains_vertically(y_in_root)) {
info.left = rect.right() + 1;
break;
Expand All @@ -59,7 +59,7 @@ InlineFormattingContext::AvailableSpaceForLineInfo InlineFormattingContext::avai

for (ssize_t i = bfc.right_side_floats().boxes.size() - 1; i >= 0; --i) {
auto const& floating_box = bfc.right_side_floats().boxes.at(i);
auto rect = margin_box_rect(floating_box, m_state);
auto rect = margin_box_rect_in_ancestor_coordinate_space(floating_box, parent().root(), m_state);
if (rect.contains_vertically(y_in_root)) {
info.right = rect.left() - 1;
break;
Expand Down

0 comments on commit bb1f26c

Please sign in to comment.