From 58640317a83e544daa8f6532a491131a17c9d708 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Tue, 5 Mar 2024 20:43:35 +0100 Subject: [PATCH] Feedback --- components/layout_2020/table/layout.rs | 41 +++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index 990f28bb5e72..ac1547f5336d 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -630,12 +630,7 @@ impl<'a> TableLayout<'a> { // TODO: GRIDMAX should never be smaller than GRIDMIN! grid_min_max.max_content = grid_min_max.max_content.max(grid_min_max.min_content); - let border_spacing = self.table.border_spacing(); - let inline_border_spacing = if self.table.size.width > 0 { - border_spacing.inline * (self.table.size.width as i32 + 1) - } else { - Au::zero() - }; + let inline_border_spacing = self.table.total_border_spacing().inline; grid_min_max.min_content += inline_border_spacing; grid_min_max.max_content += inline_border_spacing; grid_min_max @@ -682,21 +677,15 @@ impl<'a> TableLayout<'a> { }, }; - let border_spacing = self.table.border_spacing(); - let inline_border_spacing = if self.table.size.width > 0 { - border_spacing.inline * (self.table.size.width as i32 + 1) - } else { - Au::zero() - }; - // > The assignable table width is the used width of the table minus the total horizontal // > 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; + self.assignable_width = used_width_of_table - self.table.total_border_spacing().inline; // 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; + self.basis_for_cell_padding_percentage = + used_width_of_table - self.table.border_spacing().inline * 2; } /// Distribute width to columns, performing step 2.4 of table layout from @@ -1362,11 +1351,7 @@ impl<'a> TableLayout<'a> { } .auto_is(Au::zero); - let block_border_spacing = if self.table.size.height > 0 { - self.table.border_spacing().block * (self.table.size.height as i32 + 1) - } else { - Au::zero() - }; + let block_border_spacing = self.table.total_border_spacing().block; let table_height_from_rows = row_sizes.iter().sum::() + block_border_spacing; self.final_table_height = table_height_from_rows.max(table_height_from_style); @@ -1722,6 +1707,22 @@ impl Table { } } + fn total_border_spacing(&self) -> LogicalVec2 { + let border_spacing = self.border_spacing(); + LogicalVec2 { + inline: if self.size.width > 0 { + border_spacing.inline * (self.size.width as i32 + 1) + } else { + Au::zero() + }, + block: if self.size.height > 0 { + border_spacing.block * (self.size.height as i32 + 1) + } else { + Au::zero() + }, + } + } + pub(crate) fn inline_content_sizes( &mut self, layout_context: &LayoutContext,