diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-04-28 13:53:59 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-04-28 13:53:59 -0500 |
commit | b5beebbc6280f5ff6397b6a9154b705d42d000e7 (patch) | |
tree | 1d6f648336d2dfaf3db54f7b461576444d3fb86a | |
parent | 32b9c0962b7e42ac6d298f5959f1e48d4cc99c5a (diff) | |
parent | cad5d8b670bffba22dcc324fe295178b68c59bae (diff) | |
download | servo-b5beebbc6280f5ff6397b6a9154b705d42d000e7.tar.gz servo-b5beebbc6280f5ff6397b6a9154b705d42d000e7.zip |
Auto merge of #5885 - mbrubeck:empty-table, r=pcwalton
r? @pcwalton
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5885)
<!-- Reviewable:end -->
-rw-r--r-- | components/layout/table.rs | 20 | ||||
-rw-r--r-- | components/layout/table_wrapper.rs | 3 | ||||
-rw-r--r-- | tests/ref/basic.list | 1 | ||||
-rw-r--r-- | tests/ref/border_spacing_empty_table.html | 19 | ||||
-rw-r--r-- | tests/ref/border_spacing_empty_table_ref.html | 15 |
5 files changed, 50 insertions, 8 deletions
diff --git a/components/layout/table.rs b/components/layout/table.rs index 25d17d04b8f..80edfa2742e 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -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 { @@ -396,9 +404,8 @@ impl Flow for TableFlow { } } - let spacing = self.spacing().horizontal * - (self.column_intrinsic_inline_sizes.len() as i32 + 1); - computation.surrounding_size = computation.surrounding_size + spacing; + computation.surrounding_size = computation.surrounding_size + + self.total_horizontal_spacing(); 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 padding_and_borders = self.block_flow.fragment.border_padding.inline_start_end(); let spacing_per_cell = self.spacing(); - let spacing = spacing_per_cell.horizontal * - (self.column_intrinsic_inline_sizes.len() as i32 + 1); + let spacing = self.total_horizontal_spacing(); let content_inline_size = 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. let block_start_border_padding = self.fragment.border_padding.block_start; 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 // over children. @@ -795,6 +802,7 @@ impl TableLikeFlow for BlockFlow { // Account for spacing or collapsed borders. if kid.is_table_row() { + has_rows = true; let child_table_row = kid.as_table_row(); current_block_offset = current_block_offset + match self.fragment.style.get_inheritedtable().border_collapse { @@ -843,7 +851,7 @@ impl TableLikeFlow for BlockFlow { // Take border, padding, and spacing into account. 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; // Now that `current_block_offset` is at the block-end of the border box, compute the diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 5e321382e97..a336ca55cfb 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -95,8 +95,7 @@ impl TableWrapperFlow { for kid in self.block_flow.base.child_iter() { if kid.is_table() { let kid_table = kid.as_table(); - let spacing_per_cell = kid_table.spacing().horizontal; - spacing = spacing_per_cell * (self.column_intrinsic_inline_sizes.len() as i32 + 1); + spacing = kid_table.total_horizontal_spacing(); table_border_padding = kid_table.block_flow.fragment.border_padding.inline_start_end(); break diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 635d79798de..a74da9f7fe0 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -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_spacing_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_style_none_a.html border_style_none_b.html == borders_a.html borders_b.html diff --git a/tests/ref/border_spacing_empty_table.html b/tests/ref/border_spacing_empty_table.html new file mode 100644 index 00000000000..d1ee2cc66c3 --- /dev/null +++ b/tests/ref/border_spacing_empty_table.html @@ -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> + diff --git a/tests/ref/border_spacing_empty_table_ref.html b/tests/ref/border_spacing_empty_table_ref.html new file mode 100644 index 00000000000..727795d8e38 --- /dev/null +++ b/tests/ref/border_spacing_empty_table_ref.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8"> + <style> + body { + background: yellow; + } + </style> + </head> + <body> + </body> +</html> + + |