aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2023-10-20 13:47:23 +0200
committerGitHub <noreply@github.com>2023-10-20 11:47:23 +0000
commit9af3495d8aed9a7738824b3eed1e834ba77b6a47 (patch)
tree89c9078dd3f63c8b6b00218105acb5b6f580cab6
parente95de5d858e7f9a49dc3fe9e8818b46c3a3790e0 (diff)
downloadservo-9af3495d8aed9a7738824b3eed1e834ba77b6a47.tar.gz
servo-9af3495d8aed9a7738824b3eed1e834ba77b6a47.zip
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
-rw-r--r--components/layout_2020/flow/inline.rs7
-rw-r--r--tests/wpt/meta/css/CSS2/floats-clear/floats-006.xht.ini2
-rw-r--r--tests/wpt/meta/css/CSS2/floats/remove-block-between-inline-and-float.html.ini2
3 files changed, 4 insertions, 7 deletions
diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs
index 5b3f9a37efe..4a229a32aaf 100644
--- a/components/layout_2020/flow/inline.rs
+++ b/components/layout_2020/flow/inline.rs
@@ -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
diff --git a/tests/wpt/meta/css/CSS2/floats-clear/floats-006.xht.ini b/tests/wpt/meta/css/CSS2/floats-clear/floats-006.xht.ini
deleted file mode 100644
index 47dc37acc02..00000000000
--- a/tests/wpt/meta/css/CSS2/floats-clear/floats-006.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[floats-006.xht]
- expected: FAIL
diff --git a/tests/wpt/meta/css/CSS2/floats/remove-block-between-inline-and-float.html.ini b/tests/wpt/meta/css/CSS2/floats/remove-block-between-inline-and-float.html.ini
deleted file mode 100644
index 5ef5e72a276..00000000000
--- a/tests/wpt/meta/css/CSS2/floats/remove-block-between-inline-and-float.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[remove-block-between-inline-and-float.html]
- expected: FAIL