9c339ce324aa5f2661da4b1d154b02e872e0bc29
[WebKit-https.git] / LayoutTests / fast / css-grid-layout / grid-item-removal-track-breadth-update.html
1 <!DOCTYPE html>
2 <html>
3 <script>
4 if (window.testRunner)
5     testRunner.overridePreference("WebKitCSSGridLayoutEnabled", 1);
6 </script>
7 <link href="resources/grid.css" rel="stylesheet">
8 <style>
9 .gridAutoContent {
10     -webkit-grid-template-columns: auto;
11     -webkit-grid-template-rows: auto;
12 }
13
14 .gridMinContentFixed {
15     -webkit-grid-template-columns: minmax(-webkit-min-content, 100px);
16     -webkit-grid-template-rows: minmax(-webkit-min-content, 40px);
17 }
18
19 .gridMaxContentFixed {
20     -webkit-grid-template-columns: minmax(-webkit-max-content, 150px);
21     -webkit-grid-template-rows: minmax(-webkit-max-content, 40px);
22 }
23
24 .gridFixedMinContent {
25     -webkit-grid-template-columns: minmax(100px, -webkit-min-content);
26     -webkit-grid-template-rows: minmax(40px, -webkit-min-content);
27 }
28
29 .gridFixedMaxContent {
30     -webkit-grid-template-columns: minmax(100px, -webkit-max-content);
31     -webkit-grid-template-rows: minmax(40px, -webkit-max-content);
32 }
33
34 .lessConstrainedContainer {
35     width: 60px;
36     height: 20px;
37 }
38
39 .firstRowFirstColumn {
40     font: 10px/1 Ahem;
41     /* Make us fit our grid area. */
42     width: 100%;
43     height: 100%;
44 }
45 </style>
46 <script src="../../resources/check-layout.js"></script>
47 <script>
48 function testRemoval(gridElementID, size1, size2, size3)
49 {
50     var gridElement = document.getElementById(gridElementID);
51     var gridItem1 = gridElement.firstChild.nextSibling;
52     var gridItem2 = gridItem1.nextSibling.nextSibling;
53     var gridItem3 = gridItem2.nextSibling.nextSibling;
54     gridItem1.setAttribute("data-expected-width", size1.width);
55     gridItem1.setAttribute("data-expected-height", size1.height);
56     gridItem2.setAttribute("data-expected-width", size1.width);
57     gridItem2.setAttribute("data-expected-height", size1.height);
58     gridItem3.setAttribute("data-expected-width", size1.width);
59     gridItem3.setAttribute("data-expected-height", size1.height);
60     checkLayout("#" + gridElementID);
61
62     gridElement.removeChild(gridItem1);
63     gridItem2.setAttribute("data-expected-width", size2.width);
64     gridItem2.setAttribute("data-expected-height", size2.height);
65     gridItem3.setAttribute("data-expected-width", size2.width);
66     gridItem3.setAttribute("data-expected-height", size2.height);
67     checkLayout("#" + gridElementID);
68
69     gridElement.removeChild(gridItem2);
70     gridItem3.setAttribute("data-expected-width", size3.width);
71     gridItem3.setAttribute("data-expected-height", size3.height);
72     checkLayout("#" + gridElementID);
73 }
74
75 function testRemovals()
76 {
77     testRemoval("constrainedAutoGrid", { 'width': '50', 'height': '40' }, { 'width': '40', 'height': '40' }, { 'width': '30', 'height': '30' });
78     testRemoval("constrainedMinContentFixedGrid", { 'width': '50', 'height': '40' }, { 'width': '40', 'height': '40' }, { 'width': '30', 'height': '30' });
79     testRemoval("constrainedMaxContentFixedGrid", { 'width': '190', 'height': '10' }, { 'width': '190', 'height': '10' }, { 'width': '110', 'height': '10' });
80     testRemoval("constrainedFixedMinContentGrid", { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' });
81     testRemoval("constrainedFixedMaxContentGrid", { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' });
82
83     testRemoval("unconstrainedAutoGrid", { 'width': '390', 'height': '10' }, { 'width': '350', 'height': '10' }, { 'width': '170', 'height': '10' });
84     testRemoval("unconstrainedMinContentFixedGrid", { 'width': '100', 'height': '60' }, { 'width': '100', 'height': '60' }, { 'width': '100', 'height': '40' });
85     testRemoval("unconstrainedMaxContentFixedGrid", { 'width': '390', 'height': '40' }, { 'width': '350', 'height': '40' }, { 'width': '170', 'height': '40' });
86     testRemoval("unconstrainedFixedMinContentGrid", { 'width': '100', 'height': '60' }, { 'width': '100', 'height': '60' }, { 'width': '100', 'height': '40' });
87     testRemoval("unconstrainedFixedMaxContentGrid", { 'width': '390', 'height': '40' }, { 'width': '350', 'height': '40' }, { 'width': '170', 'height': '40' });
88
89     testRemoval("lessConstrainedAutoGrid", { 'width': '60', 'height': '90' }, { 'width': '60', 'height': '60' }, { 'width': '60', 'height': '30' });
90     testRemoval("lessConstrainedMinContentFixedGrid", { 'width': '60', 'height': '90' }, { 'width': '60', 'height': '60' }, { 'width': '60', 'height': '30' });
91     testRemoval("lessConstrainedMaxContentFixedGrid", { 'width': '350', 'height': '20' }, { 'width': '350', 'height': '20' }, { 'width': '170', 'height': '20' });
92     testRemoval("lessConstrainedFixedMinContentGrid", { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' });
93     testRemoval("lessConstrainedFixedMaxContentGrid", { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' }, { 'width': '100', 'height': '40' });
94 }
95 window.addEventListener("load", testRemovals, false);
96 </script>
97 <body>
98
99 <p>This test checks that the tracks' breadth are recomputed after removing a grid item.</p>
100
101 <div class="constrainedContainer">
102     <div class="grid gridAutoContent" id="constrainedAutoGrid">
103         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX</div>
104         <div class="firstRowFirstColumn">XXXX XXXX XXXX XXXX</div>
105         <div class="firstRowFirstColumn">XXX XXX XXX</div>
106     </div>
107 </div>
108
109 <div class="constrainedContainer">
110     <div class="grid gridMinContentFixed" id="constrainedMinContentFixedGrid">
111         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX</div>
112         <div class="firstRowFirstColumn">XXXX XXXX XXXX XXXX</div>
113         <div class="firstRowFirstColumn">XXX XXX XXX</div>
114     </div>
115 </div>
116
117 <div class="constrainedContainer">
118     <div class="grid gridMaxContentFixed" id="constrainedMaxContentFixedGrid">
119         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX</div>
120         <div class="firstRowFirstColumn">XXXX XXXX XXXX XXXX</div>
121         <div class="firstRowFirstColumn">XXX XXX XXX</div>
122     </div>
123 </div>
124
125 <div class="constrainedContainer">
126     <div class="grid gridFixedMinContent" id="constrainedFixedMinContentGrid">
127         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX</div>
128         <div class="firstRowFirstColumn">XXXX XXXX XXXX XXXX</div>
129         <div class="firstRowFirstColumn">XXX XXX XXX</div>
130     </div>
131 </div>
132
133 <div class="constrainedContainer">
134     <div class="grid gridFixedMaxContent" id="constrainedFixedMaxContentGrid">
135         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX</div>
136         <div class="firstRowFirstColumn">XXXX XXXX XXXX XXXX</div>
137         <div class="firstRowFirstColumn">XXX XXX XXX</div>
138     </div>
139 </div>
140
141 <!-- The container is big enough to allow all the extra space distribution we want. -->
142 <div class="unconstrainedContainer">
143     <div class="grid gridAutoContent" id="unconstrainedAutoGrid">
144         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
145         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
146         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
147     </div>
148 </div>
149
150 <div class="unconstrainedContainer">
151     <div class="grid gridMinContentFixed" id="unconstrainedMinContentFixedGrid">
152         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
153         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
154         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
155     </div>
156 </div>
157
158 <div class="unconstrainedContainer">
159     <div class="grid gridMaxContentFixed" id="unconstrainedMaxContentFixedGrid">
160         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
161         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
162         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
163     </div>
164 </div>
165
166 <div class="unconstrainedContainer">
167     <div class="grid gridFixedMinContent" id="unconstrainedFixedMinContentGrid">
168         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
169         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
170         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
171     </div>
172 </div>
173
174 <div class="unconstrainedContainer">
175     <div class="grid gridFixedMaxContent" id="unconstrainedFixedMaxContentGrid">
176         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
177         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
178         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
179     </div>
180 </div>
181
182 <!-- The container allows some expansion but also constrain the growth. -->
183 <div class="lessConstrainedContainer">
184     <div class="grid gridAutoContent" id="lessConstrainedAutoGrid">
185         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
186         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
187         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
188     </div>
189 </div>
190
191 <div class="lessConstrainedContainer">
192     <div class="grid gridMinContentFixed" id="lessConstrainedMinContentFixedGrid">
193         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
194         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
195         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
196     </div>
197 </div>
198
199 <div class="lessConstrainedContainer">
200     <div class="grid gridMaxContentFixed" id="lessConstrainedMaxContentFixedGrid">
201         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
202         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
203         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
204     </div>
205 </div>
206
207 <div class="lessConstrainedContainer">
208     <div class="grid gridFixedMinContent" id="lessConstrainedFixedMinContentGrid">
209         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
210         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
211         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
212     </div>
213 </div>
214
215 <div class="lessConstrainedContainer">
216     <div class="grid gridFixedMaxContent" id="lessConstrainedFixedMaxContentGrid">
217         <div class="firstRowFirstColumn">XXX XXX XXX XXX XXX XXX XXX XXX XXX</div>
218         <div class="firstRowFirstColumn">XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX</div>
219         <div class="firstRowFirstColumn">XX XX XX XX XX XX</div>
220     </div>
221 </div>
222
223 </body>
224 </html>