2 function createElement(tag, parent, className, id) {
3 var el = document.createElement(tag);
4 el.className = className;
7 parent.appendChild(el);
11 function createSet(width, height, nested) {
12 var container = createElement("div", document.body, "container");
13 for (var y = 0; y < height; ++y) {
14 for (var x = 0; x < width; ++x)
15 createElement("div", container, "float", "float" + x + "_" + y);
17 var nestedContainer = container;
18 for ( ; nested > 0; --nested)
19 nestedContainer = createElement("div", nestedContainer, "nested", "nested" + x + "_" + nested);
21 createElement("div", container, "float-end", "end" + x)
26 function toggle(str, str1, str2) {
27 return str == str1 ? str2 : str1;
30 function resetTest() {
31 PerfTestRunner.resetRandomSeed();
32 var list = document.querySelectorAll(".float.big");
33 for (var i = 0; i < list.length; ++i)
34 list[i].className = "float";
37 function createTestFunction(width, height, nested, runs, rows) {
39 for (var i = 0; i < rows; ++i)
40 containers[i] = createSet(width, height, nested);
44 for (var c = 0; c < rows; ++c) {
45 container = containers[c];
46 container.style.display = "block";
47 for (var i = 0; i < runs; ++i) {
48 var x = Math.floor(Math.random() * width);
49 var y = Math.floor(Math.random() * height);
50 var el = document.getElementById("float" + x + "_" + y);
51 el.className = toggle(el.className, "float", "float big");
53 container.clientHeight;
56 container.style.display = "none";
61 window.createFloatsLayoutTestFunction = createTestFunction;