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

Side by Side Diff: LayoutTests/compositing/overflow/automatically-opt-into-composited-scrolling.html

Issue 13722015: Update automatically-opt-into-composited-scrolling.html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 1 <!DOCTYPE html>
2 "http://www.w3.org/TR/html4/loose.dtd">
3 2
4 <html lang="en"> 3 <html>
5 <head> 4 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7 <title>Opting into composited scrolling</title>
8 <style type="text/css" media="screen"> 5 <style type="text/css" media="screen">
9 .container { 6 .container {
10 width: 200px; 7 width: 200px;
11 height: 200px; 8 height: 200px;
12 overflow: scroll; 9 overflow: scroll;
13 margin: 20px; 10 margin: 20px;
14 border: 1px solid black; 11 border: 1px solid black;
12 background-color: #00FFFF;
15 } 13 }
16 14
17 .scrolled { 15 .scrolled {
18 width: 180px; 16 width: 180px;
19 height: 90px; 17 height: 30px;
20 margin: 10px; 18 margin: 10px;
19 top: 70px;
21 background-color: gray; 20 background-color: gray;
22 position: relative; 21 position: relative;
23 } 22 }
24 23
25 .positioned { 24 .positioned {
26 width: 120px; 25 width: 120px;
27 height: 240px; 26 height: 240px;
28 background-color: green;
29 position: absolute; 27 position: absolute;
30 } 28 }
31 29
30 #secondChild {
31 background-color: #CC9999;
32 top: 50px;
33 }
34
32 #predecessor { 35 #predecessor {
33 left: 20px; 36 left: 20px;
34 top: 20px; 37 top: 20px;
38 background-color: #990066;
35 } 39 }
36 40
37 #successor { 41 #successor {
38 left: 160px; 42 left: 20px;
39 top: 20px; 43 top: 20px;
44 background-color: #000066;
40 } 45 }
41 46
42 #descendant { 47 #normalFlow {
43 left: 90px; 48 width: 180px;
44 top: 20px; 49 height: 30px;
45 background-color: blue; 50 margin: 10px;
46 z-index: -20; 51 background-color: yellow;
47 } 52 }
48 </style> 53 </style>
54 <script type="text/javascript" charset="utf-8" src="automatically-opt-into-com posited-scrolling.js"></script>
Julien - ping for review 2013/04/09 17:41:59 Can we remove the useless attributes from new test
hartmanng 2013/04/09 20:40:09 Yeah, sorry, a lot of this was originally based on
49 <script type="text/javascript" charset="utf-8"> 55 <script type="text/javascript" charset="utf-8">
50 var debugMode = false; 56 function didPass(count, ordering, hasPositionedAncestor, containerIsPosition ed)
Julien - ping for review 2013/04/09 17:41:59 didPass is misnamed as it can print FAIL. How abo
hartmanng 2013/04/09 20:40:09 Done.
57 {
58 var container = document.getElementById('container');
51 59
52 if (window.testRunner) 60 // Below, when we set webkitTransform to '', we want that to force an
53 testRunner.dumpAsText(); 61 // immediate, synchronous style recalculation. Querying the
54 62 // document.body.offsetTop value should force this for us.
55 if (window.internals) 63 // Note that this step is also performed inside getStackingOrder() to make
56 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(true); 64 // sure we have fresh values when we need them.
57 65 container.style.webkitTransform = 'translateZ(0px)';
58 function write(str)
59 {
60 var pre = document.getElementById('console');
61 var text = document.createTextNode(str + '\n');
62 pre.appendChild(text);
63 }
64
65 var iteration = 0;
66 function printResult(expectedResult)
67 {
68 // Force a style recalc.
69 document.body.offsetTop; 66 document.body.offsetTop;
70 67
71 if (window.internals) { 68 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(false);
72 // Force a layout. 69 container.style.webkitTransform = '';
73 window.internals.boundingBox(container);
74 var layerTree = window.internals.layerTreeAsText(document);
75 70
76 if (!layerTree == !expectedResult) 71 var oldStackingOrder = getStackingOrder(container);
77 write('Iteration ' + iteration.toString() + ': Passed') 72
73 // force to promote.
74 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnable d(true);
75 container.style.webkitTransform = 'translateZ(0px)';
76
77 var newStackingOrder = getStackingOrder(container);
78
79 var shouldOptIn = oldStackingOrder.length === newStackingOrder.length;
80 for (var i = 0; i < oldStackingOrder.length; ++i) {
81 if (oldStackingOrder[i] !== newStackingOrder[i]) {
82 shouldOptIn = false;
83 break;
84 }
85 }
86
87 container.style.webkitTransform = '';
88 if (shouldOptIn !== didOptIn(container)) {
89 if (shouldOptIn)
90 write("FAIL - should've automatically opted in but didn't " + count);
78 else 91 else
79 write('Iteration ' + iteration.toString() + ': FAILED') 92 write('FAIL - automatically opted in and changed stacking order ' + co unt);
80 93
81 if (layerTree) { 94 var additionalFailureInfo = "\tOrdering:";
82 write('Iteration ' + iteration.toString() + ', layer tree'); 95 for(var i = 0; i < ordering.length; ++i) {
83 if (debugMode) 96 additionalFailureInfo += " " + ordering[i].id + " (z-index: " + orderi ng[i].style.zIndex + ")";
84 write(layerTree); 97 if(i < ordering.length - 1)
85 } else 98 additionalFailureInfo += ",";
86 write('Iteration ' + iteration.toString() + ', no layer tree'); 99 }
100
101 additionalFailureInfo += "\n\thasPositionedAncestor: " + hasPositionedAn cestor + "; containerIsPositioned: " + containerIsPositioned;
102 write(additionalFailureInfo);
103 } else {
104 if (shouldOptIn)
105 write("PASS iteration " + count + ": opted in, since doing so does not change the stacking order.");
106 else
107 write("PASS iteration " + count + ": did not opt in, since doing so wo uld change the stacking order.");
87 } 108 }
88 iteration++;
89 } 109 }
90 110
91 function doTest() 111 function doTest()
92 { 112 {
93 var predecessor = document.getElementById('predecessor'); 113 buildDom();
94 var successor = document.getElementById('successor'); 114 permute(didPass);
95 var container = document.getElementById('container'); 115 }
96 var firstChild = document.getElementById('firstChild');
97 var secondChild = document.getElementById('secondChild');
98 var descendant = document.getElementById('descendant');
99 var count = 0;
100
101 descendant.style.display = 'none';
102
103 // descendants in stacking order.
104 for (i = 0; i < 3; ++i) {
105 for (j = 0; j < 5; ++j) {
106 for (k = 0; k < 2; ++k) {
107 for (l = 0; l < 2; ++l) {
108 var minZIndex = 0;
109 var maxZIndex = 0;
110 if (i == 0) {
111 firstChild.style.zIndex = '1';
112 secondChild.style.zIndex = '3';
113 maxZIndex = 3;
114 } else if (i == 1) {
115 firstChild.style.zIndex = '-1';
116 secondChild.style.zIndex = '-3';
117 minZIndex = -3;
118 } else {
119 firstChild.style.zIndex = '-1';
120 secondChild.style.zIndex = '3';
121 minZIndex = -1;
122 maxZIndex = 3;
123 }
124
125 var sibling = predecessor;
126 var toHide = successor;
127 if (k == 1) {
128 sibling = successor;
129 toHide = predecessor;
130 }
131
132 // The result should be the same if the the element to hide is
133 // display:hidden or display:none.
134 if (l == 0)
135 toHide.style.display = 'none';
136 else
137 toHide.style.display = 'hidden';
138
139 sibling.style.display = '';
140
141 if (j == 0)
142 sibling.style.zIndex = (maxZIndex + 1).toString();
143 else if (j == 1)
144 sibling.style.zIndex = (minZIndex - 1).toString();
145 else if (j == 2)
146 sibling.style.zIndex = maxZIndex.toString();
147 else if (j == 3)
148 sibling.style.zIndex = minZIndex.toString();
149 else
150 sibling.style.zIndex = ((minZIndex + maxZIndex) / 2).toString();
151
152 var areContiguous = false;
153 if (sibling.style.zIndex > maxZIndex ||
154 sibling.style.zIndex < minZIndex) {
155 // sibling is outside the range of our descendants.
156 areContiguous = true;
157 } else if (sibling.style.zIndex < maxZIndex &&
158 sibling.style.zIndex > minZIndex) {
159 // sibling is between our descendants.
160 areContiguous = false;
161 } else if (sibling.style.zIndex == minZIndex) {
162 if (minZIndex == 0) {
163 // sibling lies between us (normal flow) and our pos
164 // z-order descendants, so we are not contiguous.
165 areContiguous = false;
166 } else {
167 // sibling's zIndex matches the min; we're only ok if it
168 // appears first.
169 areContiguous = k == 0;
170 }
171 } else if (sibling.style.zIndex == maxZIndex) {
172 if (maxZIndex < 0) {
173 // sibling lies between us (normal flow) and neg z-order
174 // descendants, so we are not contiguous.
175 areContiguous = false;
176 } else if (maxZIndex == 0) {
177 // sibling is in the pos z-order list and does not affect
178 // us since we're in the normal flow list and our
179 // descandants are in the neg z-order list.
180 areContiguous = true;
181 } else {
182 // sibling's zIndex matches the max; we're only ok if it
183 // appears after.
184 areContiguous = k == 1;
185 }
186 }
187
188 printResult(areContiguous);
189 } // for l
190 } // for k
191 } // for j
192 } // for i
193
194 // Now check that we don't promote if we have an out of flow descendant.
195 // We need to hide the predecessor and successor so they don't interfere
196 // with this experiment.
197 predecessor.style.display = 'none';
198 successor.style.display = 'none';
199 for (i = 0; i < 3; ++i) {
200 if (i == 0)
201 descendant.style.display = 'hidden';
202 else if (i == 1)
203 descendant.style.display = '';
204 else
205 descendant.style.display = 'none';
206
207 // If the out of flow positioned descendant is visible, we cannot opt
208 // into composited scrolling.
209 printResult(i != 1);
210 count++;
211 } // for i
212
213 } // function doTest
214 116
215 window.addEventListener('load', doTest, false); 117 window.addEventListener('load', doTest, false);
216 </script> 118 </script>
217 </head> 119 </head>
218 120
219 <body> 121 <body>
220 <div class="positioned" id="predecessor"></div>
221 <div class="container" id="container">
222 <div class="scrolled" id="firstChild"></div>
223 <div class="scrolled" id="secondChild"></div>
224 <div class="positioned" id="descendant"></div>
225 </div>
226 <div class="positioned" id="successor"></div>
227 <pre id="console"></pre>
228 </body> 122 </body>
229 </html> 123 </html>
230
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698