Skip to content

Truly independent web browser

LibWeb: Reset flex targets when no free space remains to distribute

Andreas Klinga6c49907edbd
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index f235b043790..3296a1f08b0 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -1765,6 +1765,17 @@ impl<'pass> FlexFormattingContext<'pass> {
distributed = distributed_including_item;
}
}
+ } else {
+ // INTEROP: Distributing no free space leaves the unfrozen items at their flex base size, rather than at
+ // a target main size left over from a previous iteration of this loop. Otherwise, an item
+ // that was shrunk before another item froze at its max size stays shrunk, even though the
+ // line now has room for it.
+ for item_position in 0..item_count {
+ let index = self.flex_lines[line_index].items[item_position];
+ if !self.flex_items[index].frozen {
+ self.flex_items[index].target_main_size = self.flex_items[index].flex_base_size;
+ }
+ }
}
// d. Fix min/max violations.
diff --git a/Tests/LibWeb/Layout/expected/flex/flex-shrink-item-restored-after-sibling-freezes-at-max-size.txt b/Tests/LibWeb/Layout/expected/flex/flex-shrink-item-restored-after-sibling-freezes-at-max-size.txt
index 34b8565f8e6..96f0b1e1b54 100644
--- a/Tests/LibWeb/Layout/expected/flex/flex-shrink-item-restored-after-sibling-freezes-at-max-size.txt
+++ b/Tests/LibWeb/Layout/expected/flex/flex-shrink-item-restored-after-sibling-freezes-at-max-size.txt
@@ -24,23 +24,23 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text> (not painted)
- BlockContainer <div.sidecar> at [600,0] flex-item [24+0+0 31.875 0+0+24] [0+0+0 200 0+0+0] [BFC] children: not-inline overflow: [600,0 75.515625x200]
- BlockContainer <ul> at [600,0] [0+0+0 31.875 0+0+0] [0+0+0 72 0+0+0] children: not-inline
- ListItemBox <li> at [600,0] [0+0+0 31.875 0+0+0] [0+0+0 24 0+0+0] children: not-inline
+ BlockContainer <div.sidecar> at [600,0] flex-item [24+0+0 100 0+0+24] [0+0+0 200 0+0+0] [BFC] children: not-inline
+ BlockContainer <ul> at [600,0] [0+0+0 100 0+0+0] [0+0+0 72 0+0+0] children: not-inline
+ ListItemBox <li> at [600,0] [0+0+0 100 0+0+0] [0+0+0 24 0+0+0] children: not-inline
ListItemMarkerBox <(anonymous)> at [586,0] [0+0+0 13.84375 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from GeneratedTextNode start: 0, length: 2, rect: [586,4 13.84375x16] baseline: 12.796875
"• "
GeneratedTextNode <(anonymous)> (not painted)
- BlockContainer <p> at [600,0] [0+0+0 31.875 0+0+0] [0+0+0 24 0+0+0] children: inline
+ BlockContainer <p> at [600,0] [0+0+0 100 0+0+0] [0+0+0 24 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 8, rect: [600,4 66.765625x16] baseline: 12.796875
"Security"
TextNode <#text> (not painted)
- ListItemBox <li> at [600,24] [0+0+0 31.875 0+0+0] [0+0+0 48 0+0+0] children: not-inline
+ ListItemBox <li> at [600,24] [0+0+0 100 0+0+0] [0+0+0 48 0+0+0] children: not-inline
ListItemMarkerBox <(anonymous)> at [586,24] [0+0+0 13.84375 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from GeneratedTextNode start: 0, length: 2, rect: [586,28 13.84375x16] baseline: 12.796875
"• "
GeneratedTextNode <(anonymous)> (not painted)
- BlockContainer <p> at [600,24] [0+0+0 31.875 0+0+0] [0+0+0 48 0+0+0] children: inline
+ BlockContainer <p> at [600,24] [0+0+0 100 0+0+0] [0+0+0 48 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 10, rect: [600,28 75.515625x16] baseline: 12.796875
"Highlights"
frag 1 from TextNode start: 11, length: 4, rect: [600,52 35.5625x16] baseline: 12.796875
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/multiline-min-max.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/multiline-min-max.txt
index ba5c9153cf0..7db781f30ff 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/multiline-min-max.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/multiline-min-max.txt
@@ -2,19 +2,18 @@ Harness status: OK
Found 14 tests
-11 Pass
-3 Fail
+14 Pass
Pass .flexbox 1
Pass .flexbox 2
Pass .flexbox 3
Pass .flexbox 4
-Fail .flexbox 5
+Pass .flexbox 5
Pass .flexbox 6
Pass .flexbox 7
Pass .flexbox 8
Pass .flexbox 9
Pass .flexbox 10
Pass .flexbox 11
-Fail .flexbox 12
-Fail .flexbox 13
+Pass .flexbox 12
+Pass .flexbox 13
Pass .flexbox 14
\ No newline at end of file