summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-tables/tentative/rowspan-height-redistribution.html
blob: 364ae321c901b073d5eba9655b8481089a3b2f01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!doctype html>
<title>ROWSPAN redistribution</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src="/resources/check-layout-th.js"></script>
<link rel="stylesheet" type="text/css" href="./support/table-tentative.css">
<link rel="author" title="Aleks Totic" href="atotic@chromium.org" />
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#row-layout" />
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4418" />
<style>
  main table {
    margin-top: 8px;
    border-collapse: collapse;
    background: rgba(0,0,255,0.1);
    background-image: linear-gradient(45deg, #DDD 25%, transparent 25%), linear-gradient(-45deg, #DDD 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #DDD 75%), linear-gradient(-45deg, transparent 75%, #DDD 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  }
  .sizer {
    width: 30px;
    height: 100px;
  }
  main tbody tr:nth-child(odd) {
    background: rgba(255,255,0,1.0);
  }
  main tbody tr:nth-child(even) {
    background: rgba(255,165,0,1.0);
  }
  main td div {
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.5) 0%, rgba(0,255,0,0.7) 100%);
  }
  main .td-padding td {
    padding: 2px;
  }
  main .td-padding-xl td {
    padding: 10px;
  }
</style>
<main>
<h1>ROWSPAN > 1 to row distribution</h1>
<p>The algorithm has not been standardized. This is my understanding of how it works.</p>
<ol>
  <li>rowspan>1 TDs are sorted:</li>
    <ol>
      <li>If TD span the same rows, taller TD is distributed first.</li>
      <li>If one TD is fully enclosed by another, inner TD is distributed first.</li>
      <li>Otherwise, higher TD is distributed first.</li>
    </ol>
  <li>Each rowspan>1 TD's height is distributed as following</li>
    <ol>
      <li>rowspan > 1 TDs have height TDh, span N rows. N rows have total height of Rh. TDh - Rh height, Dh, must be distributed as follows.</li>
      <li>If percentage resolution size is available (this happens when redistributiong table/section height), percentage rows grow to their percentage size, proportional to (percentage size - current size). Dh shrinks by distributed height. Justification: explicit percentage rows should grow to their percentage.</li>
      <li>Rows that originate rowspan>1 cells get all the Dh height, distributed evenly. Justification: rowspan>1 rows are likely to need to grow later. If there are multiple rowspan>1 cells, there can be multiple originating rows.</li>
      <li>Unconstrained non-empty rows grow, proportional to their existing height.</li>
      <li>If all rows are empty, last row gets all the height. Justification: ???</li>
      <li>Contstrained rows grow in proportion to current height.</li>
    </ol>
  </ol>
<p class="error">It is unclear what the existing ChromeLegacy/FF algorithms do for distribution over rowspan>1 and empty cells. <a href="https://dxr.mozilla.org/mozilla-central/source/layout/tables/nsTableRowGroupFrame.cpp#509">FF special cases</a> "there is no cell originating in the row with owspan=1 and there are at least 2 cells spanning the row. Chrome Legacy also tries to do something similar, but they disagree on what. TablesNG will try to ship without special cases.</p>
 <p class="error">Safari fails most of these tests</p>
<p>Color scheme</p>
<table>
  <tr>
    <td>odd rows are yellow</td>
  </tr>
  <tr>
    <td>even rows are orange</td>
  </tr>
  <tr>
    <td><div style="height:50px">inner divs have a green gradient</div>
    </td>
  </tr>
  <tr>
    <td>row</td>
  </tr>
  <tr>
    <td>row</td>
  </tr>
 <tr>
    <td>row</td>
  </tr>
  <tr>
    <td>row</td>
  </tr>

</table>
<h2>Unconstrained rows</h2>
 <p>Rows whose height is not fixed or percent are unconstrained.</p>
<p class="testdesc">Unconstrained rows
Unconstrained rows are redistributed proportionally. Rows are constrained if their height is fixed, or percent.</p>
<table>
  <tbody>
    <tr data-expected-height="50">
      <td>0,0</td>
      <td rowspan="2"><div class="sizer"></div></td>
    </tr>
    <tr data-expected-height="50">
      <td>0,1</td>
    </tr>
</table>

<p class="testdesc">Unconstrained rows with zero height do not grow.</p>
<table>
  <tbody>
    <tr data-expected-height="50">
      <td>0,0</td>
      <td rowspan="3"><div class="sizer"></div></td>
    </tr>
    <tr data-expected-height="0">
    </tr>
    <tr data-expected-height="50">
      <td>0,2</td>
    </tr>
</table>

<p class="testdesc">rowspan>1 is zero height, spanned rows have height.</p>
<table>
  <tbody>
    <tr data-expected-height="0">
      <td></td>
      <td rowspan="3"><div class="sizer"></div></td>
      <td></td>
    </tr>
    <tr data-expected-height="50">
      <td>1,0</td>
      <td></td>
    </tr>
    <tr data-expected-height="50">
      <td>2,0</td>
      <td></td>
    </tr>
