html5-table-formatting-3.html (5388B)
1 <!doctype html> 2 <script src='/resources/testharness.js'></script> 3 <script src='/resources/testharnessreport.js'></script> 4 <link rel='stylesheet' href='./support/base.css' /> 5 <link rel="help" href="https://drafts.csswg.org/css-tables-3/#missing-cells-fixup"> 6 <link rel="help" href="https://drafts.csswg.org/css-tables-3/#dimensioning-the-row-column-grid"> 7 <main> 8 9 <h1>HTML5 Table Formatting algorithm (row/column grid computation)</h1> 10 <p>Verifies how browsers deal with implicit tracks from which no cell does originate</p> 11 12 <hr/> 13 <p>This should be a 100px by 100px blue square:</p> 14 <p>The table grid is 1x1, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p> 15 <p>The consecutive tracks were merged together because they are not all defined explicitely by a table-column or a table-row, and share the same set of cells</p> 16 <p>Two 25px border-spacing causes the addition of 50px (track is 50x50)</p> 17 <x-table style="background: blue; border-spacing: 25px"> 18 <x-tr><x-td style="padding: 25px"></x-td></x-tr> 19 </x-table> 20 21 <hr/> 22 <p>This should be a 100px by 100px blue square:</p> 23 <p>The table grid is 1x1, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p> 24 <p>The consecutive tracks were merged together because they are not all defined explicitely by a table-column or a table-row, and share the same set of cells</p> 25 <p>Two 25px border-spacing causes the addition of 50px (track is 50x50)</p> 26 <x-table style="background: blue; border-spacing: 25px"> 27 <x-tr><x-td style="padding: 25px" rowspan=2 colspan=2></x-td></x-tr> 28 </x-table> 29 30 <hr/> 31 <p>This should be a 75px by 75px blue square:</p> 32 <p>The table grid is 2x2, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p> 33 <p>The consecutive tracks were not merged together because they are all defined explicitely by a table-column or a table-row</p> 34 <p>Three 25px border-spacing causes the addition of 75px (tracks are 0x0)</p> 35 <x-table style="background: blue; border-spacing: 25px"> 36 <x-col></x-col> 37 <x-col></x-col> 38 <x-tr><x-td style="padding: 0px" rowspan=2 colspan=2></x-td></x-tr> 39 <x-tr></x-tr> 40 </x-table> 41 42 <hr/> 43 <p>This should be a 100px by 100px blue square:</p> 44 <p>The table grid is 2x2, so the table is not empty and follows step 3A of the table layout algorithm (which adds anonymous cell boxes)</p> 45 <p>The consecutive tracks were not merged together because they are all defined explicitely by a table-column or a table-row</p> 46 <p>Three 25px border-spacing causes the addition of 75px (tracks are 12.5x12.5)</p> 47 <x-table style="background: blue; border-spacing: 25px"> 48 <x-col></x-col> 49 <x-col></x-col> 50 <x-tr><x-td style="padding: 25px" rowspan=2 colspan=2></x-td></x-tr> 51 <x-tr></x-tr> 52 </x-table> 53 54 </main> 55 56 <script> 57 while(true) { 58 var xtd = document.querySelector('x-td[rowspan], x-td[colspan]'); if(!xtd) break; 59 var td = document.createElement('td'); for(var i = xtd.attributes.length; i--;) { td.setAttribute(xtd.attributes[i].name,xtd.attributes[i].value) } 60 xtd.parentNode.replaceChild(td,xtd); 61 } 62 63 document.body.onload = () => { 64 generate_tests(assert_equals, [ 65 [ 66 "Control test for table-cell padding and border-spacing, etc (width)", 67 document.querySelector("x-table:nth-of-type(1)").offsetWidth, 68 100 69 ], 70 [ 71 "Control test for table-cell padding and border-spacing (height)", 72 document.querySelector("x-table:nth-of-type(1)").offsetHeight, 73 100 74 ], 75 [ 76 "Anonymous consecutive columns spanned by the same set of cells are merged", 77 document.querySelector("x-table:nth-of-type(2)").offsetWidth, 78 100 79 ], 80 [ 81 "Anonymous consecutive rows spanned by the same set of cells are merged", 82 document.querySelector("x-table:nth-of-type(2)").offsetHeight, 83 100 84 ], 85 [ 86 "Explicitely-defined consecutive columns spanned by the same set of cells are not merged", 87 document.querySelector("x-table:nth-of-type(3)").offsetWidth, 88 75 89 ], 90 [ 91 "Explicitely-defined consecutive rows spanned by the same set of cells are not merged", 92 document.querySelector("x-table:nth-of-type(3)").offsetHeight, 93 75 94 ], 95 [ 96 "Explicitely-defined consecutive columns spanned by the same set of cells are not merged, and cells span across border-spacing", 97 document.querySelector("x-table:nth-of-type(4) x-col").getBoundingClientRect().width, 98 12.5 99 ], 100 [ 101 "Explicitely-defined consecutive rows spanned by the same set of cells are not merged, and cells span across border-spacing", 102 document.querySelector("x-table:nth-of-type(4) x-tr").getBoundingClientRect().height, 103 12.5 104 ], 105 ]) 106 } 107 </script>