diff --git a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index fd0f5e545e8..e2187fee2a3 100644 --- a/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -283,7 +283,8 @@ void InlineFormattingContext::generate_line_boxes() if (item.node) { auto introduce_clearance = parent().clear_floating_boxes(*item.node, *this); if (introduce_clearance == BlockFormattingContext::DidIntroduceClearance::Yes) { - line_builder.set_current_block_offset(vertical_float_clearance()); + if (vertical_float_clearance() > line_builder.current_block_offset()) + line_builder.set_current_block_offset(vertical_float_clearance()); parent().reset_margin_state(); } } diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/float-vertical-clearance-for-text-after-break.txt b/Tests/LibWeb/Layout/expected/block-and-inline/float-vertical-clearance-for-text-after-break.txt new file mode 100644 index 00000000000..e9ade08de08 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/block-and-inline/float-vertical-clearance-for-text-after-break.txt @@ -0,0 +1,24 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x100 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x84 children: not-inline + BlockContainer at (8,8) content-size 50x84 children: inline + frag 0 from TextNode start: 1, length: 3, rect: [8,58 27.15625x17] baseline: 13.296875 + "foo" + frag 1 from TextNode start: 1, length: 3, rect: [8,75 27.640625x17] baseline: 13.296875 + "bar" + TextNode <#text> + BlockContainer at (8,8) content-size 50x50 floating [BFC] children: not-inline + TextNode <#text> + BreakNode + TextNode <#text> + BlockContainer <(anonymous)> at (8,92) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x100] + PaintableWithLines (BlockContainer) [8,8 784x84] + PaintableWithLines (BlockContainer
.a) [8,8 50x84] + PaintableWithLines (BlockContainer
.b) [8,8 50x50] + TextPaintable (TextNode<#text>) + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [8,92 784x0] diff --git a/Tests/LibWeb/Layout/input/block-and-inline/float-vertical-clearance-for-text-after-break.html b/Tests/LibWeb/Layout/input/block-and-inline/float-vertical-clearance-for-text-after-break.html new file mode 100644 index 00000000000..a1a580babd0 --- /dev/null +++ b/Tests/LibWeb/Layout/input/block-and-inline/float-vertical-clearance-for-text-after-break.html @@ -0,0 +1,21 @@ + + +
+
+ foo +
+ bar +