Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 12 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-sizing/keyword-sizes-on-replaced-element.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Keyword sizes on replaced element</title>
<link rel="author" title="Oriol Brufau" href="obrufau@igalia.com">
<meta assert="The various keyword sizes work as expected on replaced elements.">
<style>
.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 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 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 style="width: 200px; max-height: 100px">
<canvas width="100" height="100" class="test height stretch indefinite"
data-expected-width="110" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test min-height stretch indefinite"
data-expected-width="10" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-height stretch indefinite"
data-expected-width="510" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test height stretch indefinite" style="max-width: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test min-height stretch indefinite" style="min-width: 50px"
data-expected-width="60" data-expected-height="110"></canvas>
<canvas width="100" height="100" class="test max-height stretch indefinite" style="max-width: 50px"
data-expected-width="60" data-expected-height="60"></canvas>
<canvas width="100" height="100" class="test height stretch indefinite" style="min-width: 150px"
data-expected-width="160" data-expected-height="160"></canvas>
<canvas width="100" height="100" class="test min-height stretch indefinite" style="min-width: 150px"
data-expected-width="160" data-expected-height="160"></canvas>
<canvas width="100" height="100" class="test max-height stretch indefinite" style="max-width: 150px"
data-expected-width="160" data-expected-height="110"></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>