1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:17:45 +00:00

LibWeb: Clamp fit-content widths in flex layout to min/max-width

In situations where we need a width to calculate the intrinsic height of
a flex item, we use the fit-content width as a stand-in. However, we
also need to clamp it to any min-width and max-width properties present.
This commit is contained in:
Andreas Kling 2023-03-28 18:29:12 +02:00
parent 4c090a9a35
commit c0a7a61288
4 changed files with 58 additions and 4 deletions

View file

@ -0,0 +1,20 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x331.570312 children: not-inline
Box <body.hero> at (2,2) content-size 600x329.570312 flex-container(column) children: not-inline
BlockContainer <div.header> at (102,3) content-size 400x327.570312 flex-item children: inline
line 0 width: 340.488281, height: 65.507812, bottom: 65.507812, baseline: 50.742187
frag 0 from TextNode start: 0, length: 11, rect: [102,3 340.488281x65.507812]
"This entire"
line 1 width: 341.25, height: 66.015625, bottom: 131.523437, baseline: 50.742187
frag 0 from TextNode start: 12, length: 11, rect: [102,68 341.25x65.507812]
"text should"
line 2 width: 274.160156, height: 65.523437, bottom: 196.539062, baseline: 50.742187
frag 0 from TextNode start: 24, length: 8, rect: [102,134 274.160156x65.507812]
"be on an"
line 3 width: 204.082031, height: 66.03125, bottom: 262.554687, baseline: 50.742187
frag 0 from TextNode start: 33, length: 6, rect: [102,199 204.082031x65.507812]
"orange"
line 4 width: 351.5625, height: 65.539062, bottom: 327.570312, baseline: 50.742187
frag 0 from TextNode start: 40, length: 11, rect: [102,265 351.5625x65.507812]
"background."
TextNode <#text>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html><html><head><style>
* {
border: 1px solid black;
margin: 0;
padding: 0;
font: 60px SerenitySans;
}
html {
background: white;
}
.hero {
display: flex;
flex-direction: column;
align-items: center;
width: 600px;
background: pink;
}
.header {
max-width: 400px;
background: orange;
}
</style></head><body class="hero"><div class="header">This entire text should be on an orange background.</div></body></html>