Skip to content

Commit

Permalink
Take into account the intrinsic block size when computing the main si…
Browse files Browse the repository at this point in the history
…ze of a column flex container

In particular, `main_content_sizes()` now works with columns.

`layout_for_block_content_size()` is now used for both intrinsic sizes
and intrinsic contributions, a IntrinsicSizingMode parameter is added
to choose the behavior.

Also, we consider the main size of a flex item as indefinite if its flex
basis is indefinite and the flex container has an indefinite main size.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
  • Loading branch information
2 people authored and servo-wpt-sync committed Aug 20, 2024
1 parent f9d5548 commit 6185316
Showing 1 changed file with 91 additions and 6 deletions.
97 changes: 91 additions & 6 deletions css/css-flexbox/flex-one-sets-flex-basis-to-zero-px.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<title>CSS Flexbox: flex-basis with zero pixel</title>
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#flex-basis-property">
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#intrinsic-main-sizes">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link href="support/flexbox.css" rel="stylesheet">
<meta name="assert" content="This test ensures that setting 'flex-basis' property to
Expand All @@ -10,18 +11,40 @@
<style>
.flexbox > div {
font: 14px/1 Ahem;
min-width: 0;
min-height: 0;
}

.flex-zero {
flex: 0;
}

.flex-zero-one-zero-percent {
flex: 0 1 0%;
}

.flex-zero-one-zero-px {
flex: 0 1 0px;
}

.flex-half {
flex: 0.5;
}

.flex-half-one-zero-percent {
flex: 0.5 1 0%;
}

.flex-half-one-zero-px {
flex: 0.5 1 0px;
}

.flex-one-one-zero-percent {
flex: 1 1 0%;
min-width: 0;
min-height: 0;
}

.flex-one-one-zero-px {
flex: 1 1 0px;
min-width: 0;
min-height: 0;
}

.vertical {
Expand All @@ -33,6 +56,35 @@
<script src="/resources/check-layout-th.js"></script>
<body onload="document.fonts.ready.then(() => { checkLayout('.flexbox'); })">
<div id=log></div>
<div class="flexbox column">
<div class="flex-zero" data-expected-height="14">Flex item with flex: 0</div>
</div>

<div class="flexbox column">
<div class="flex-zero-one-zero-percent" data-expected-height="14">Flex item with flex: 0 1 0%</div>
</div>

<div class="flexbox column">
<div class="flex-zero-one-zero-px" data-expected-height="0">Flex item with flex: 0 1 0px</div>
</div>

<div class="flexbox column">
<div class="flex-half" data-expected-height="14">Flex item with flex: 0.5</div>
</div>

<div class="flexbox column">
<div class="flex-half-one-zero-percent" data-expected-height="14">Flex item with flex: 0.5 1 0%</div>
</div>

<!-- A flex-grow of 0 would size the container to the flex base size of the item (0px),
and a flex-grow of 1 would size it to the max-content contribution of the item (14px).
Therefore, a flew-grow of 0.5 sizes the container to the average, 7px.
And then the item grows to fill half of that, 3.5px.
Note that Gecko, Blink and WebKit use the flex-basis instead. -->
<div class="flexbox column">
<div class="flex-half-one-zero-px" data-expected-height="4">Flex item with flex: 0.5 1 0px</div>
</div>

<div class="flexbox column">
<div class="flex-one" data-expected-height="14">Flex item with flex: 1</div>
</div>
Expand All @@ -41,8 +93,39 @@
<div class="flex-one-one-zero-percent" data-expected-height="14">Flex item with flex: 1 1 0%</div>
</div>

<!-- flex-grow is >= 1, so the flex container is sized to the max-content contribution of the item.
Note that Gecko, Blink and WebKit use the flex-basis instead. -->
<div class="flexbox column">
<div class="flex-one-one-zero-px" data-expected-height="0">Flex item with flex: 1 1 0px</div>
<div class="flex-one-one-zero-px" data-expected-height="14">Flex item with flex: 1 1 0px</div>
</div>

<div class="flexbox column vertical">
<div class="flex-zero" data-expected-width="14">Flex item with flex: 0</div>
</div>

<div class="flexbox column vertical">
<div class="flex-zero-one-zero-percent" data-expected-width="14">Flex item with flex: 0 1 0%</div>
</div>

<div class="flexbox column vertical">
<div class="flex-zero-one-zero-px" data-expected-width="0">Flex item with flex: 0 1 0px</div>
</div>

<div class="flexbox column vertical">
<div class="flex-half" data-expected-width="14">Flex item with flex: 0.5</div>
</div>

<div class="flexbox column vertical">
<div class="flex-half-one-zero-percent" data-expected-width="14">Flex item with flex: 0.5 1 0%</div>
</div>

<!-- A flex-grow of 0 would size the container to the flex base size of the item (0px),
and a flex-grow of 1 would size it to the max-content contribution of the item (14px).
Therefore, a flew-grow of 0.5 sizes the container to the average, 7px.
And then the item grows to fill half of that, 3.5px.
Note that Gecko, Blink and WebKit use the flex-basis instead. -->
<div class="flexbox column vertical">
<div class="flex-half-one-zero-px" data-expected-width="4">Flex item with flex: 0.5 1 0px</div>
</div>

<div class="flexbox column vertical">
Expand All @@ -53,8 +136,10 @@
<div class="flex-one-one-zero-percent" data-expected-width="14">Flex item with flex: 1 1 0%</div>
</div>

<!-- flex-grow is >= 1, so the flex container is sized to the max-content contribution of the item.
Note that Gecko, Blink and WebKit use the flex-basis instead. -->
<div class="flexbox column vertical">
<div class="flex-one-one-zero-px" data-expected-width="0">Flex item with flex: 1 1 0px</div>
<div class="flex-one-one-zero-px" data-expected-width="14">Flex item with flex: 1 1 0px</div>
</div>
</body>
</html>

2 comments on commit 6185316

@davidsgrogan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Loirooriol @mrobinson What do y'all want to do about this test? Do you want to change the expectations to what webkit/blink/gecko do? Or want to leave it following the current spec that we know to be unshippable but don't have a replacement for? Up to you, but if you want to leave it as-is, we should remove it from interop2024 "scoring".

@Loirooriol
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should change it back, pointing to w3c/csswg-drafts#8884 (comment) to explain the divergence from the spec.

Please sign in to comment.