OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script type="text/javascript" src="../resources/runner.js"></script> | 4 <script type="text/javascript" src="../resources/runner.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <div id="root"></div> | 7 <div id="root"><div id="child1"></div><div id="child2"></div></div> |
8 <script> | 8 <script> |
9 function createTreeOfTrees(root, depth, branch, eachTreeHeight) | 9 function createTreeOfTrees(root, depth, eachTreeHeight) |
10 { | 10 { |
11 var node = root; | 11 var node = root; |
12 var i; | 12 var i; |
13 for (i = 0; i < eachTreeHeight; ++i) { | 13 for (i = 0; i < eachTreeHeight; ++i) { |
14 var child = document.createElement('div'); | 14 var child = document.createElement('div'); |
15 node.appendChild(child); | 15 node.appendChild(child); |
16 node = child; | 16 node = child; |
17 } | 17 } |
18 if (depth == 1) | 18 if (depth == 1) |
19 return; | 19 return; |
20 for (i = 0; i < branch; ++i) { | 20 var child = document.createElement('div'); |
21 var child = document.createElement('div'); | 21 node.appendChild(child); |
22 node.appendChild(child); | 22 var shadowRoot = child.webkitCreateShadowRoot(); |
23 var shadowRoot = child.webkitCreateShadowRoot(); | 23 createTreeOfTrees(shadowRoot, depth - 1, eachTreeHeight); |
24 createTreeOfTrees(shadowRoot, depth - 1, branch, eachTreeHeight); | |
25 } | |
26 } | 24 } |
27 | 25 |
28 function leftMostLeaf(root) | 26 function leftMostLeaf(root) |
29 { | 27 { |
30 var node = root; | 28 var node = root; |
31 while (node.firstChild) | 29 while (node.firstChild) |
32 node = node.firstChild | 30 node = node.firstChild |
33 if (!node.shadowRoot) | 31 if (!node.shadowRoot) |
34 return node; | 32 return node; |
35 return leftMostLeaf(node.shadowRoot) | 33 return leftMostLeaf(node.shadowRoot) |
36 } | 34 } |
37 | 35 |
38 function rightMostLeaf(root) | 36 function rightMostLeaf(root) |
39 { | 37 { |
40 var node = root; | 38 var node = root; |
41 while (node.lastChild) | 39 while (node.lastChild) |
42 node = node.lastChild | 40 node = node.lastChild |
43 if (!node.shadowRoot) | 41 if (!node.shadowRoot) |
44 return node; | 42 return node; |
45 return rightMostLeaf(node.shadowRoot) | 43 return rightMostLeaf(node.shadowRoot) |
46 } | 44 } |
47 | 45 |
48 var root = document.getElementById('root'); | 46 var root = document.getElementById('root'); |
49 createTreeOfTrees(root, 10, 2, 50); | 47 createTreeOfTrees(document.getElementById('child1'), 200, 50); |
| 48 createTreeOfTrees(document.getElementById('child2'), 200, 50); |
50 var leaf1 = leftMostLeaf(root); | 49 var leaf1 = leftMostLeaf(root); |
51 var leaf2 = rightMostLeaf(root); | 50 var leaf2 = rightMostLeaf(root); |
52 | 51 |
53 function run() | 52 function run() |
54 { | 53 { |
55 leaf1.dispatchEvent(new MouseEvent('mousemove', { | 54 leaf1.dispatchEvent(new MouseEvent('mousemove', { |
56 relatedTarget: leaf2 | 55 relatedTarget: leaf2 |
57 })); | 56 })); |
58 } | 57 } |
59 | 58 |
60 PerfTestRunner.measureRunsPerSecond({ | 59 PerfTestRunner.measureRunsPerSecond({ |
61 description: "Measure mousemove events dispatching in shadow trees", | 60 description: "Measure mousemove events dispatching in shadow trees", |
62 run: run | 61 run: run |
63 }); | 62 }); |
64 </script> | 63 </script> |
65 </body> | 64 </body> |
66 </html> | 65 </html> |
OLD | NEW |