forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfieldset-container-width-changes.html
88 lines (75 loc) · 1.98 KB
/
fieldset-container-width-changes.html
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
<!doctype HTML>
<!--
This test creates a fieldset with 10,000 non-trivial items. It locks the
container and adjusts its width continuously. If content-visibility is properly
optimized, then the width adjustments are very quick (< one frame). Otherwise,
the layout recalculation leaks into the children element and the width
adjustments are slow.
-->
<style>
#container {
content-visibility: hidden;
width: 500px;
height: 500px;
border: 1px solid black;
background: lightblue;
overflow: auto;
}
.item {
display: inline-block;
overflow: auto;
background: blue;
margin: 1px;
width: 10%;
height: 10%;
}
</style>
<template id="item_template">
<div class="item">
<div style="position: relative; width: 90%;">
relpos
<div style="position: absolute; top: 1px; left: 1%">
abspos
</div>
</div>
<div style="position: absolute; top: 150px; left: 1%">
abspos
</div>
lorem ipsum dolor sit amet
</div>
</template>
<fieldset id=container><legend>legend</legend></fieldset>
<script src="../resources/runner.js"></script>
<script>
function construct(n) {
const specimen = document.importNode(document.getElementById("item_template").content, true).firstElementChild;
const container = document.getElementById("container");
for (let i = 0; i < n; ++i) {
const clone = specimen.cloneNode(true);
container.appendChild(clone);
}
}
construct(10000);
let widths = ["400px", "500px"];
let width_index = 0;
function changeStyle() {
document.getElementById("container").style.width = widths[width_index];
width_index = 1 - width_index;
}
let testDone = false;
let startTime;
function runTest() {
if (startTime)
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
if (testDone)
return;
startTime = PerfTestRunner.now();
changeStyle();
requestAnimationFrame(runTest);
}
PerfTestRunner.prepareToMeasureValuesAsync({
unit: 'ms',
done: () => { testDone = true; container.innerHTML = "";}
});
requestAnimationFrame(runTest);
</script>