Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 6 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-flexbox/intrinsic-size/row-use-cases-001.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel="author" title="David Grogan" href="mailto:dgrogan@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<meta name="assert"
content="Requested use cases from our issue tracker that were duplicated or included in the bug report for the new algorithm. These are intentionally not very reduced from their original form with liberal pass conditions." />
<style>
section.bugreport {
outline: 1px solid grey;
margin-bottom: 25px;
padding: 3px;
}
border: 1px solid lightgrey;
margin: 20px;
padding: 8px;
display: flex;
flex-flow: column;
}
display: flex;
flex-flow: row;
flex: none;
justify-content: flex-start;
align-items: stretch;
}
flex: 0 0 auto;
}
flex: none;
}
flex: 0 0 5px;
}
flex: 0 0 30px;
}
display: inline-block;
height: 10px;
width: 35px;
background: orange;
}
border: 3px solid black;
display: flex;
margin: 1em;
}
border: 3px solid red;
display: flex;
flex: 0 0 auto;
}
background: rgba(0, 0, 0, .2);
flex: 0 0 100px;
}
#bug533627c3 .outer {
display: flex;
padding: 10px;
}
#bug533627c3 .middle,
#bug533627c3 .middle2 {
display: flex;
flex-shrink: 0;
background: red;
padding: 10px;
}
#bug533627c3 .inner {
flex-basis: 258px;
flex-shrink: 0;
display: flex;
flex-grow: 0;
background: green;
}
#bug533627c3 .inner2 {
width: 258px;
flex-shrink: 0;
display: flex;
flex-grow: 0;
background: green;
}
display: flex;
}
flex-direction: column;
flex-wrap: wrap;
}
flex-direction: row
}
flex-basis: 0
}
display: flex;
gap: 1px
}
background: lightblue
}
margin-top: 1.5rem
}
flex-grow: 1;
border: 3px solid blue;
padding: 1px;
}
border-color: purple
}
background: Thistle;
flex-wrap: nowrap;
}
font: 12px/1 Ahem;
}
</style>
<div class="container">
<div class="h-box">
<div class="h-box">
<input type="checkbox" class="none">
<div class="gap2-fails"></div>
<span class="none" id="left-item">
first checkbox example
</span>
</div>
<div class="h-box">
<input type="checkbox" class="none" id="right-item">
<div class="gap2-fails"></div>
<span class="auto">
second checkbox example
</span>
</div>
</div>
</div>
</section>
<div class="FlexOuterContainer">
<div class="FlexInnerContainer">
<div class="FlexItem">MMMMM</div>
<div id="right-item" class="FlexItem">MMMMM</div>
</div>
</div>
</section>
<section id="bug533627c3" class="bugreport">
<div class="outer">
<div class="middle">
<div class="inner">
hello
</div>
</div>
</div>
<div class="outer">
<div class="middle2">
<div class="inner2">
hello
</div>
</div>
</div>
</section>
below blue block to have 0 width</p>
<div>
<!-- shipping: .middle has flex-basis=200px (from its max-content), and
used min-width=200px (from min-content) -->
<!-- author wants .middle flex-basis = 0, so author wants .middle
max-content = 0 -->
<!-- that means author also needs min-content = 0 -->
<!-- so width:200 item needs to contribute flex-basis to both min and max
-->
<div style="height: 100px; background: blue; align-self: flex-start;"
class="middle">
<div style="width: 200px; flex: 0;"></div>
</div>
</div>
</section>
<!-- This case needs max-content to use flex fractions. -->
<div class="grid-y" id="top">
<!-- broke: grid-x intrinsic sizes are ("95", "154") -->
<!-- works: grid-x intrinsic sizes are ("165", "283") -->
<!-- broke: grid-x main inner size = 146-->
<!-- works: grid-x main inner size = 275-->
<!-- to determine its vertical flex basis, grid-x lays out with width set to max content*. Then, both of its items have flex basis 0 and same grow factor, so they get flexed to each have approximately half of first item's max-width. This makes "phantom whitespace" wrap, which makes it too tall.
* this doesn't happen in the nowrap case, which stretches grid-x's width. -->
<div class="grid-x">
<!-- while laying out grid-x to get its flex-basis:
when laying out the two items for cross sizes:
broke: 1st gets 78px fixed inline size, returns height 48px
works: 1st gets 137px fixed inline size, returns height 28px
broke: 2nd gets 67px fixed inline size, returns height 8px
works: 2nd gets 137px fixed inline size, returns height 8px
-->
<div>phantom whitespace</div>
<div></div>
</div>
</div>
<div class="grid-y" id="middle">
<div>
<div class="grid-x">
<div>also phantom whitespace</div>
<div></div>
</div>
</div>
</div>
<div class="grid-y nowrap" id="bottom">
<div class="grid-x">
<div>no more phantom whitespace</div>
<div></div>
</div>
</div>
</section>
<div
style="display: flex; width: min-content; border: 2px solid blue; font: 12px/1 Ahem;"
id="container">
<!-- shipping: min-content width of container is sum of min-contents (2x
the width of the word "content")
author needs: each `flex: 0 0 auto` item contributes flex-basis to
container min-content because they can't shrink from their flex bases
-->
<div style="flex-shrink: 0">Test content</div>
<div style="background: yellow; flex-shrink: 0" id="right">Test content
</div>
</div>
</section>
<script>
test(_ => {
let left = bug423112.querySelector("#left-item");
let right = bug423112.querySelector("#right-item");
assert_less_than_equal(left.getBoundingClientRect().right, right.getBoundingClientRect().left);
}, "left < right");
test(_ => {
const container = bug464210.querySelector(".FlexInnerContainer");
const right = bug464210.querySelector("#right-item");
assert_less_than_equal(right.getBoundingClientRect().right, container.getBoundingClientRect().right);
}, "no overflow");
test(_ => {
const middle = bug533627c3.querySelector(".middle");
const middle2 = bug533627c3.querySelector(".middle2");
assert_equals(middle.offsetWidth, middle2.offsetWidth);
}, "same widths");
test(_ => {
const middle = bug441768.querySelector(".middle");
assert_equals(middle.offsetWidth, 0);
}, "zero width");
test(_ => {
const top = bug1144312.querySelector("#top");
const middle = bug1144312.querySelector("#middle");
const bottom = bug1144312.querySelector("#bottom");
assert_equals(top.offsetHeight, bottom.offsetHeight);
assert_equals(middle.offsetHeight, bottom.offsetHeight);
}, "same heights");
test(_ => {
const container = bug1154243.querySelector("#container");
const right = bug1154243.querySelector("#right");
assert_less_than_equal(right.getBoundingClientRect().right, container.getBoundingClientRect().right)
}, "no overflow 2");
</script>