From b34b0a1cd36aac21c2591a82dc9beaadcdf7a48b Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 9 Aug 2023 16:59:20 +0200 Subject: [PATCH] LibWeb: Use root content width as automatic width if children inline Returning greatest_child_width() from automatic_content_width() in BFC if root box children are inline and there are min/max-width that caused width to be changed after IFC layout while content_width should be always set to correct value by layout_inline_children() regardless of layout mode. --- .../expected/grid/justify-start-min-width.txt | 16 ++++++++++++++++ .../Layout/expected/grid/min-max-content.txt | 16 ++++++++-------- .../input/grid/justify-start-min-width.html | 11 +++++++++++ .../LibWeb/Layout/BlockFormattingContext.cpp | 2 ++ 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/grid/justify-start-min-width.txt create mode 100644 Tests/LibWeb/Layout/input/grid/justify-start-min-width.html diff --git a/Tests/LibWeb/Layout/expected/grid/justify-start-min-width.txt b/Tests/LibWeb/Layout/expected/grid/justify-start-min-width.txt new file mode 100644 index 00000000000..a43c9d38d3e --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/justify-start-min-width.txt @@ -0,0 +1,16 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x33.46875 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x17.46875 children: not-inline + Box at (8,8) content-size 784x17.46875 [GFC] children: not-inline + BlockContainer at (8,8) content-size 288x17.46875 [BFC] children: inline + line 0 width: 102.75, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 13, rect: [8,8 102.75x17.46875] + "Start Selling" + TextNode <#text> + +PaintableWithLines (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x33.46875] + PaintableWithLines (BlockContainer) [8,8 784x17.46875] + PaintableBox (Box
#grid) [8,8 784x17.46875] + PaintableWithLines (BlockContainer#box) [8,8 288x17.46875] + TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/expected/grid/min-max-content.txt b/Tests/LibWeb/Layout/expected/grid/min-max-content.txt index 047f5177342..44ce03cedf0 100644 --- a/Tests/LibWeb/Layout/expected/grid/min-max-content.txt +++ b/Tests/LibWeb/Layout/expected/grid/min-max-content.txt @@ -4,23 +4,23 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline Box at (8,8) content-size 784x17.46875 [GFC] children: not-inline BlockContainer <(anonymous)> (not painted) [BFC] children: inline TextNode <#text> - BlockContainer at (8,8) content-size 93.765625x17.46875 [BFC] children: inline + BlockContainer at (8,8) content-size 0x17.46875 [BFC] children: inline line 0 width: 93.765625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 frag 0 from TextNode start: 0, length: 11, rect: [8,8 93.765625x17.46875] "min-content" TextNode <#text> BlockContainer <(anonymous)> (not painted) [BFC] children: inline TextNode <#text> - BlockContainer at (101.765625,8) content-size 98.640625x17.46875 [BFC] children: inline + BlockContainer at (8,8) content-size 98.640625x17.46875 [BFC] children: inline line 0 width: 98.640625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 - frag 0 from TextNode start: 0, length: 11, rect: [101.765625,8 98.640625x17.46875] + frag 0 from TextNode start: 0, length: 11, rect: [8,8 98.640625x17.46875] "max-content" TextNode <#text> BlockContainer <(anonymous)> (not painted) [BFC] children: inline TextNode <#text> - BlockContainer at (200.40625,8) content-size 591.59375x17.46875 [BFC] children: inline + BlockContainer at (106.640625,8) content-size 685.359375x17.46875 [BFC] children: inline line 0 width: 21.609375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 - frag 0 from TextNode start: 0, length: 3, rect: [200.40625,8 21.609375x17.46875] + frag 0 from TextNode start: 0, length: 3, rect: [106.640625,8 21.609375x17.46875] "1fr" TextNode <#text> BlockContainer <(anonymous)> (not painted) [BFC] children: inline @@ -30,9 +30,9 @@ PaintableWithLines (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x600] PaintableWithLines (BlockContainer) [8,8 784x17.46875] PaintableBox (Box
.grid-container) [8,8 784x17.46875] - PaintableWithLines (BlockContainer
.grid-item) [8,8 93.765625x17.46875] + PaintableWithLines (BlockContainer
.grid-item) [8,8 0x17.46875] overflow: [8,8 93.765625x17.46875] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer
.grid-item) [101.765625,8 98.640625x17.46875] + PaintableWithLines (BlockContainer
.grid-item) [8,8 98.640625x17.46875] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer
.grid-item) [200.40625,8 591.59375x17.46875] + PaintableWithLines (BlockContainer
.grid-item) [106.640625,8 685.359375x17.46875] TextPaintable (TextNode<#text>) diff --git a/Tests/LibWeb/Layout/input/grid/justify-start-min-width.html b/Tests/LibWeb/Layout/input/grid/justify-start-min-width.html new file mode 100644 index 00000000000..ff663b01f25 --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/justify-start-min-width.html @@ -0,0 +1,11 @@ +