mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Consider trailing_whitespace_advance when calling place_line_among_floats() (#30586)
After placing a float, FloatBox's layout_into_line_items() was calling place_line_among_floats() with ifc.current_line.inline_position as the width of needed by the contents of the line. The problem is that this amount includes the trailing whitespace advance and thus it could seem that the in-flow contents wouldn't fit next to the float. That's not the case, since collapsible whitespace at the end of the line is removed, and preserved whitespace hangs. So this patch subtracts ifc.current_line.trailing_whitespace_advance when calling place_line_among_floats(), like it was already happening when computing the available_inline_size. Fixes #30561
This commit is contained in:
parent
e95de5d858
commit
9af3495d8a
3 changed files with 4 additions and 7 deletions
|
@ -1475,11 +1475,12 @@ impl FloatBox {
|
|||
let margin_box = fragment.border_rect().inflate(&fragment.margin);
|
||||
let inline_size = margin_box.size.inline.max(Length::zero());
|
||||
|
||||
let inline_position =
|
||||
ifc.current_line.inline_position - ifc.current_line.trailing_whitespace_advance;
|
||||
let available_inline_size = match ifc.current_line.placement_among_floats.get() {
|
||||
Some(placement_among_floats) => placement_among_floats.size.inline,
|
||||
None => ifc.containing_block.inline_size,
|
||||
} - (ifc.current_line.inline_position -
|
||||
ifc.current_line.trailing_whitespace_advance);
|
||||
} - inline_position;
|
||||
|
||||
// If this float doesn't fit on the current line or a previous float didn't fit on
|
||||
// the current line, we need to place it starting at the next line BUT still as
|
||||
|
@ -1500,7 +1501,7 @@ impl FloatBox {
|
|||
// placement among floats for the current line, which may adjust its inline
|
||||
// start position.
|
||||
let new_placement = ifc.place_line_among_floats(&LogicalVec2 {
|
||||
inline: ifc.current_line.inline_position,
|
||||
inline: inline_position,
|
||||
block: ifc.current_line.max_block_size,
|
||||
});
|
||||
ifc.current_line
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue