From 3c897e7cf3594f02f559599e1bf28747c9edba13 Mon Sep 17 00:00:00 2001 From: BenJilks Date: Mon, 15 Jul 2024 16:07:06 +0100 Subject: [PATCH] LibWeb: Propagate margin and offset when computing a box's baseline When traversing the layout tree to find an appropriate box child to derive the baseline from. Only the child's margin and offset was being applied. Now we sum each offset on the recursive call. --- .../button-baseline-align.txt | 14 +++---- .../block-and-inline/button-image-only.txt | 2 +- ...should-have-vertically-aligned-content.txt | 2 +- .../button-with-after-pseudo.txt | 2 +- .../button-with-before-pseudo.txt | 2 +- ...tton-with-block-content-baseline-align.txt | 14 +++---- .../button-with-min-height.txt | 2 +- ...on-with-multiple-words-text-node-label.txt | 2 +- ...ton-with-text-node-label-and-font-size.txt | 2 +- .../button-with-text-node-label.txt | 2 +- .../inline-block-baseline-1.txt | 4 +- .../inline-block-baseline-2.txt | 4 +- .../block-and-inline/margin-collapse-5.txt | 2 +- ...-box-for-definite-sizes-without-layout.txt | 20 +++++----- .../Layout/expected/css-line-height-zero.txt | 2 +- .../flex/inline-flex-baseline-of-child.txt | 39 ++++++++++++++++++ ...-early-resolution-of-percentage-height.txt | 2 +- ...ith-main-axis-margin-on-flex-container.txt | 2 +- .../expected/grid/inline-grid-simple.txt | 2 +- Tests/LibWeb/Layout/expected/input-file.txt | 40 +++++++++---------- .../Layout/expected/input-image-to-text.txt | 2 +- .../expected/input-password-to-text.txt | 2 +- .../Layout/expected/input-placeholder.txt | 12 +++--- ...text-node-invalidation-on-value-change.txt | 2 +- .../expected/input-text-to-password.txt | 2 +- .../expected/select-with-option-selected.txt | 2 +- .../table/border-collapse-is-inherited.txt | 2 +- .../expected/table/inline-table-width.txt | 2 +- .../Layout/expected/textarea-content.txt | 8 ++-- .../LibWeb/Layout/expected/textarea-reset.txt | 2 +- .../flex/inline-flex-baseline-of-child.html | 15 +++++++ .../LibWeb/Layout/FormattingContext.cpp | 2 +- 32 files changed, 134 insertions(+), 80 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/flex/inline-flex-baseline-of-child.txt create mode 100644 Tests/LibWeb/Layout/input/flex/inline-flex-baseline-of-child.html diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/button-baseline-align.txt b/Tests/LibWeb/Layout/expected/block-and-inline/button-baseline-align.txt index f288c446c0e..7fe178b4311 100644 --- a/Tests/LibWeb/Layout/expected/block-and-inline/button-baseline-align.txt +++ b/Tests/LibWeb/Layout/expected/block-and-inline/button-baseline-align.txt @@ -1,15 +1,15 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline BlockContainer at (8,8) content-size 784x48 children: inline - frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 61.1875x48] baseline: 34 + frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 61.1875x48] baseline: 36 BlockContainer at (8,8) content-size 61.1875x48 inline-block [BFC] children: inline - frag 0 from BlockContainer start: 0, length: 0, rect: [9,25 17.828125x22] baseline: 18 - frag 1 from TextNode start: 0, length: 1, rect: [28,28 8x17] baseline: 13.296875 + frag 0 from BlockContainer start: 0, length: 0, rect: [9,27 17.828125x22] baseline: 18 + frag 1 from TextNode start: 0, length: 1, rect: [28,30 8x17] baseline: 13.296875 " " - frag 2 from BlockContainer start: 0, length: 0, rect: [41,10 23.359375x44] baseline: 34 + frag 2 from BlockContainer start: 0, length: 0, rect: [41,10 23.359375x44] baseline: 36 TextNode <#text> - BlockContainer at (9,25) content-size 17.828125x22 inline-block [BFC] children: inline - frag 0 from TextNode start: 0, length: 1, rect: [9,25 17.828125x22] baseline: 17 + BlockContainer at (9,27) content-size 17.828125x22 inline-block [BFC] children: inline + frag 0 from TextNode start: 0, length: 1, rect: [9,27 17.828125x22] baseline: 17 "A" TextNode <#text> TextNode <#text> @@ -25,7 +25,7 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x600] PaintableWithLines (BlockContainer) [8,8 784x48] PaintableWithLines (BlockContainer
.ib) [8,8 61.1875x48] - PaintableWithLines (BlockContainer
.label) [8,24 19.828125x24] + PaintableWithLines (BlockContainer
.label) [8,26 19.828125x24] TextPaintable (TextNode<#text>) TextPaintable (TextNode<#text>) PaintableWithLines (BlockContainer