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
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>Last remembered size</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#last-remembered">
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override">
<link rel="help" href="https://drafts.csswg.org/css-contain-2/#content-visibility">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7529">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7516">
<meta name="assert" content="Tests that the last remembered size is tracked independently for each axis." />
<style>
#target {
width: max-content;
height: max-content;
border: 1px solid;
}
#target::before {
content: "";
display: block;
}
.content-100-50::before {
width: 100px;
height: 50px;
}
.content-skip {
content-visibility: hidden;
}
.ciw-auto-2 {
contain-intrinsic-width: auto 2px;
}
.ciw-auto-20 {
contain-intrinsic-width: auto 20px;
}
.cih-auto-1 {
contain-intrinsic-height: auto 1px;
}
.cih-auto-10 {
contain-intrinsic-height: auto 10px;
}
</style>
<div id="log"></div>
<div id="target"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const target = document.getElementById("target");
function checkSize(expectedWidth, expectedHeight, msg) {
assert_equals(target.clientWidth, expectedWidth, msg + " - clientWidth");
assert_equals(target.clientHeight, expectedHeight, msg + " - clientHeight");
}
function nextRendering() {
return new Promise(resolve => {
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
});
}
promise_test(async function() {
target.className = "content-100-50 ciw-auto-20";
checkSize(100, 50, "Sizing normally");
await nextRendering();
target.className = "content-skip ciw-auto-2 cih-auto-1";
checkSize(100, 1, "Using last remembered inline size");
}, "Only recording last remembered inline size");
promise_test(async function() {
target.className = "content-100-50 cih-auto-10";
checkSize(100, 50, "Sizing normally");
await nextRendering();
target.className = "content-skip ciw-auto-2 cih-auto-1";
checkSize(2, 50, "Using last remembered block size");
}, "Only recording last remembered block size");
</script>
|