OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 |
| 3 <html><head> |
| 4 <style> |
| 5 .filler { |
| 6 background-color: #CC9900; |
| 7 border-style: solid; |
| 8 border-width: 1px; |
| 9 width: 400px; |
| 10 height: 100px; |
| 11 } |
| 12 |
| 13 .negativechild { |
| 14 z-index: -1; |
| 15 position: relative; |
| 16 } |
| 17 |
| 18 #parentscrollinglayer { |
| 19 background-color: #CC9999; |
| 20 height: 200px; |
| 21 width: 500px; |
| 22 overflow-y: scroll; |
| 23 } |
| 24 |
| 25 #childscrollinglayer { |
| 26 position: relative; |
| 27 background-color: #990066; |
| 28 height: 200px; |
| 29 width: 300px; |
| 30 overflow-x: scroll; |
| 31 } |
| 32 </style> |
| 33 |
| 34 <script src="resources/build-paint-order-lists.js"></script> |
| 35 <script> |
| 36 var debugMode = false; |
| 37 |
| 38 if (window.testRunner) |
| 39 testRunner.dumpAsText(); |
| 40 |
| 41 function write(str) |
| 42 { |
| 43 var pre = document.getElementById('console'); |
| 44 var text = document.createTextNode(str + '\n'); |
| 45 pre.appendChild(text); |
| 46 } |
| 47 |
| 48 function getStackingOrder() |
| 49 { |
| 50 var divElements = []; |
| 51 // Force a style recalc. |
| 52 document.body.offsetTop; |
| 53 |
| 54 var stackingOrder = window.internals.nodesFromRect(document, 100, 75, 200,
200, 200, 200, false, false, false); |
| 55 |
| 56 for (var i = 0; i < stackingOrder.length; ++i) |
| 57 if (stackingOrder[i].nodeName === "DIV") |
| 58 divElements.push(stackingOrder[i]); |
| 59 |
| 60 return divElements; |
| 61 } |
| 62 |
| 63 function compareStackingOrderWithPaintOrder(stackingOrder, paintOrder) |
| 64 { |
| 65 if (debugMode) { |
| 66 write("paint:") |
| 67 for (var i = 0; i < paintOrder.length; i++) |
| 68 write(paintOrder[i].id + " " + paintOrder[i].className + " " + paintOr
der[i].tagName); |
| 69 |
| 70 write("stacking:") |
| 71 for (var i = 0; i < stackingOrder.length; i++) |
| 72 write(stackingOrder[i].id + " " + stackingOrder[i].className + " " + s
tackingOrder[i].tagName); |
| 73 } |
| 74 |
| 75 for (var i = 0, j = 0; i < stackingOrder.length && j < paintOrder.length;
i++) { |
| 76 // Ignore elements with class "filler negativechild". These elements are |
| 77 // irrelevant to stacking order, since they do not overlap with the |
| 78 // elements we care about. They exist in the paint order lists because |
| 79 // they are still descendants of the same stacking context, but they |
| 80 // will not affect visual layout. |
| 81 while (j < paintOrder.length && paintOrder[paintOrder.length - j - 1].cl
assName === "filler negativechild") |
| 82 j++; |
| 83 |
| 84 if (j >= paintOrder.length) |
| 85 break; |
| 86 |
| 87 if (stackingOrder[i] === paintOrder[paintOrder.length - j - 1]) |
| 88 j++; |
| 89 } |
| 90 |
| 91 if (debugMode) |
| 92 write(stackingOrder.length + " " + i + " " + paintOrder.length + " " + j
); |
| 93 |
| 94 return j === paintOrder.length; |
| 95 } |
| 96 |
| 97 function doTest() |
| 98 { |
| 99 var parentscrollinglayer = document.getElementById('parentscrollinglayer')
; |
| 100 var childscrollinglayer = document.getElementById('childscrollinglayer'); |
| 101 |
| 102 if (window.internals) { |
| 103 var failure = false; |
| 104 |
| 105 // Here we want to compare paint order lists before and after promotion |
| 106 // to the actual stacking order as determined by hit-testing. So we |
| 107 // first force the element not to promote, then compute its paint and |
| 108 // stacking order lists. We then force the element to opt in, and |
| 109 // generate the paint and stacking order lists after opt-in. |
| 110 // |
| 111 // The paint order lists should exactly match the stacking order lists |
| 112 // (modulo children that fall outside of the hit-testing area |
| 113 // on-screen), both before and after promotion. |
| 114 parentscrollinglayer.style.webkitTransform = 'translateZ(0px)'; |
| 115 document.body.offsetTop; |
| 116 |
| 117 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnab
led(false); |
| 118 parentscrollinglayer.style.webkitTransform = ''; |
| 119 |
| 120 var oldStackingOrder = getStackingOrder(); |
| 121 var oldPaintOrder = getPaintOrder(childscrollinglayer); |
| 122 |
| 123 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnab
led(true); |
| 124 parentscrollinglayer.style.webkitTransform = 'translateZ(0px)'; |
| 125 |
| 126 var newStackingOrder = getStackingOrder(); |
| 127 var newPaintOrder = getPaintOrder(childscrollinglayer); |
| 128 |
| 129 // The getPaintOrder() function should return a pair of paint orders. |
| 130 // One before promotion and one after. This pair of lists should remain |
| 131 // identical whether the element is actually currently promoted or not, |
| 132 // its purpose is to generate hypothetical pre- and post-lists to |
| 133 // determine if the element is promotable. |
| 134 if (!comparePaintOrderLists(oldPaintOrder, newPaintOrder)) { |
| 135 failure = true; |
| 136 write("FAIL - paint order lists not identical before/after promotion")
; |
| 137 } |
| 138 |
| 139 if (!compareStackingOrderWithPaintOrder(oldStackingOrder, oldPaintOrder.
beforePromote)) { |
| 140 failure = true; |
| 141 write("FAIL - paint order list before promote doesn't match stacking o
rder"); |
| 142 } |
| 143 |
| 144 if (!compareStackingOrderWithPaintOrder(newStackingOrder, oldPaintOrder.
afterPromote)) { |
| 145 failure = true; |
| 146 write("FAIL - paint order list after promote doesn't match stacking or
der"); |
| 147 } |
| 148 |
| 149 var childScrollingLayerOccurrences = countOccurrencesOfElementInPaintOrd
erList(oldPaintOrder.beforePromote, childscrollinglayer); |
| 150 if (childScrollingLayerOccurrences !== 1) { |
| 151 failure = true; |
| 152 write("FAIL - paint order list before promote contains " + childScroll
ingLayerOccurrences + " occurrences of child scrolling layer. Should be exactly
1."); |
| 153 } |
| 154 |
| 155 childScrollingLayerOccurrences = countOccurrencesOfElementInPaintOrderLi
st(oldPaintOrder.afterPromote, childscrollinglayer); |
| 156 if (childScrollingLayerOccurrences !== 1) { |
| 157 failure = true; |
| 158 write("FAIL - paint order list after promote contains " + childScrolli
ngLayerOccurrences + " occurrences of child scrolling layer. Should be exactly 1
."); |
| 159 } |
| 160 |
| 161 if(!failure) |
| 162 write("PASS - did not crash."); |
| 163 } |
| 164 } |
| 165 |
| 166 window.addEventListener('load', doTest, false); |
| 167 </script> |
| 168 </head> |
| 169 <body> |
| 170 <div class="filler"></div> |
| 171 <div id="parentscrollinglayer"> |
| 172 <div id="childscrollinglayer"> |
| 173 <div class="filler"></div> |
| 174 </div> |
| 175 <div class="filler"></div> |
| 176 <div class="filler"></div> |
| 177 </div> |
| 178 <div id="fillerchild1" class="filler negativechild"></div> |
| 179 <div id="fillerchild2" class="filler negativechild"></div> |
| 180 <div id="fillerchild3" class="filler negativechild"></div> |
| 181 <div id="fillerchild4" class="filler negativechild"></div> |
| 182 <pre id="console"></pre> |
| 183 </body> |
| 184 </html> |
OLD | NEW |