Browse Source

LibWeb: Fix IFC over-shrinking the available space for line boxes

After accounting for left-side floats, we have to subtract the offset of
the IFC's containing block again, to get the real starting X offset
for the current line.

This was done correctly in leftmost_x_offset_at() but incorrectly in
available_space_for_line(), causing IFC to break lines too early in
cases where the containing block had a non-zero X offset from the BFC
root block.
Andreas Kling 3 years ago
parent
commit
83afc1154c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp

+ 1 - 1
Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp

@@ -57,7 +57,7 @@ float InlineFormattingContext::available_space_for_line(float y) const
     auto const& containing_block_state = m_state.get(containing_block());
     auto const& root_block_state = m_state.get(parent().root());
 
-    space.left = max(space.left, containing_block_state.offset.x());
+    space.left = max(space.left, containing_block_state.offset.x()) - containing_block_state.offset.x();
     space.right = min(root_block_state.content_width - space.right, containing_block_state.offset.x() + containing_block_state.content_width);
 
     return space.right - space.left;