</table>

<p class="testdesc">Unconstrained rows are redistributed proportionally to heights</p>
<table>
  <tbody>
    <tr data-expected-height="75">
      <td><div style="height:45px">0,0</div></td>
      <td rowspan="2"><div class="sizer"></div></td>
    </tr>
    <tr data-expected-height="25">
      <td><div style="height:15px">0,1</div></td>
    </tr>
</table>

<h2>Fixed rows</h2>

<p class="testdesc">Constrained fixed rows
do not grow if there are unconstrained ones</p>
<p class="error">Edge grows constrained rows too</p>
<table>
  <tbody>
    <tr style="height: 30px" data-expected-height="30">
      <td>0,0 30px</td>
      <td rowspan="2"><div class="sizer"></div></td>
    </tr>
    <tr data-expected-height="70">
      <td>0,1</td>
    </tr>
</table>

<p class="testdesc"> Constrained fixed rows
grow proportionally to their size if there are no unconstrained rows</p>
<table>
  <tbody>
    <tr style="height: 20px" data-expected-height="25">
      <td>20</div></td>
      <td rowspan="3"><div class="sizer"></div></td>
    </tr>
    <tr style="height: 20px" data-expected-height="25">
      <td>20</td>
    </tr>
    <tr style="height: 40px" data-expected-height="50">
      <td>40</td>
    </tr>
</table>

<h2>Percent rows</h2>

<p class="testdesc">Constrained percent rows
grow like unconstrained ones when percent resolution size is undefined.</p>
<p class="error">FF always treats percent rows as constrained. Chrome legacy does resolve percentage against final height of the table. I do not think that can work. Edge follows NG.</p>
<table>
  <tbody>
    <tr style="height: 30%" data-expected-height="50">
      <td>0,0 30%</td>
      <td rowspan="2"><div class="sizer"></div></td>
    </tr>
    <tr data-expected-height="50">
      <td>0,1</td>
    </tr>
    <tr style="height:100px"><td>100px</td></tr>
</table>


<p class="testdesc">Percent rows with zero height
do not grow.</p>
<p class="error">Legacy Chrome has a strange gap between rows</p>
<table>
  <tbody>
    <tr data-expected-height="50">
      <td>0,0</td>
      <td rowspan="3"><div class="sizer"></div></td>
    </tr>
    <tr style="height:10%;background:red" data-expected-height="0">
    </tr>
    <tr data-expected-height="50">
      <td>2,0</td>
    </tr>
</table>

<h2>Order of rowspan distribution</h2>


<p class="testdesc">If cells span the same rows, bigger cell is distributed first
Not sure how to test this, I think it is just an optimization, there is no observable effect.
<p class="error">FF and Legacy Chrome unexpectedly distribute height evenly between rows in the first test case. Edge and TablesNG do not.</p>
<table>
  <tr data-expected-height=0>
    <td rowspan=3><div style="height:50px"></div></td>
    <td rowspan=3><div style="height:99px"></div></td>
  </tr>
  <tr data-expected-height=0>
  </tr>
  <tr data-expected-height=99>
  </tr>
  <tr>
    <td>bottom</td>
    <td>bottom</td>
  </tr>
</table>
<table>
  <tr data-expected-height=0>
    <td rowspan=3><div style="height:50px"></div></td>
    <td rowspan=3><div style="height:99px"></div></td>
    <td style="width:20px"></td>
  </tr>
  <tr data-expected-height=0>
    <td></td>
  </tr>
  <tr data-expected-height=99>
    <td></td>
  </tr>
  <tr>
    <td>bottom</td>
    <td>bottom</td>
  </tr>
</table>
<table>
  <tr data-expected-height=0>
    <td rowspan=3><div style="height:99px;width:20px"></div></td>
  </tr>
  <tr></tr>
  <tr data-expected-height=99></tr>
 <tr>
    <td>bottom</td>
    <td>bottom</td>
  </tr>
</table>


<p class="testdesc">If one cell is fully enclosed by another, inner cell wins.
<p class="error">Not in Edge</p>
<table>
  <tr data-expected-height=0>
    <td rowspan=4><div style="height:50px;width:20px"></div></td>
    <td></td>
  <tr data-expected-height=0>
    <td></td>
    <td rowspan=2><div style="height:100px;width:20px"></div></td>
  </tr>
  <tr data-expected-height=100></tr>
  <tr data-expected-height=0></tr>
</tr>
</table>

<p class="testdesc">First row wins.
rowspan-4 distributes 50 to last empty row, row3. rowspan-3 distributes 100px to only nonempty row, row3.
<p class="error">Edge disagrees here.</p>
<table>
  <tr data-expected-height=0>
    <td rowspan=4><div style="height:50px;width:20px"></div></td>
    <td></td>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=100>
    <td></td>
    <td rowspan=3><div style="height:100px;width:20px"></div></td>
  </tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
</tr>
</table>

<h2>Rowspan distribution over empty rows.</h2>

