Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <html> | |
| 4 <head> | |
| 5 <style> | |
| 6 .container { | |
| 7 width: 200px; | |
| 8 height: 200px; | |
| 9 overflow: scroll; | |
| 10 margin: 20px; | |
| 11 border: 1px solid black; | |
| 12 background-color: #00FFFF; | |
| 13 } | |
| 14 | |
| 15 .scrolled { | |
| 16 width: 180px; | |
| 17 height: 30px; | |
| 18 margin: 10px; | |
| 19 top: 70px; | |
| 20 background-color: gray; | |
| 21 position: relative; | |
| 22 } | |
| 23 | |
| 24 .positioned { | |
| 25 width: 120px; | |
| 26 height: 240px; | |
| 27 position: absolute; | |
| 28 } | |
| 29 | |
| 30 #secondChild { | |
| 31 background-color: #CC9999; | |
| 32 top: 50px; | |
| 33 } | |
| 34 | |
| 35 #predecessor { | |
| 36 left: 20px; | |
| 37 top: 20px; | |
| 38 background-color: #990066; | |
| 39 } | |
| 40 | |
| 41 #successor { | |
| 42 left: 20px; | |
| 43 top: 20px; | |
| 44 background-color: #000066; | |
| 45 } | |
| 46 | |
| 47 #normalFlow { | |
| 48 width: 180px; | |
| 49 height: 30px; | |
| 50 margin: 10px; | |
| 51 top: -20px; | |
| 52 background-color: yellow; | |
|
Julien - ping for review
2013/04/24 15:44:01
Do we *really* need all this style? Ideally we sho
hartmanng
2013/04/24 17:02:41
I've taken out what I can, unfortunately a lot of
| |
| 53 } | |
| 54 </style> | |
| 55 <script src="resources/automatically-opt-into-composited-scrolling.js"></scrip t> | |
| 56 <script src="resources/build-paint-order-lists.js"></script> | |
| 57 <script> | |
| 58 function compareStackingOrderWithPaintOrder(stackingOrder, paintOrder) | |
| 59 { | |
| 60 if (debugMode) { | |
| 61 write("paint order:") | |
| 62 for (var i = 0; i < paintOrder.length; i++) | |
| 63 write(paintOrder[i].id + " " + paintOrder[i].className + " " + paintOr der[paintOrder.length - i - 1].tagName); | |
| 64 | |
| 65 write("stacking order:") | |
| 66 for (var i = 0; i < stackingOrder.length; i++) | |
| 67 write(stackingOrder[i].id + " " + stackingOrder[i].className + " " + s tackingOrder[i].tagName); | |
| 68 } | |
| 69 | |
| 70 if (stackingOrder.length < paintOrder.length) | |
| 71 return false; | |
| 72 | |
| 73 // We expect the stacking order list to contain more than the paint order | |
| 74 // list sometimes because after we promote, the container's children won't | |
| 75 // appear in the stacking context's ancestor's lists anymore (which is | |
| 76 // expected and correct). They'll still be in the stacking order list. | |
| 77 // The important part is that the order of the things present in the paint | |
| 78 // order list is preserved in the stacking order list. | |
| 79 for (var i = 0, j = 0; i < stackingOrder.length && j < paintOrder.length; i++) | |
| 80 if (stackingOrder[i] === paintOrder[paintOrder.length - j - 1]) | |
| 81 j++; | |
| 82 | |
| 83 if (debugMode) | |
| 84 write(stackingOrder.length + " " + i + " " + paintOrder.length + " " + j ); | |
| 85 | |
| 86 return j == paintOrder.length; | |
| 87 } | |
| 88 | |
| 89 function testPermutation(count) { | |
| 90 var container = document.getElementById('container'); | |
| 91 // Here we want to compare paint order lists before and after promotion | |
| 92 // to the actual stacking order as determined by hit-testing. So we | |
| 93 // first force the element not to promote, then compute its paint and | |
| 94 // stacking order lists. We then force the element to opt in, and | |
| 95 // generate the paint and stacking order lists after opt-in. | |
| 96 // | |
| 97 // The paint order lists should exactly match the stacking order lists | |
| 98 // (modulo children that fall outside of the hit-testing area | |
| 99 // on-screen), both before and after promotion. | |
| 100 container.style.webkitTransform = 'translateZ(0px)'; | |
| 101 document.body.offsetTop; | |
| 102 | |
| 103 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(false); | |
| 104 container.style.webkitTransform = ''; | |
| 105 | |
| 106 var oldStackingOrder = getStackingOrder(container); | |
| 107 var oldPaintOrder = getPaintOrder(container); | |
| 108 | |
| 109 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(true); | |
| 110 container.style.webkitTransform = 'translateZ(0px)'; | |
| 111 | |
| 112 var newStackingOrder = getStackingOrder(container); | |
| 113 var newPaintOrder = getPaintOrder(container); | |
| 114 | |
| 115 // The getPaintOrder() function should return a pair of paint orders. | |
| 116 // One before promotion and one after. This pair of lists should remain | |
| 117 // identical whether the element is actually currently promoted or not, | |
| 118 // its purpose is to generate hypothetical pre- and post-lists to | |
| 119 // determine if the element is promotable. | |
| 120 if (!comparePaintOrderLists(oldPaintOrder, newPaintOrder)) | |
| 121 write("iteration " + count + " FAIL - paint order lists not identical be fore/after promotion"); | |
| 122 | |
| 123 if (!compareStackingOrderWithPaintOrder(oldStackingOrder, oldPaintOrder.be forePromote)) | |
| 124 write("iteration " + count + " FAIL - paint order list before promote do esn't match stacking order"); | |
| 125 | |
| 126 if (!compareStackingOrderWithPaintOrder(newStackingOrder, oldPaintOrder.af terPromote)) | |
| 127 write("iteration " + count + " FAIL - paint order list after promote doe sn't match stacking order"); | |
| 128 | |
| 129 var containerOccurrences = countOccurrencesOfElementInPaintOrderList(oldPa intOrder.beforePromote, container); | |
| 130 if (containerOccurrences !== 1) | |
| 131 write("iteration " + count + " FAIL - paint order list before promote co ntains " + containerOccurrences + " occurrences of container. Should be exactly 1."); | |
| 132 | |
| 133 containerOccurrences = countOccurrencesOfElementInPaintOrderList(oldPaintO rder.afterPromote, container); | |
| 134 if (containerOccurrences !== 1) | |
| 135 write("iteration " + count + " FAIL - paint order list after promote con tains " + containerOccurrences + " occurrences of container. Should be exactly 1 ."); | |
| 136 } | |
| 137 | |
| 138 function doTest() | |
| 139 { | |
| 140 buildDom(); | |
| 141 permute(testPermutation); | |
| 142 } | |
| 143 | |
| 144 window.addEventListener('load', doTest, false); | |
| 145 </script> | |
| 146 </head> | |
| 147 | |
| 148 <body> | |
| 149 </body> | |
| 150 </html> | |
| OLD | NEW |