Truly independent web browser
LibWeb: Place fixed-width tables below floats when they don't fit
Andreas Kling8cfb32b04070
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 9db994cf802..431d40c9d64 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -722,11 +722,15 @@ impl<'pass> BlockFormattingContext<'pass> {// We use that inline size as the input here to ensure that margins get resolved.replaced_inline_size} else if facts.is_table_wrapper() {+ // NB: An auto-width table shrinks to fit the space next to floats. A table with a specified width does not,+ // so clamp it against the containing block instead. That way a table which is too wide for the space+ // next to floats reports its real size and gets placed below the floats.+ let table_has_specified_inline_size = !self.style(sizing.table_box_inside_wrapper(node)).width().is_auto();Some(sizing.compute_table_box_inline_size_inside_wrapper(node,remaining_available_space,constraints,- None,+ table_has_specified_inline_size.then_some(available_inline_size),formatting_context::TableWrapperInlineSizeMode::ClampToAvailableInlineSize,))} else if facts.uses_button_layout() && style.width().is_auto() {diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/table-too-wide-for-float-gap-moves-below-float.txt b/Tests/LibWeb/Layout/expected/block-and-inline/table-too-wide-for-float-gap-moves-below-float.txtindex 80c0d7d9c4b..6794a523076 100644--- a/Tests/LibWeb/Layout/expected/block-and-inline/table-too-wide-for-float-gap-moves-below-float.txt+++ b/Tests/LibWeb/Layout/expected/block-and-inline/table-too-wide-for-float-gap-moves-below-float.txt@@ -1,14 +1,14 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 70 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [0,0] [0+0+0 600 0+0+200] [0+0+0 70 0+0+0] children: not-inline+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 75 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [0,0] [0+0+0 600 0+0+200] [0+0+0 75 0+0+0] children: not-inlineBlockContainer <div.bar> at [0,0] [0+0+0 600 0+0+0] [0+0+0 20 0+0+0] children: not-inlineBlockContainer <div.float> at [0,0] floating [0+0+0 150 0+0+0] [0+0+0 25 0+0+0] [BFC] children: not-inlineBlockContainer <(anonymous)> at [0,20] [0+0+0 600 0+0+0] [0+0+0 0 0+0+0] children: inlineTextNode <#text> (not painted)- TableWrapper <(anonymous)> at [150,20] [0+0+0 600 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline- Box <div.table> at [150,20] table-box [0+0+0 600 0+0+-150] [0+0+0 50 0+0+0] [TFC] children: not-inline- BlockContainer <(anonymous)> at [0,70] [0+0+0 600 0+0+0] [0+0+0 0 0+0+0] children: inline+ TableWrapper <(anonymous)> at [0,25] [0+0+0 600 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline+ Box <div.table> at [0,25] table-box [0+0+0 600 0+0+0] [0+0+0 50 0+0+0] [TFC] children: not-inline+ BlockContainer <(anonymous)> at [0,75] [0+0+0 600 0+0+0] [0+0+0 0 0+0+0] children: inlineTextNode <#text> (not painted)SC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x70] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x75] (z-index: auto)