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
|
<!DOCTYPE html>
<title>Keyword sizes on replaced element</title>
<link rel="author" title="Oriol Brufau" href="obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#sizing-values">
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#sizing-values">
<link rel="help" href="https://drafts.csswg.org/css2/#replaced-element">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11006">
<meta assert="The various keyword sizes work as expected on replaced elements.">
<style>
.wrapper {
display: inline-block;
vertical-align: top;
margin-right: 150px;
}
.test {
margin: 5px;
border: 3px solid;
padding: 2px;
width: auto;
height: auto;
}
/* Set the preferred size to small amount, to test that the min size works */
.test.min-width { width: 0px }
.test.min-height { height: 0px }
/* Set the preferred size to big amount, to test that the max size works */
.test.max-width { width: 500px }
.test.max-height { height: 500px }
/* stretch isn't widely supported, fall back to vendor-prefixed alternatives */
.width.stretch { width: -moz-available; width: -webkit-fill-available; width: stretch }
.min-width.stretch { min-width: -moz-available; min-width: -webkit-fill-available; min-width: stretch }
.max-width.stretch { max-width: -moz-available; max-width: -webkit-fill-available; max-width: stretch }
.height.stretch { height: -moz-available; height: -webkit-fill-available; height: stretch }
.min-height.stretch { min-height: -moz-available; min-height: -webkit-fill-available; min-height: stretch }
.max-height.stretch { max-height: -moz-available; max-height: -webkit-fill-available; max-height: stretch }
</style>
<div id="log"></div>
<!-- Intrinsic keywords -->
<div class="wrapper" style="width: 200px; height: 100px">
<canvas width="100" height="100" class="test width height" style="width: 50px; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: 50px; height: min-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: 50px; height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: 50px; height: max-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: min-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: min-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: min-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: min-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: fit-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: fit-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: fit-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: fit-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: max-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test width height" style="width: max-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: max-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test width height" style="width: max-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<br>
<canvas width="100" height="100" class="test min-width height" style="min-width: 50px; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: 50px; height: min-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: 50px; height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: 50px; height: max-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: min-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: min-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: min-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: min-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: fit-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: fit-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: fit-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: fit-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: max-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: max-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: max-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-width height" style="min-width: max-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<br>
<canvas width="100" height="100" class="test max-width height" style="max-width: 50px; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: 50px; height: min-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: 50px; height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: 50px; height: max-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: min-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: min-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: min-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: min-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: fit-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: fit-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: fit-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: fit-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: max-content; height: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: max-content; height: min-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: max-content; height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-width height" style="max-width: max-content; height: max-content"
data-expected-width="110" data-expected-height="110"></canvas>
</div>
<!-- Definite stretch -->
<div class="wrapper" style="width: 200px; height: 100px">
<canvas width="100" height="100" class="test width stretch"
data-expected-width="190" data-expected-height="190"></canvas>
<canvas width="100" height="100" class="test min-width stretch"
data-expected-width="190" data-expected-height="190"></canvas>
<canvas width="100" height="100" class="test max-width stretch"
data-expected-width="190" data-expected-height="190"></canvas>
<canvas width="100" height="100" class="test height stretch"
data-expected-width="90" data-expected-height="90"></canvas>
<canvas width="100" height="100" class="test min-height stretch"
data-expected-width="90" data-expected-height="90"></canvas>
<canvas width="100" height="100" class="test max-height stretch"
data-expected-width="90" data-expected-height="90"></canvas>
</div>
<!-- Stretch sizes can't result in a negative content size -->
<div class="wrapper" style="width: 0px; height: 0px">
<canvas width="100" height="100" class="test width min-width max-width stretch"
data-expected-width="10" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test height min-height max-height stretch"
data-expected-width="10" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test width min-width max-width height min-height max-height stretch"
data-expected-width="10" data-expected-height="10"></canvas>
</div>
<!-- Indefinite stretch -->
<div class="wrapper" style="width: 200px; max-height: 100px">
<canvas width="100" height="100" class="test height stretch"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-height stretch"
data-expected-width="10" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test max-height stretch"
data-expected-width="510" data-expected-height="510"></canvas>
<canvas width="100" height="100" class="test height stretch" style="max-width: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-height stretch" style="min-width: 50px"
data-expected-width="60" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test max-height stretch" style="max-width: 50px"
data-expected-width="60" data-expected-height="510"></canvas>
<canvas width="100" height="100" class="test height stretch" style="min-width: 150px"
data-expected-width="160" data-expected-height="160"></canvas>
<canvas width="100" height="100" class="test min-height stretch" style="min-width: 150px"
data-expected-width="160" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test max-height stretch" style="max-width: 150px"
data-expected-width="160" data-expected-height="510"></canvas>
</div>
<!-- Fit-content with indefinite stretch -->
<div class="wrapper" style="width: 200px; max-height: 100px">
<canvas width="100" height="100" class="test height" style="height: fit-content"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-height" style="min-height: fit-content"
data-expected-width="10" data-expected-height="10"></canvas>
<canvas width="100" height="100" class="test max-height" style="max-height: fit-content"
data-expected-width="510" data-expected-height="510"></canvas>
<canvas width="100" height="100" class="test height" style="max-width: 50px; height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-height" style="min-width: 50px; min-height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test max-height" style="max-width: 50px; max-height: fit-content"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test height" style="min-width: 150px; height: fit-content"
data-expected-width="160" data-expected-height="160"></canvas>
<canvas width="100" height="100" class="test min-height" style="min-width: 150px; min-height: fit-content"
data-expected-width="160" data-expected-height="160"></canvas>
<canvas width="100" height="100" class="test max-height" style="max-width: 150px; max-height: fit-content"
data-expected-width="160" data-expected-height="160"></canvas>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script>
checkLayout(".test");
</script>
|