Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: LayoutTests/compositing/overflow/build-paint-order-list-where-opt-in-decisions-can-affect-each-other.html

Issue 13467028: Add an intermediate function to generate 2 paint-order lists. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Responding to Ian's comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2
3 <html><head>
4 <style>
5 .filler {
6 background-color: #CC9900;
7 margin: 20px;
8 border-style: solid;
9 border-width: 1px;
10 width: 400px;
11 height: 100px;
12 }
13
14 .negativechild {
15 z-index: -1;
16 position: relative;
17 }
18
19 #parentscrollinglayer {
20 background-color: #CC9999;
21 height: 200px;
22 width: 500px;
23 overflow-y: scroll;
24 }
25
26 #childscrollinglayer {
27 margin: 30px;
28 position: relative;
29 left: 20px;
30 top: 20px;
31 background-color: #990066;
32 height: 200px;
33 width: 300px;
34 overflow-x: scroll;
35 }
36 </style>
37
38 <script>
39 var debugMode = false;
40
41 if (window.testRunner)
42 testRunner.dumpAsText();
43
44 function write(str)
45 {
46 var pre = document.getElementById('console');
47 var text = document.createTextNode(str + '\n');
48 pre.appendChild(text);
49 }
50
51 function getStackingOrder()
52 {
53 var divElements = [];
54 // Force a style recalc.
55 document.body.offsetTop;
56
57 var stackingOrder = window.internals.nodesFromRect(document, 100, 75, 200, 200, 200, 200, false, false, false);
58
59 for (var i = 0; i < stackingOrder.length; ++i)
60 if (stackingOrder[i].nodeName === "DIV")
61 divElements.push(stackingOrder[i]);
62
63 return divElements;
64 }
65
66 function getPaintOrder()
67 {
68 var divElementsBeforePromote = [];
69 var divElementsAfterPromote = [];
70 // Force a style recalc.
71 document.body.offsetTop;
72
73 var paintOrderLists = window.internals.paintOrderLists(document.getElement ById('childscrollinglayer'));
74 var paintOrderListBeforePromote = paintOrderLists.listBeforePromote;
75 var paintOrderListAfterPromote = paintOrderLists.listAfterPromote;
76
77 for (var i = 0; i < paintOrderListBeforePromote.length; ++i)
78 if (paintOrderListBeforePromote[i].nodeName === "DIV")
79 divElementsBeforePromote.push(paintOrderListBeforePromote[i]);
80
81 for (var i = 0; i < paintOrderListAfterPromote.length; ++i)
82 if (paintOrderListAfterPromote[i].nodeName === "DIV")
83 divElementsAfterPromote.push(paintOrderListAfterPromote[i]);
84
85 return {"beforePromote": divElementsBeforePromote,
86 "afterPromote": divElementsAfterPromote};
87 }
88
89 function comparePaintOrderLists(oldPaintOrder, newPaintOrder)
90 {
91 if (oldPaintOrder.length !== newPaintOrder.length)
92 return false;
93
94 for (var i = 0; i < oldPaintOrder.length; i++)
95 if (oldPaintOrder[i] !== newPaintOrder[i])
96 return false;
97
98 return true;
99 }
100
101 function compareStackingOrderWithPaintOrder(stackingOrder, paintOrder)
102 {
103 if (debugMode) {
104 write("paint:")
105 for (var i = 0; i < paintOrder.length; i++)
106 write(paintOrder[i].id + " " + paintOrder[i].className + " " + paintOr der[i].tagName);
107
108 write("stacking:")
109 for (var i = 0; i < stackingOrder.length; i++)
110 write(stackingOrder[i].id + " " + stackingOrder[i].className + " " + s tackingOrder[i].tagName);
111 }
112
113 for (var i = 0, j = 0; i < stackingOrder.length && j < paintOrder.length; i++) {
114 // Ignore elements with class "filler negativechild". These elements are
115 // irrelevant to stacking order, since they do not overlap with the
116 // elements we care about. They exist in the paint order lists because
117 // they are still descendants of the same stacking context, but they
118 // will not affect visual layout.
119 while (j < paintOrder.length && paintOrder[paintOrder.length - j - 1].cl assName === "filler negativechild")
120 j++;
121
122 if (j >= paintOrder.length)
123 break;
124
125 if (stackingOrder[i] === paintOrder[paintOrder.length - j - 1])
126 j++;
127 }
128
129 if (debugMode)
130 write(stackingOrder.length + " " + i + " " + paintOrder.length + " " + j );
131
132 return j === paintOrder.length;
133 }
134
135 function countOccurrencesOfChildScrollingLayerInPaintOrderList(paintOrder) {
136 var childScrollingLayer = document.getElementById('childscrollinglayer');
137 var occurrenceCount = 0;
138 for (var i = 0; i < paintOrder.length; i++)
139 if (paintOrder[i] === childScrollingLayer)
140 occurrenceCount++;
141
142 return occurrenceCount;
143 }
144
145 function doTest()
146 {
147 var parentscrollinglayer = document.getElementById('parentscrollinglayer') ;
148 var childscrollinglayer = document.getElementById('childscrollinglayer');
149
150 if (window.internals) {
151 // Here we want to compare paint order lists before and after promotion
152 // to the actual stacking order as determined by hit-testing. So we
153 // first force the element not to promote, then compute its paint and
154 // stacking order lists. We then force the element to opt in, and
155 // generate the paint and stacking order lists after opt-in.
156 //
157 // The paint order lists should exactly match the stacking order lists
158 // (modulo children that fall outside of the hit-testing area
159 // on-screen), both before and after promotion.
160 parentscrollinglayer.style.webkitTransform = 'translateZ(0px)';
161 document.body.offsetTop;
162
163 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnab led(false);
164 parentscrollinglayer.style.webkitTransform = '';
165
166 var oldStackingOrder = getStackingOrder();
167 var oldPaintOrder = getPaintOrder();
168
169 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnab led(true);
170 parentscrollinglayer.style.webkitTransform = 'translateZ(0px)';
171
172 var newStackingOrder = getStackingOrder();
173 var newPaintOrder = getPaintOrder();
174
175 // The getPaintOrder() function should return a pair of paint orders.
176 // One before promotion and one after. This pair of lists should remain
177 // identical whether the element is actually currently promoted or not,
178 // its purpose is to generate hypothetical pre- and post-lists to
179 // determine if the element is promotable.
180 if (!comparePaintOrderLists(oldPaintOrder, newPaintOrder))
181 write("FAIL - paint order lists not identical before/after promotion") ;
182
183 if (!compareStackingOrderWithPaintOrder(oldStackingOrder, oldPaintOrder. beforePromote))
184 write("FAIL - paint order list before promote doesn't match stacking o rder");
185
186 if (!compareStackingOrderWithPaintOrder(newStackingOrder, oldPaintOrder. afterPromote))
187 write("FAIL - paint order list after promote doesn't match stacking or der");
188
189 var childScrollingLayerOccurrences = countOccurrencesOfChildScrollingLay erInPaintOrderList(oldPaintOrder.beforePromote);
190 if (childScrollingLayerOccurrences !== 1)
191 write("FAIL - paint order list before promote contains " + childScroll ingLayerOccurrences + " occurrences of child scrolling layer. Should be exactly 1.");
192
193 childScrollingLayerOccurrences = countOccurrencesOfChildScrollingLayerIn PaintOrderList(oldPaintOrder.afterPromote);
194 if (childScrollingLayerOccurrences !== 1)
195 write("FAIL - paint order list after promote contains " + childScrolli ngLayerOccurrences + " occurrences of child scrolling layer. Should be exactly 1 .");
196
197 if (debugMode)
198 write(window.internals.paintOrderListsAsText(container));
199
200 write("PASS - did not crash.");
201 }
202 }
203
204 window.addEventListener('load', doTest, false);
205 </script>
206 </head>
207 <body>
208 <div class="filler"></div>
209 <div id="parentscrollinglayer">
210 <div id="childscrollinglayer">
211 <div class="filler"></div>
212 </div>
213 <div class="filler"></div>
214 <div class="filler"></div>
215 </div>
216 <div id="fillerchild1" class="filler negativechild"></div>
217 <div id="fillerchild2" class="filler negativechild"></div>
218 <div id="fillerchild3" class="filler negativechild"></div>
219 <div id="fillerchild4" class="filler negativechild"></div>
220 <pre id="console"></pre>
221 </body>
222 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698