From 6f414df867cb8aea02dbc7009000096c17eeb3ab Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Mon, 10 Jun 2024 11:26:46 +0200 Subject: [PATCH] Fix and unify 'span' attribute for table columns (#32467) The attribute was only taken into account on columns that are immediate children of tables, and on column groups. It was ignored on columns within column groups. This patch moves the logic into a helper function that is then called from the three consumers. --- components/layout_2020/table/construct.rs | 75 ++++++++++--------- .../background-applies-to-006.xht.ini | 2 - .../background-color-applies-to-006.xht.ini | 2 - .../background-image-applies-to-006.xht.ini | 2 - ...background-position-applies-to-006.xht.ini | 2 - ...ackground-position-applies-to-006a.xht.ini | 2 - .../background-repeat-applies-to-006.xht.ini | 2 - .../box-display/containing-block-029.xht.ini | 2 - .../css/CSS2/box-display/display-013.xht.ini | 2 - .../css/CSS2/css1/c414-flt-fit-000.xht.ini | 2 - .../vertical-align-baseline-003.xht.ini | 2 - .../normal-flow/width-applies-to-006.xht.ini | 2 - .../tables/fixed-table-layout-017.xht.ini | 2 - .../tables/fixed-table-layout-018.xht.ini | 2 - .../tables/fixed-table-layout-019.xht.ini | 2 - .../tables/fixed-table-layout-020.xht.ini | 2 - .../tables/fixed-table-layout-021.xht.ini | 2 - .../tables/fixed-table-layout-022.xht.ini | 2 - .../tables/fixed-table-layout-023.xht.ini | 2 - ...l-change-span-bg-invalidation-001.html.ini | 2 - .../visibility-collapse-col-005.html.ini | 3 - .../visibility-collapse-rowcol-002.html.ini | 3 - 22 files changed, 41 insertions(+), 78 deletions(-) delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-color-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-image-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006a.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/backgrounds/background-repeat-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/box-display/containing-block-029.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/box-display/display-013.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/css1/c414-flt-fit-000.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/linebox/vertical-align-baseline-003.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/normal-flow/width-applies-to-006.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-017.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-018.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-019.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-020.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-021.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-022.xht.ini delete mode 100644 tests/wpt/meta/css/CSS2/tables/fixed-table-layout-023.xht.ini delete mode 100644 tests/wpt/meta/css/css-tables/paint/col-change-span-bg-invalidation-001.html.ini delete mode 100644 tests/wpt/meta/css/css-tables/visibility-collapse-col-005.html.ini delete mode 100644 tests/wpt/meta/css/css-tables/visibility-collapse-rowcol-002.html.ini diff --git a/components/layout_2020/table/construct.rs b/components/layout_2020/table/construct.rs index ac689c951e1..fd2441daf18 100644 --- a/components/layout_2020/table/construct.rs +++ b/components/layout_2020/table/construct.rs @@ -777,20 +777,12 @@ where ::std::mem::forget(box_slot) }, DisplayLayoutInternal::TableColumn => { - let span = info - .node - .and_then(|node| node.to_threadsafe().get_span()) - .unwrap_or(1) - .min(1000); - - for _ in 0..span + 1 { - self.builder.table.columns.push(TableTrack { - base_fragment_info: info.into(), - style: info.style.clone(), - group_index: None, - is_anonymous: false, - }) - } + add_column( + &mut self.builder.table.columns, + info, + None, /* group_index */ + false, /* is_anonymous */ + ); // We are doing this until we have actually set a Box for this `BoxSlot`. ::std::mem::forget(box_slot) @@ -810,20 +802,11 @@ where let first_column = self.builder.table.columns.len(); if column_group_builder.columns.is_empty() { - let span = info - .node - .and_then(|node| node.to_threadsafe().get_span()) - .unwrap_or(1) - .min(1000) as usize; - - self.builder.table.columns.extend( - repeat(TableTrack { - base_fragment_info: info.into(), - style: info.style.clone(), - group_index: Some(column_group_index), - is_anonymous: true, - }) - .take(span), + add_column( + &mut self.builder.table.columns, + info, + Some(column_group_index), + true, /* is_anonymous */ ); } else { self.builder @@ -1068,12 +1051,12 @@ where ) { return; } - self.columns.push(TableTrack { - base_fragment_info: info.into(), - style: info.style.clone(), - group_index: Some(self.column_group_index), - is_anonymous: false, - }); + add_column( + &mut self.columns, + info, + Some(self.column_group_index), + false, /* is_anonymous */ + ); } } @@ -1088,3 +1071,27 @@ impl From for TableTrackGroupType { } } } + +fn add_column<'dom, Node>( + collection: &mut Vec, + column_info: &NodeAndStyleInfo, + group_index: Option, + is_anonymous: bool, +) where + Node: NodeExt<'dom>, +{ + let span = column_info + .node + .and_then(|node| node.to_threadsafe().get_span()) + .map_or(1, |span| span.min(1000) as usize); + + collection.extend( + repeat(TableTrack { + base_fragment_info: column_info.into(), + style: column_info.style.clone(), + group_index, + is_anonymous, + }) + .take(span), + ); +} diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-applies-to-006.xht.ini deleted file mode 100644 index b07107ebe15..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-color-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-color-applies-to-006.xht.ini deleted file mode 100644 index 7ca436d83ef..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-color-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-color-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-image-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-image-applies-to-006.xht.ini deleted file mode 100644 index 99601a2c080..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-image-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-image-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006.xht.ini deleted file mode 100644 index a34a3b0ff2a..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-position-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006a.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006a.xht.ini deleted file mode 100644 index ed6072d2f93..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-position-applies-to-006a.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-position-applies-to-006a.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/backgrounds/background-repeat-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/backgrounds/background-repeat-applies-to-006.xht.ini deleted file mode 100644 index 6bf74bc9290..00000000000 --- a/tests/wpt/meta/css/CSS2/backgrounds/background-repeat-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-repeat-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/box-display/containing-block-029.xht.ini b/tests/wpt/meta/css/CSS2/box-display/containing-block-029.xht.ini deleted file mode 100644 index 652b2c6aaeb..00000000000 --- a/tests/wpt/meta/css/CSS2/box-display/containing-block-029.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[containing-block-029.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/box-display/display-013.xht.ini b/tests/wpt/meta/css/CSS2/box-display/display-013.xht.ini deleted file mode 100644 index 1062e603d52..00000000000 --- a/tests/wpt/meta/css/CSS2/box-display/display-013.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[display-013.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/css1/c414-flt-fit-000.xht.ini b/tests/wpt/meta/css/CSS2/css1/c414-flt-fit-000.xht.ini deleted file mode 100644 index 7ba830b51dd..00000000000 --- a/tests/wpt/meta/css/CSS2/css1/c414-flt-fit-000.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[c414-flt-fit-000.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/linebox/vertical-align-baseline-003.xht.ini b/tests/wpt/meta/css/CSS2/linebox/vertical-align-baseline-003.xht.ini deleted file mode 100644 index f100b74e713..00000000000 --- a/tests/wpt/meta/css/CSS2/linebox/vertical-align-baseline-003.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[vertical-align-baseline-003.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/normal-flow/width-applies-to-006.xht.ini b/tests/wpt/meta/css/CSS2/normal-flow/width-applies-to-006.xht.ini deleted file mode 100644 index 2acc68dac95..00000000000 --- a/tests/wpt/meta/css/CSS2/normal-flow/width-applies-to-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[width-applies-to-006.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-017.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-017.xht.ini deleted file mode 100644 index 67eeb2283f6..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-017.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-017.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-018.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-018.xht.ini deleted file mode 100644 index 12249988f34..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-018.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-018.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-019.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-019.xht.ini deleted file mode 100644 index aa137e60d59..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-019.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-019.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-020.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-020.xht.ini deleted file mode 100644 index a2104178ed0..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-020.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-020.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-021.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-021.xht.ini deleted file mode 100644 index 1d280301286..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-021.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-021.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-022.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-022.xht.ini deleted file mode 100644 index 1c2dec056d2..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-022.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-022.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-023.xht.ini b/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-023.xht.ini deleted file mode 100644 index a79a648b47d..00000000000 --- a/tests/wpt/meta/css/CSS2/tables/fixed-table-layout-023.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[fixed-table-layout-023.xht] - expected: FAIL diff --git a/tests/wpt/meta/css/css-tables/paint/col-change-span-bg-invalidation-001.html.ini b/tests/wpt/meta/css/css-tables/paint/col-change-span-bg-invalidation-001.html.ini deleted file mode 100644 index 5bd57809dac..00000000000 --- a/tests/wpt/meta/css/css-tables/paint/col-change-span-bg-invalidation-001.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[col-change-span-bg-invalidation-001.html] - expected: FAIL diff --git a/tests/wpt/meta/css/css-tables/visibility-collapse-col-005.html.ini b/tests/wpt/meta/css/css-tables/visibility-collapse-col-005.html.ini deleted file mode 100644 index 98aed8b9e60..00000000000 --- a/tests/wpt/meta/css/css-tables/visibility-collapse-col-005.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[visibility-collapse-col-005.html] - [col visibility:collapse changes table width] - expected: FAIL diff --git a/tests/wpt/meta/css/css-tables/visibility-collapse-rowcol-002.html.ini b/tests/wpt/meta/css/css-tables/visibility-collapse-rowcol-002.html.ini deleted file mode 100644 index 5ae403b640f..00000000000 --- a/tests/wpt/meta/css/css-tables/visibility-collapse-rowcol-002.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[visibility-collapse-rowcol-002.html] - [spanning row visibility:collapse doesn't change table width] - expected: FAIL