Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <style> | |
| 5 #container { | |
| 6 width: 200px; | |
| 7 height: 200px; | |
| 8 overflow: scroll; | |
| 9 margin: 20px; | |
| 10 border: 1px solid black; | |
| 11 } | |
| 12 | |
| 13 #abs-pos-ancestor { | |
| 14 width: 500px; | |
| 15 height: 500px; | |
| 16 position: absolute; | |
| 17 z-index: 0; | |
| 18 } | |
| 19 | |
| 20 #positioned-ancestor { | |
| 21 width: 150px; | |
| 22 height: 300px; | |
| 23 position: relative; | |
| 24 } | |
| 25 | |
| 26 #descendant { | |
| 27 left: 10px; | |
| 28 top: 10px; | |
| 29 width: 50px; | |
| 30 height: 50px; | |
| 31 background-color: blue; | |
| 32 position: absolute; | |
| 33 z-index: -20; | |
| 34 } | |
| 35 </style> | |
| 36 <script> | |
| 37 var debugMode = false; | |
| 38 | |
| 39 if (window.testRunner) | |
| 40 testRunner.dumpAsText(); | |
| 41 | |
| 42 if (window.internals) | |
| 43 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(true); | |
| 44 | |
| 45 function write(str) | |
| 46 { | |
| 47 var pre = document.getElementById('console'); | |
| 48 var text = document.createTextNode(str + '\n'); | |
| 49 pre.appendChild(text); | |
| 50 } | |
| 51 | |
| 52 var iteration = 0; | |
| 53 function printResult(expectedResult) | |
| 54 { | |
| 55 // Force a style recalc. | |
| 56 document.body.offsetTop; | |
| 57 | |
| 58 if (window.internals) { | |
| 59 var layerTree = window.internals.layerTreeAsText(document); | |
| 60 | |
| 61 if (!layerTree == !expectedResult) | |
| 62 write('Iteration ' + iteration.toString() + ': Passed') | |
| 63 else | |
| 64 write('Iteration ' + iteration.toString() + ': FAILED') | |
| 65 | |
| 66 if (layerTree) { | |
| 67 write('Iteration ' + iteration.toString() + ', layer tree'); | |
| 68 if (debugMode) | |
| 69 write(layerTree); | |
|
Julien - ping for review
2013/04/18 00:42:34
The FAILED output could be improved. Ideally you w
Ian Vollick
2013/04/18 20:55:52
Done.
| |
| 70 } else | |
| 71 write('Iteration ' + iteration.toString() + ', no layer tree'); | |
| 72 } | |
| 73 iteration++; | |
| 74 } | |
| 75 | |
| 76 function doTest() | |
| 77 { | |
| 78 var container = document.getElementById('container'); | |
| 79 var positionedAncestor = document.getElementById('positioned-ancestor'); | |
| 80 var descendant = document.getElementById('descendant'); | |
| 81 | |
| 82 // Initial configuration should opt in. | |
| 83 printResult(true); | |
| 84 | |
| 85 // If positioned ancestor ceases to be positioned, the containing | |
| 86 // will become the abs-pos-ancestor. We should opt out. | |
| 87 positionedAncestor.style.position = 'static'; | |
| 88 printResult(false); | |
| 89 | |
| 90 // If we get rid of the out-of-flow positioned descendant at this point, | |
| 91 // it should be ok to opt back in. | |
| 92 descendant.style.display = 'none'; | |
| 93 printResult(true); | |
| 94 | |
| 95 // This should return us to our previous state. | |
| 96 descendant.style.display = ''; | |
| 97 printResult(false); | |
| 98 | |
| 99 // If the descendant ceases to be out-of-flow-positioned, then we should | |
| 100 // opt in. | |
| 101 descendant.style.position = 'static'; | |
| 102 printResult(true); | |
| 103 | |
| 104 // This should return us to our previous state. | |
| 105 descendant.style.position = ''; | |
| 106 printResult(false); | |
| 107 | |
| 108 // If the positionedAncestor again becomes positioned, it will become the | |
| 109 // containing block for the descendant and we should opt in. | |
| 110 positionedAncestor.style.position = 'relative'; | |
| 111 printResult(true); | |
| 112 } // function doTest | |
| 113 | |
| 114 window.addEventListener('load', doTest, false); | |
| 115 </script> | |
| 116 </head> | |
| 117 | |
| 118 <body> | |
| 119 <div id="abs-pos-ancestor"> | |
| 120 <div id="container"> | |
| 121 <div id="positioned-ancestor"> | |
| 122 <div id="descendant"></div> | |
| 123 </div> | |
| 124 </div> | |
| 125 </div> | |
| 126 <pre id="console"></pre> | |
| 127 </body> | |
| 128 </html> | |
| 129 | |
| OLD | NEW |