stretch-alias-min-inline-size-001.tentative.html (8617B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#sizing-values"> 3 <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/check-layout-th.js"></script> 7 <!-- NOTE: This test is meant to be an near-exact copy of the neighboring test 8 file of nearly-the-same-name, with this version just adding "-alias" and 9 ".tentative" to the filename. The markup should be identical to the 10 original, aside from s/stretch/-webkit-fill-available/ in the CSS rule 11 ".test {...}". The expectation is that those keywords can be considered 12 to be aliases that give the exact same sizing behavior. --> 13 <meta name="assert" 14 content="min-inline-size:stretch (setting 'min-width' in this case) resolves and clamps as expected (producing similar results as if we had specified the keyword for the inline-size property)"> 15 <style> 16 .cb { 17 inline-size: 50px; 18 block-size: 40px; 19 20 /* This margin & border are purely cosmetic and don't impact the sizing 21 * calculations in this test: */ 22 margin: 5px; 23 border: 2px solid black; 24 25 /* This padding only comes into play for the subtests with absolutely 26 * positioned children (where our padding-box forms the containing block 27 * for the abspos child). */ 28 padding-inline: 5px; 29 padding-block: 3px; 30 31 /* We make each containing block an inline-level box, so we can display 32 * subtests in multiple rows, for easier visualization: */ 33 display: inline-block; 34 vertical-align: top; 35 } 36 37 .test { 38 /* We have 2+3 = 5px of margin in the inline axis. This means the stretched 39 * children should all have a border-box size that's 5px less than the 40 * containing block's content-box size, i.e. 50 - 5 = 45px. */ 41 margin-inline-start: 2px; 42 margin-inline-end: 3px; 43 44 /* We also have some border/padding that UAs will need to account for 45 * when computing the stretched children's content-box sizes; but these 46 * don't reduce our `data-expected-width` expectations, since those 47 * correspond to the border-box size. */ 48 border: 3px solid blue; 49 padding: 2px; 50 51 /* We expect "min-inline-size:stretch" to cause the used value of 52 * "inline-size" to be clamped to the resolved "stretch" size. */ 53 min-inline-size: -webkit-fill-available; 54 inline-size: 0; 55 block-size: 20px; 56 background: fuchsia; 57 } 58 </style> 59 <script> 60 function runTests() { 61 checkLayout('[data-expected-width]'); 62 63 // Add box-sizing:border-box (which shouldn't impact the actual resolved 64 // box sizes that 'stretch' produces), and retest: 65 for (let elem of document.querySelectorAll(".test")) { 66 elem.style.boxSizing = "border-box"; 67 } 68 checkLayout('[data-expected-width]'); 69 } 70 </script> 71 <body onload="runTests()"> 72 <!-- 'stretch' on a block box, replaced element, form controls, float: --> 73 <div class="cb"> 74 <div class="test" data-expected-width="45"></div> 75 </div> 76 <div class="cb"> 77 <canvas class="test" data-expected-width="45"></canvas> 78 </div> 79 <div class="cb"> 80 <input class="test" data-expected-width="45"> 81 </div> 82 <div class="cb"> 83 <textarea class="test" data-expected-width="45"></textarea> 84 </div> 85 <div class="cb"> 86 <button class="test" data-expected-width="45"></button> 87 </div> 88 <div class="cb"> 89 <div class="test" style="float: left" data-expected-width="45"></div> 90 </div> 91 92 <br> 93 94 <!-- 'stretch' on various abspos configurations, which use the container's 95 padding-box as the area-to-fill (which in this case is 10px larger than 96 the container's content-box, hence the larger 'data-expected-*' 97 values vs. the previous subtests). --> 98 <!-- With 0 insets, the child's margin-box fills the CB's padding-box, so 99 the child's border-box should end being 100 cb-padding-box-size - child-margin-size = 60px - 5px = 55px --> 101 <div class="cb" style="position: relative"> 102 <div class="test" style="position: absolute; inset-inline: 0;" 103 data-expected-width="55"></div> 104 </div> 105 106 <!-- With auto insets, the child is placed at its static position which is 107 the origin of the CB's content-box, and then 'stretch' makes it extend 108 to reach the far end of the CB's padding-box. So it should be as large 109 as the zero-insets case above, minus the CB's inline-start-padding 110 which is 5px. --> 111 <div class="cb" style="position: relative"> 112 <div class="test" style="position: absolute" data-expected-width="50"></div> 113 </div> 114 115 <!-- When we specify an inset, the child should be as large as the 116 zero-insets case above, minus whatever nonzero inset we choose. --> 117 <div class="cb" style="position: relative"> 118 <div class="test" style="position: absolute; inset-inline-start: 10px" 119 data-expected-width="45"></div> 120 </div> 121 <div class="cb" style="position: relative"> 122 <div class="test" style="position: absolute; inset-inline-end: 10px" 123 data-expected-width="45"></div> 124 </div> 125 126 <!-- If an inset pushes the child past the edge of the CB, 'stretch' shrinks 127 to just the 10px needed for the child's border/padding: --> 128 <div class="cb" style="position: relative"> 129 <div class="test" style="position: absolute; inset-inline-end: 55px" 130 data-expected-width="10"></div> 131 </div> 132 <div class="cb" style="position: relative"> 133 <div class="test" style="position: absolute; inset-inline-start: 55px" 134 data-expected-width="10"></div> 135 </div> 136 137 <br> 138 139 <!-- 'stretch' on various abspos configurations in a grid: similar to 140 above, but the grid area forms the containing block. --> 141 <!-- Similar to zero insets case above, but just now in a grid: --> 142 <div class="cb" 143 style="display: inline-grid; position: relative"> 144 <div class="test" 145 style="position: absolute; inset-inline: 0;" 146 data-expected-width="55"></div> 147 </div> 148 149 <!-- With no insets, we're placed at our static position which is the grid's 150 padding-box origin, and then we stretch to reach the far end of its 151 padding-box. So we should be as large as the zero-insets case above. --> 152 <div class="cb" 153 style="display: inline-grid; position: relative"> 154 <div class="test" 155 style="position: absolute" 156 data-expected-width="55"></div> 157 </div> 158 159 <!-- When we specify an inset, the child should be as large as the 160 zero-insets case above, minus whatever nonzero inset we choose. --> 161 <div class="cb" 162 style="display: inline-grid; position: relative"> 163 <div class="test" 164 style="position: absolute; inset-inline-start: 10px" 165 data-expected-width="45"></div> 166 </div> 167 <div class="cb" 168 style="display: inline-grid; position: relative"> 169 <div class="test" 170 style="position: absolute; inset-inline-end: 10px" 171 data-expected-width="45"></div> 172 </div> 173 174 <!-- If an inset pushes the child past the edge of the CB, 'stretch' shrinks 175 to just the 10px needed for the child's border/padding: --> 176 <div class="cb" 177 style="display: inline-grid; position: relative"> 178 <div class="test" 179 style="position: absolute; inset-inline-end: 55px" 180 data-expected-width="10"></div> 181 </div> 182 <div class="cb" 183 style="display: inline-grid; position: relative"> 184 <div class="test" 185 style="position: absolute; inset-inline-start: 55px" 186 data-expected-width="10"></div> 187 </div> 188 189 <br> 190 191 <!-- 'stretch' on a flex item: --> 192 <div class="cb" style="display: inline-flex; flex-direction: row"> 193 <div class="test" data-expected-width="45"></div> 194 </div> 195 <div class="cb" style="display: inline-flex; flex-direction: column"> 196 <div class="test" data-expected-width="45"></div> 197 </div> 198 <!--...now with an extra-large sibling sharing the child's flex line, to be 199 sure our 'stretch' sizing value resolves against the flex line's size: --> 200 <div class="cb" style="display: inline-flex; flex-flow: column wrap"> 201 <div class="test" data-expected-width="55"></div> 202 <div style="inline-size: 60px"></div> 203 </div> 204 205 <!-- 'stretch' on a grid item in a definite-size grid track: --> 206 <div class="cb" style="display: inline-grid; grid-template-columns: 35px"> 207 <div class="test" data-expected-width="30"></div> 208 </div> 209 210 <!-- 'stretch' on a grid item in an automatically-sized grid track: --> 211 <div class="cb" style="display: inline-grid"> 212 <div class="test" data-expected-width="45"></div> 213 </div> 214 </body>