servo: Merge #14798 - Fix rowspan handling for rows that span to the end of the rowgroup (from mbrubeck:rowgroup); r=notriddle
authorMatt Brubeck <mbrubeck@limpet.net>
Fri, 30 Dec 2016 21:56:00 -0800
changeset 340452 29665644bcb8aa09ca9ea4648caf97a677860d6a
parent 340451 0fdf16676d2756ffa2d54f5cbc7fd6cb752f1835
child 340453 4308461871cdc0a98b57761d749dc8c1118f08a3
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnotriddle
servo: Merge #14798 - Fix rowspan handling for rows that span to the end of the rowgroup (from mbrubeck:rowgroup); r=notriddle This fixes `rowspan="0"` to behave as described in [the HTML spec](https://html.spec.whatwg.org/multipage/tables.html#attributes-common-to-td-and-th-elements): > For this attribute, the value zero means that the cell is to span all the remaining rows in the row group. It also prevents any `rowspan` from overlapping into another rowgroup, as required by [HTML § 4.9.12](https://html.spec.whatwg.org/multipage/tables.html#table-processing-model): > Row groups cannot overlap each other. Similarly, column groups cannot overlap each other. A cell cannot cover slots that are from two or more row groups. r? @notriddle or @pcwalton --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ Source-Repo: https://github.com/servo/servo Source-Revision: c2ac495188efb5d2af75a0158a5f72614d5f6062
servo/components/layout/table_row.rs
--- a/servo/components/layout/table_row.rs
+++ b/servo/components/layout/table_row.rs
@@ -747,16 +747,17 @@ pub fn propagate_column_inline_sizes_to_
         border_spacing: &border_spacing::T,
         incoming_rowspan: &mut Vec<u32>) {
     // If the child is a row group or a row, the column inline-size and rowspan info should be copied from its
     // parent.
     //
     // FIXME(pcwalton): This seems inefficient. Reference count it instead?
     match child_flow.class() {
         FlowClass::TableRowGroup => {
+            incoming_rowspan.clear();
             let child_table_rowgroup_flow = child_flow.as_mut_table_rowgroup();
             child_table_rowgroup_flow.spacing = *border_spacing;
             for kid in child_table_rowgroup_flow.block_flow.base.child_iter_mut() {
                 propagate_column_inline_sizes_to_child(kid,
                                                        table_writing_mode,
                                                        column_computed_inline_sizes,
                                                        border_spacing,
                                                        incoming_rowspan);
@@ -784,17 +785,21 @@ pub fn propagate_column_inline_sizes_to_
                     if col < incoming_rowspan.len() && incoming_rowspan[col] > 1 {
                         incoming_rowspan[col] -= 1;
                     }
                     // If this cell spans later rows, record its rowspan.
                     if cell.row_span != 1 {
                         if incoming_rowspan.len() < col + 1 {
                             incoming_rowspan.resize(col + 1, 1);
                         }
-                        incoming_rowspan[col] = max(cell.row_span, incoming_rowspan[col]);
+                        // HTML § 4.9.11: For rowspan, the value 0 means the cell is to span all
+                        // the remaining rows in the rowgroup.
+                        if cell.row_span > incoming_rowspan[col] || cell.row_span == 0 {
+                            incoming_rowspan[col] = cell.row_span;
+                        }
                     }
                     col += 1;
                 }
             }
         }
         c => warn!("unexpected flow in table {:?}", c)
     }
 }