OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>CSS 3D Test: Projected Blue Box over Black Background</title> | 4 <title>CSS 3D Test: Projected Blue Box over Black Background</title> |
5 <style type="text/css"> | 5 <style type="text/css"> |
6 .nomargin { | 6 .nomargin { |
7 margin: 0px auto; | 7 margin: 0px auto; |
8 } | 8 } |
9 | 9 |
10 #container { | 10 #container { |
11 -webkit-perspective: 500; | 11 -webkit-perspective: 500; |
12 } | 12 } |
13 | 13 |
14 #container > div { | 14 #container > div { |
15 position: relative; | 15 position: relative; |
16 margin: 50px; | 16 margin: 50px; |
17 width: 125px; | 17 width: 125px; |
18 height: 75px; | 18 height: 75px; |
19 } | 19 } |
20 | 20 |
21 #container > :first-child { | 21 #container > :first-child { |
22 background-color: blue; | 22 background-color: blue; |
23 -webkit-transform: rotateY(45deg); | 23 -webkit-transform: rotateY(45deg); |
24 } | 24 } |
25 </style> | 25 </style> |
26 <script> | 26 <script> |
27 var g_swapsBeforeAck = 15; | 27 var g_swapsBeforeAck = 15; |
28 var g_paintLoopStarted = false; | 28 var g_targetWidth, g_targetHeight; |
| 29 |
| 30 function onresized() |
| 31 { |
| 32 if (g_targetWidth != window.outerWidth || |
| 33 g_targetHeight != window.outerHeight) |
| 34 return; |
| 35 |
| 36 main(); |
| 37 } |
| 38 |
29 | 39 |
30 function main() | 40 function main() |
31 { | 41 { |
32 g_swapsBeforeAck = 15; | 42 waitForFinish(); |
33 if (!g_paintLoopStarted) { | |
34 g_paintLoopStarted = true; | |
35 waitForFinish(); | |
36 } | |
37 } | 43 } |
38 | 44 |
39 function waitForFinish() | 45 function waitForFinish() |
40 { | 46 { |
41 if (g_swapsBeforeAck == 0) { | 47 if (g_swapsBeforeAck == 0) { |
42 domAutomationController.setAutomationId(1); | 48 domAutomationController.setAutomationId(1); |
43 domAutomationController.send("resized"); | 49 domAutomationController.send("resized"); |
44 } else { | 50 } else { |
45 g_swapsBeforeAck--; | 51 g_swapsBeforeAck--; |
46 document.getElementById('blue_box').style.zIndex = g_swapsBeforeAck + 1; | 52 document.getElementById('blue_box').style.zIndex = g_swapsBeforeAck + 1; |
47 window.webkitRequestAnimationFrame(waitForFinish); | 53 window.webkitRequestAnimationFrame(waitForFinish); |
48 } | 54 } |
49 } | 55 } |
50 | 56 |
51 function notifyLoadFinished() | 57 function notifyLoadFinished() |
52 { | 58 { |
53 domAutomationController.setAutomationId(1); | 59 domAutomationController.setAutomationId(1); |
54 domAutomationController.send("ok"); | 60 domAutomationController.send("ok"); |
55 } | 61 } |
56 | 62 |
57 function preCallResizeInChromium() | 63 function preCallResizeInChromium(targetWidth, targetHeight) |
58 { | 64 { |
59 window.onresize = main; | 65 g_targetWidth = targetWidth; |
| 66 g_targetHeight = targetHeight; |
| 67 window.onresize = onresized; |
| 68 |
60 // Call main() on a timeout in case the window did not resize for whatever | 69 // Call main() on a timeout in case the window did not resize for whatever |
61 // reason. | 70 // reason. |
62 setTimeout(main, 10000); | 71 setTimeout(main, 10000); |
63 } | 72 } |
64 </script> | 73 </script> |
65 </head> | 74 </head> |
66 <body onload="notifyLoadFinished()"> | 75 <body onload="notifyLoadFinished()"> |
67 <div style="position:relative; width:200px; height:200px; background-color:black
; zindex-0"> | 76 <div style="position:relative; width:200px; height:200px; background-color:black
; zindex-0"> |
68 </div> | 77 </div> |
69 <div id="container" style="position:absolute; top:0px; left:0px"> | 78 <div id="container" style="position:absolute; top:0px; left:0px"> |
70 <div id="blue_box"></div> | 79 <div id="blue_box"></div> |
71 </div> | 80 </div> |
72 </body> | 81 </body> |
73 </html> | 82 </html> |
OLD | NEW |