mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibWeb: Support max-content
for width
, min-width
and max-width
We're gonna need to handle this in many more places, this patch only adds it to calculate_inner_width().
This commit is contained in:
parent
358d94b57a
commit
97c510329c
4 changed files with 53 additions and 1 deletions
|
@ -0,0 +1,24 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (1,1) content-size 798x76.40625 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (10,10) content-size 780x58.40625 children: not-inline
|
||||||
|
BlockContainer <div.foo> at (11,11) content-size 150.21875x17.46875 children: inline
|
||||||
|
line 0 width: 150.21875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||||
|
frag 0 from TextNode start: 0, length: 18, rect: [11,11 150.21875x17.46875]
|
||||||
|
"width: max-content"
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <(anonymous)> at (10,29.46875) content-size 780x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <div.bar> at (11,30.46875) content-size 187.953125x17.46875 children: inline
|
||||||
|
line 0 width: 187.953125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||||
|
frag 0 from TextNode start: 0, length: 22, rect: [11,30.46875 187.953125x17.46875]
|
||||||
|
"max-width: max-content"
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <(anonymous)> at (10,48.9375) content-size 780x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <div.baz> at (11,49.9375) content-size 183.078125x17.46875 children: inline
|
||||||
|
line 0 width: 183.078125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||||
|
frag 0 from TextNode start: 0, length: 22, rect: [11,49.9375 183.078125x17.46875]
|
||||||
|
"min-width: max-content"
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <(anonymous)> at (10,68.40625) content-size 780x0 children: inline
|
||||||
|
TextNode <#text>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<!doctype html><style>
|
||||||
|
* {
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
.foo {
|
||||||
|
background: pink;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
.bar {
|
||||||
|
background: orange;
|
||||||
|
width: 50%;
|
||||||
|
max-width: max-content;
|
||||||
|
}
|
||||||
|
.baz {
|
||||||
|
background: magenta;
|
||||||
|
width: 1%;
|
||||||
|
min-width: max-content;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="foo">width: max-content</div>
|
||||||
|
<div class="bar">max-width: max-content</div>
|
||||||
|
<div class="baz">min-width: max-content</div>
|
|
@ -1338,6 +1338,7 @@
|
||||||
],
|
],
|
||||||
"valid-identifiers": [
|
"valid-identifiers": [
|
||||||
"fit-content",
|
"fit-content",
|
||||||
|
"max-content",
|
||||||
"none"
|
"none"
|
||||||
],
|
],
|
||||||
"quirks": [
|
"quirks": [
|
||||||
|
@ -1374,6 +1375,7 @@
|
||||||
"valid-identifiers": [
|
"valid-identifiers": [
|
||||||
"auto",
|
"auto",
|
||||||
"fit-content",
|
"fit-content",
|
||||||
|
"max-content",
|
||||||
"none"
|
"none"
|
||||||
],
|
],
|
||||||
"quirks": [
|
"quirks": [
|
||||||
|
@ -1773,7 +1775,8 @@
|
||||||
],
|
],
|
||||||
"valid-identifiers": [
|
"valid-identifiers": [
|
||||||
"auto",
|
"auto",
|
||||||
"fit-content"
|
"fit-content",
|
||||||
|
"max-content"
|
||||||
],
|
],
|
||||||
"quirks": [
|
"quirks": [
|
||||||
"unitless-length"
|
"unitless-length"
|
||||||
|
|
|
@ -1349,6 +1349,9 @@ CSS::Length FormattingContext::calculate_inner_width(Layout::Box const& box, Ava
|
||||||
if (width.is_fit_content()) {
|
if (width.is_fit_content()) {
|
||||||
return CSS::Length::make_px(calculate_fit_content_width(box, AvailableSpace { available_width, AvailableSize::make_indefinite() }));
|
return CSS::Length::make_px(calculate_fit_content_width(box, AvailableSpace { available_width, AvailableSize::make_indefinite() }));
|
||||||
}
|
}
|
||||||
|
if (width.is_max_content()) {
|
||||||
|
return CSS::Length::make_px(calculate_max_content_width(box));
|
||||||
|
}
|
||||||
|
|
||||||
auto& computed_values = box.computed_values();
|
auto& computed_values = box.computed_values();
|
||||||
if (computed_values.box_sizing() == CSS::BoxSizing::BorderBox) {
|
if (computed_values.box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue