diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index 61be299c695..f34a1139bc2 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -67,6 +67,7 @@ struct TableLayout<'a> { row_sizes: Vec, row_baselines: Vec, cells_laid_out: Vec>>, + basis_for_cell_padding_percentage: Au, } #[derive(Clone, Debug)] @@ -98,6 +99,7 @@ impl<'a> TableLayout<'a> { row_sizes: Vec::new(), row_baselines: Vec::new(), cells_laid_out: Vec::new(), + basis_for_cell_padding_percentage: Au::zero(), } } @@ -167,9 +169,15 @@ impl<'a> TableLayout<'a> { .max(max_size.inline.min(size.inline)) }; - let pbm = cell.style.padding_border_margin(containing_block); - outer_min_content_width += pbm.padding_border_sums.inline; - outer_max_content_width += pbm.padding_border_sums.inline; + let inline_padding_border_sum = Au::from( + cell.style + .padding(writing_mode) + .percentages_relative_to(Length::zero()) + .inline_sum() + + cell.style.border_width(writing_mode).inline_sum(), + ); + outer_min_content_width += inline_padding_border_sum; + outer_max_content_width += inline_padding_border_sum; row_measures[column_index] = CellOrColumnMeasure { content_sizes: ContentSizes { @@ -578,6 +586,10 @@ impl<'a> TableLayout<'a> { // > border spacing (if any). This is the width that we will be able to allocate to the // > columns. self.assignable_width = used_width_of_table - inline_border_spacing; + + // This is the amount that we will use to resolve percentages in the padding of cells. + // It matches what Gecko and Blink do, though they disagree when there is a big caption. + self.basis_for_cell_padding_percentage = used_width_of_table - border_spacing.inline * 2; } /// Distribute width to columns, performing step 2.4 of table layout from @@ -897,7 +909,7 @@ impl<'a> TableLayout<'a> { let padding = cell .style .padding(containing_block.style.writing_mode) - .percentages_relative_to(Length::zero()); + .percentages_relative_to(self.basis_for_cell_padding_percentage.into()); let inline_border_padding_sum = border.inline_sum() + padding.inline_sum(); let mut total_width: CSSPixelLength = Length::from(total_width) - inline_border_padding_sum; diff --git a/tests/wpt/meta-legacy-layout/css/css-tables/tentative/padding-percentage.html.ini b/tests/wpt/meta-legacy-layout/css/css-tables/tentative/padding-percentage.html.ini new file mode 100644 index 00000000000..ac05593227d --- /dev/null +++ b/tests/wpt/meta-legacy-layout/css/css-tables/tentative/padding-percentage.html.ini @@ -0,0 +1,2 @@ +[padding-percentage.html] + expected: FAIL diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 367808cd900..ba9de8f73b6 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -243079,6 +243079,19 @@ ] ], "tentative": { + "padding-percentage.html": [ + "67f8009de365a32275232b5c5b008072a0c8fc17", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], "paint": { "background-image-column-collapsed.html": [ "6e6ae7a82cfd04c09989dcea682744eb79e982a7", diff --git a/tests/wpt/tests/css/css-tables/tentative/padding-percentage.html b/tests/wpt/tests/css/css-tables/tentative/padding-percentage.html new file mode 100644 index 00000000000..67f8009de36 --- /dev/null +++ b/tests/wpt/tests/css/css-tables/tentative/padding-percentage.html @@ -0,0 +1,108 @@ + + + + + + + +

Test passes if there is a filled green square and no red.

+ + + + +
+
+
+ + + + + +
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+ + + + + + + +
+
+
+
+
+
+
+
+