mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Ignore border-spacing for tables with zero cells
This commit is contained in:
parent
32b9c0962b
commit
cad5d8b670
5 changed files with 50 additions and 8 deletions
|
@ -202,6 +202,14 @@ impl TableFlow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn total_horizontal_spacing(&self) -> Au {
|
||||||
|
let num_columns = self.column_intrinsic_inline_sizes.len();
|
||||||
|
if num_columns == 0 {
|
||||||
|
return Au(0);
|
||||||
|
}
|
||||||
|
self.spacing().horizontal * (num_columns as i32 + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Flow for TableFlow {
|
impl Flow for TableFlow {
|
||||||
|
@ -396,9 +404,8 @@ impl Flow for TableFlow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let spacing = self.spacing().horizontal *
|
computation.surrounding_size = computation.surrounding_size +
|
||||||
(self.column_intrinsic_inline_sizes.len() as i32 + 1);
|
self.total_horizontal_spacing();
|
||||||
computation.surrounding_size = computation.surrounding_size + spacing;
|
|
||||||
|
|
||||||
self.block_flow.base.intrinsic_inline_sizes = computation.finish()
|
self.block_flow.base.intrinsic_inline_sizes = computation.finish()
|
||||||
}
|
}
|
||||||
|
@ -435,8 +442,7 @@ impl Flow for TableFlow {
|
||||||
let inline_end_content_edge = self.block_flow.fragment.border_padding.inline_end;
|
let inline_end_content_edge = self.block_flow.fragment.border_padding.inline_end;
|
||||||
let padding_and_borders = self.block_flow.fragment.border_padding.inline_start_end();
|
let padding_and_borders = self.block_flow.fragment.border_padding.inline_start_end();
|
||||||
let spacing_per_cell = self.spacing();
|
let spacing_per_cell = self.spacing();
|
||||||
let spacing = spacing_per_cell.horizontal *
|
let spacing = self.total_horizontal_spacing();
|
||||||
(self.column_intrinsic_inline_sizes.len() as i32 + 1);
|
|
||||||
let content_inline_size =
|
let content_inline_size =
|
||||||
self.block_flow.fragment.border_box.size.inline - padding_and_borders - spacing;
|
self.block_flow.fragment.border_box.size.inline - padding_and_borders - spacing;
|
||||||
|
|
||||||
|
@ -785,6 +791,7 @@ impl TableLikeFlow for BlockFlow {
|
||||||
// Our current border-box position.
|
// Our current border-box position.
|
||||||
let block_start_border_padding = self.fragment.border_padding.block_start;
|
let block_start_border_padding = self.fragment.border_padding.block_start;
|
||||||
let mut current_block_offset = block_start_border_padding;
|
let mut current_block_offset = block_start_border_padding;
|
||||||
|
let mut has_rows = false;
|
||||||
|
|
||||||
// At this point, `current_block_offset` is at the content edge of our box. Now iterate
|
// At this point, `current_block_offset` is at the content edge of our box. Now iterate
|
||||||
// over children.
|
// over children.
|
||||||
|
@ -795,6 +802,7 @@ impl TableLikeFlow for BlockFlow {
|
||||||
|
|
||||||
// Account for spacing or collapsed borders.
|
// Account for spacing or collapsed borders.
|
||||||
if kid.is_table_row() {
|
if kid.is_table_row() {
|
||||||
|
has_rows = true;
|
||||||
let child_table_row = kid.as_table_row();
|
let child_table_row = kid.as_table_row();
|
||||||
current_block_offset = current_block_offset +
|
current_block_offset = current_block_offset +
|
||||||
match self.fragment.style.get_inheritedtable().border_collapse {
|
match self.fragment.style.get_inheritedtable().border_collapse {
|
||||||
|
@ -843,7 +851,7 @@ impl TableLikeFlow for BlockFlow {
|
||||||
|
|
||||||
// Take border, padding, and spacing into account.
|
// Take border, padding, and spacing into account.
|
||||||
let block_end_offset = self.fragment.border_padding.block_end +
|
let block_end_offset = self.fragment.border_padding.block_end +
|
||||||
block_direction_spacing;
|
if has_rows { block_direction_spacing } else { Au(0) };
|
||||||
current_block_offset = current_block_offset + block_end_offset;
|
current_block_offset = current_block_offset + block_end_offset;
|
||||||
|
|
||||||
// Now that `current_block_offset` is at the block-end of the border box, compute the
|
// Now that `current_block_offset` is at the block-end of the border box, compute the
|
||||||
|
|
|
@ -95,8 +95,7 @@ impl TableWrapperFlow {
|
||||||
for kid in self.block_flow.base.child_iter() {
|
for kid in self.block_flow.base.child_iter() {
|
||||||
if kid.is_table() {
|
if kid.is_table() {
|
||||||
let kid_table = kid.as_table();
|
let kid_table = kid.as_table();
|
||||||
let spacing_per_cell = kid_table.spacing().horizontal;
|
spacing = kid_table.total_horizontal_spacing();
|
||||||
spacing = spacing_per_cell * (self.column_intrinsic_inline_sizes.len() as i32 + 1);
|
|
||||||
table_border_padding =
|
table_border_padding =
|
||||||
kid_table.block_flow.fragment.border_padding.inline_start_end();
|
kid_table.block_flow.fragment.border_padding.inline_start_end();
|
||||||
break
|
break
|
||||||
|
|
|
@ -86,6 +86,7 @@ flaky_cpu == append_style_a.html append_style_b.html
|
||||||
== border_radius_overlapping_a.html border_radius_overlapping_ref.html
|
== border_radius_overlapping_a.html border_radius_overlapping_ref.html
|
||||||
== border_spacing_a.html border_spacing_ref.html
|
== border_spacing_a.html border_spacing_ref.html
|
||||||
== border_spacing_auto_layout_a.html border_spacing_ref.html
|
== border_spacing_auto_layout_a.html border_spacing_ref.html
|
||||||
|
== border_spacing_empty_table.html border_spacing_empty_table_ref.html
|
||||||
== border_spacing_fixed_layout_a.html border_spacing_ref.html
|
== border_spacing_fixed_layout_a.html border_spacing_ref.html
|
||||||
== border_style_none_a.html border_style_none_b.html
|
== border_style_none_a.html border_style_none_b.html
|
||||||
== borders_a.html borders_b.html
|
== borders_a.html borders_b.html
|
||||||
|
|
19
tests/ref/border_spacing_empty_table.html
Normal file
19
tests/ref/border_spacing_empty_table.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: yellow;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-spacing: 100px;
|
||||||
|
background: darkblue;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table></table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
15
tests/ref/border_spacing_empty_table_ref.html
Normal file
15
tests/ref/border_spacing_empty_table_ref.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: yellow;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue