1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
<!DOCTYPE html>
<link rel="author" title="David Grogan" href="mailto:dgrogan@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#intrinsic-sizes">
<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;
}
#bug423112 .container {
border: 1px solid lightgrey;
margin: 20px;
padding: 8px;
display: flex;
flex-flow: column;
}
#bug423112 .h-box {
display: flex;
flex-flow: row;
flex: none;
justify-content: flex-start;
align-items: stretch;
}
#bug423112 .auto {
flex: 0 0 auto;
}
#bug423112 .none {
flex: none;
}
#bug423112 .gap1-fails {
flex: 0 0 5px;
}
#bug423112 .gap2-fails {
flex: 0 0 30px;
}
#bug423112 .word {
display: inline-block;
height: 10px;
width: 35px;
background: orange;
}
#bug464210 .FlexOuterContainer {
border: 3px solid black;
display: flex;
margin: 1em;
}
#bug464210 .FlexInnerContainer {
border: 3px solid red;
display: flex;
flex: 0 0 auto;
}
#bug464210 .FlexItem {
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;
}
#bug441768 div {
display: flex;
}
#bug1144312 .grid-y {
flex-direction: column;
flex-wrap: wrap;
}
#bug1144312 .grid-x {
flex-direction: row
}
#bug1144312 .grid-x>* {
flex-basis: 0
}
#bug1144312 [class*=grid] {
display: flex;
gap: 1px
}
#bug1144312 .grid-y {
background: lightblue
}
#bug1144312 .grid-y:not(:first-child) {
margin-top: 1.5rem
}
#bug1144312 [class*=grid]>* {
flex-grow: 1;
border: 3px solid blue;
padding: 1px;
}
#bug1144312 .nowrap div {
border-color: purple
}
#bug1144312 .nowrap {
background: Thistle;
flex-wrap: nowrap;
}
#bug1144312 div {
font: 12px/1 Ahem;
}
</style>
<section id="bug423112" class="bugreport">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=423112</p>
<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>
<section id="bug464210" class="bugreport">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=464210</p>
<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">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=533627#c3</p>
<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>
<section id="bug441768" class="bugreport">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=441768 author wants
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>
<section id="bug1144312" class="bugreport">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=1144312</p>
<!-- 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>
<section id="bug1154243" class="bugreport">
<p>https://bugs.chromium.org/p/chromium/issues/detail?id=1154243</p>
<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>
|