<p class="testdesc">Rowspans that span non-existent rows
Span is truncated so only existing rows are spanned.</p>
<table>
  <tbody data-expected-height="100">
    <tr>
      <td data-expected-height="50">0,0</td>
      <td data-expected-height="100" rowspan="5"><div style="height:100px;">rowspan 5</div></td>
    </tr>
    <tr>
      <td data-expected-height="50">1,0</td>
    </tr>
    <tr data-expected-height="0"></tr>
  </tbody>
  <tbody>
    <tr>
      <td>body 2</td>
    </tr>
  </tbody>
</table>

<p class="testdesc">Rowspan spans only empty rows
Last spanned row gets all the height.
<p class="error">Edge distributes height to all empty rows, not just last.</p>
<table>
  <tr>
    <td>first row</td>
  </tr>
  <tr data-expected-height=0>
    <td></td>
    <td rowspan=5><div style="height:100px;width:30px;"></div></td>
  </tr>
  <tr data-expected-height=0><td></td></tr>
  <tr data-expected-height=0><td></td></tr>
  <tr data-expected-height=0><td></td></tr>
  <tr data-expected-height=100><td></td></tr>
  <tr>
    <td>last row</td>
  </tr>
</table>

<p class="testdesc">TD is not considered empty if it has padding, but no content
<table>
  <tr>
    <td>first row</td>
  </tr>
  <tr data-expected-height=0>
    <td></td>
    <td style="height:100px" rowspan=3></td>
  </tr>
  <tr data-expected-height=100><td style="padding:2px"></td></tr>
  <tr data-expected-height=0></tr>
  <tr>
    <td>last row</td>
  </tr>
</table>

<p class="testdesc">row with an empty tall cell is not considered empty.
<p class="error">
<table>
  <tr>
    <td rowspan=5><div style="height:100px">rowspan</div></td>
    <td></td>
    <td></td>
  </tr>
  <tr data-expected-height=100>
    <td rowspan=5></td>
    <td></td>
  </tr>
  <tr></tr>
  <tr></tr>
  <tr></tr>
  <tr></tr>
</table>

<p class="testdesc">Empty rows with border-spacing big enough for rowspan cell
rows are 0 height, cell spans the entire table.
<table style="border-spacing:20px;border-collapse:separate " data-expected-height=100>
  <tr data-expected-height=0>
    <td rowspan=4><div style="height:60px;width:40px"></div></td>
  </tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
</table>

<p class="testdesc">row with a non-empty rowspan>0 cell is empty.
Distributes to all rows except start row?
<p class="error">
<table>
  <tr>
    <td rowspan=5><div style="height:100px">rowspan</div></td>
    <td></td>
  </tr>
  <tr data-expected-height=100>
    <td rowspan=5><div style="height:100px">rowspan</div></td>
  </tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
  <tr></tr>
  <tr></tr>
</table>
<table>
  <tr>
    <td rowspan=5><div style="height:100px">rowspan</div></td>
    <td></td>
  </tr>
  <tr data-expected-height=100>
    <td>yo</td>
  </tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
  <tr data-expected-height=0></tr>
</table>


<p class="testdesc">Distribution over rowspan > 1 rows
Distribution over rowspan > 1 rows

<table class="td-padding-xl" data-expected-height=360>
  <tr>
    <td rowspan=6><div style="width:50px;height:280px"></div></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr style="height:30%;background:purple">
    <td data-expected-height=20></td>
  </tr>
  <tr data-expected-height=110>
    <td rowspan=7 ></td>
  </tr>
  <tr data-expected-height=110>
    <td rowspan=17 ><div style="width:50px;height:40px"></div></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
    <tr>
    <td></td>
  </tr>
    <tr>
    <td></td>
  </tr>
</table>

<p class="testdesc">Distribution of table height over rowspan > 1 rows
If there are any unconstrained non-empty rows, they get it.
When all rows are empty, last row takes it</p>
<table class="td-padding-xl" style="height:460px">
  <tr>
    <td rowspan=6><div style="width:50px;height:280px" data-expected-height=280></div></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr style="height:30%;background:purple" data-expected-height=120>
    <td ></td>
  </tr>
  <tr data-expected-height=110>
    <td rowspan=7 ></td>
  </tr>
  <tr data-expected-height=110>
    <td rowspan=17><div style="width:50px;height:40px"></div></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
    <tr>
    <td></td>
  </tr>
    <tr>
    <td></td>
  </tr>
</table>

<p class="testdesc">Distribution of rowspan over percentage rows
Percentage rows are considered empty if they cannot resolve</p>
<table>
  <tbody>
    <tr style="height:20%">
      <td rowspan=3><div style="height:100px;width:100px"></div></td>
      <td></td>
    </tr>
    <tr style="height:30%">
      <td></td>
    </tr>
    <tr data-expected-height=100 style="height:50%">
      <td></td>
    </tr>
  </tbody>
</table>

</main>
<script>
  checkLayout("table");
</script>