OLD | NEW |
| (Empty) |
1 <!DOCTYPE> | |
2 <html> | |
3 <head> | |
4 <title>Creating composited layers for fixed position elements</title> | |
5 | |
6 <style type="text/css" media="screen"> | |
7 #tall { | |
8 height: 100px; | |
9 } | |
10 | |
11 #fixed { | |
12 width: 300px; | |
13 height: 100px; | |
14 position: fixed; | |
15 top: 30px; | |
16 right: 5px; | |
17 background-color: green; | |
18 } | |
19 </style> | |
20 <script type="text/javascript" charset="utf-8"> | |
21 if (window.internals) | |
22 window.internals.settings.setAcceleratedCompositingForFixedPositionEnabled
(true); | |
23 | |
24 function doTest() | |
25 { | |
26 var layerTreeOutput = ''; | |
27 | |
28 // If the fixed position element doesn't have its own stacking context the
n | |
29 // it cannot get a composited layer. | |
30 if (window.testRunner) | |
31 layerTreeOutput += 'Before (should be empty): \n' + window.internals.lay
erTreeAsText(document) + '\n'; | |
32 | |
33 // Adding a z-index to the fixed position element will give it a stacking
context | |
34 // and allow it to be composited. | |
35 document.getElementById('fixed').style.zIndex = '1'; | |
36 | |
37 if (window.testRunner) { | |
38 layerTreeOutput += 'After (should not be empty): \n' + window.internals.
layerTreeAsText(document); | |
39 document.getElementById('layertree').innerText = layerTreeOutput; | |
40 testRunner.dumpAsText(); | |
41 } | |
42 | |
43 // Adding a transform to the container will turn off compositing. | |
44 document.getElementById('container').style.webkitTransform = 'translateX(0
)'; | |
45 if (window.testRunner) { | |
46 layerTreeOutput += 'After (should be empty): \n' + window.internals.laye
rTreeAsText(document); | |
47 document.getElementById('layertree').innerText = layerTreeOutput; | |
48 testRunner.dumpAsText(); | |
49 } | |
50 | |
51 } | |
52 | |
53 window.addEventListener("load", doTest, false); | |
54 | |
55 </script> | |
56 </head> | |
57 | |
58 <!-- Fixed position elements may skip compositing without a scrollable | |
59 ancestor. To make sure this test covers the intended scenario, we force the | |
60 body element to be tall, so that the FrameView is scrolling. --> | |
61 <body style="height: 4000px;"> | |
62 <!-- Fixed position element should get its own layer --> | |
63 <pre id="layertree"></pre> | |
64 <div id="tall"></div> | |
65 <div id="container"> | |
66 <div id="fixed"></div> | |
67 </div> | |
68 </body> | |
69 </html> | |
OLD | NEW |