diff options
author | Andreas Kling <kling@serenityos.org> | 2023-03-27 20:56:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-27 23:28:07 +0200 |
commit | af118abdf0a735d23159eeeb2a867a6acb880977 (patch) | |
tree | d90aa705efa59fabdf65b93f2feacfe3526506b6 /Tests | |
parent | ca290b27eaadba2792585623ed8e24e2887d4485 (diff) | |
download | serenity-af118abdf0a735d23159eeeb2a867a6acb880977.zip |
LibWeb: Use fit-content width in place of indefinite flex item widths
In `flex-direction: column` layouts, a flex item's intrinsic height may
depend on its width, but the width is calculated *after* the intrinsic
height is required.
Unfortunately, the specification doesn't tell us exactly what to do here
(missing inputs to intrinsic sizing is a common problem) so we take the
solution that flexbox applies in 9.2.3.C and apply it to all intrinsic
height calculations within FlexFormattingContext: if the used width of
an item is not yet known when its intrinsic height is requested, we
substitute the fit-content width instead.
Note that while this is technically ad-hoc, it's basically extrapolating
the spec's suggestion in one specific case and using it in all cases.
Diffstat (limited to 'Tests')
2 files changed, 37 insertions, 0 deletions
diff --git a/Tests/LibWeb/Layout/expected/flex-column-item-with-auto-height-depending-on-auto-width.txt b/Tests/LibWeb/Layout/expected/flex-column-item-with-auto-height-depending-on-auto-width.txt new file mode 100644 index 0000000000..7a43441486 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/flex-column-item-with-auto-height-depending-on-auto-width.txt @@ -0,0 +1,22 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer <html> at (1,1) content-size 798x457.09375 children: not-inline + Box <body.hero> at (10,10) content-size 500x439.09375 flex-container(column) children: not-inline + BlockContainer <div.upper> at (10,11) content-size 500x437.09375 flex-item children: inline + line 0 width: 453.984375, height: 87.34375, bottom: 87.34375, baseline: 67.65625 + frag 0 from TextNode start: 0, length: 11, rect: [10,11 453.984375x87.34375] + "This entire" + line 1 width: 455, height: 87.6875, bottom: 175.03125, baseline: 67.65625 + frag 0 from TextNode start: 12, length: 11, rect: [10,98 455x87.34375] + "text should" + line 2 width: 230.78125, height: 88.03125, bottom: 262.71875, baseline: 67.65625 + frag 0 from TextNode start: 24, length: 5, rect: [10,185 230.78125x87.34375] + "be on" + line 3 width: 272.109375, height: 87.375, bottom: 349.40625, baseline: 67.65625 + frag 0 from TextNode start: 30, length: 6, rect: [10,273 272.109375x87.34375] + "orange" + line 4 width: 468.75, height: 87.71875, bottom: 437.09375, baseline: 67.65625 + frag 0 from TextNode start: 37, length: 11, rect: [10,360 468.75x87.34375] + "background." + TextNode <#text> + BlockContainer <(anonymous)> at (10,10) content-size 0x0 children: inline + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/flex-column-item-with-auto-height-depending-on-auto-width.html b/Tests/LibWeb/Layout/input/flex-column-item-with-auto-height-depending-on-auto-width.html new file mode 100644 index 0000000000..0c4e25aaee --- /dev/null +++ b/Tests/LibWeb/Layout/input/flex-column-item-with-auto-height-depending-on-auto-width.html @@ -0,0 +1,15 @@ +<!DOCTYPE html><html><head><style> +* { + border: 1px solid black; + font: 80px SerenitySans; +} +.hero { + display: flex; + flex-direction: column; + align-items: center; + width: 500px; +} +.upper { + background: orange; +} +</style></head><body class="hero"><div class="upper">This entire text should be on orange background.</div></div> |