diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-08-31 11:28:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-31 11:28:18 -0500 |
commit | f5a546a1600fe6a6761e3fd6ac1bb6c3f1a503eb (patch) | |
tree | 451284b4598b47a65c036d479b32b019b56f628e /components/layout/table.rs | |
parent | 59a0be0068cb0e06002d8c4f33491cc67187dbec (diff) | |
parent | a3af2303d6ca9f40c9c91a11fa7943328350930c (diff) | |
download | servo-f5a546a1600fe6a6761e3fd6ac1bb6c3f1a503eb.tar.gz servo-f5a546a1600fe6a6761e3fd6ac1bb6c3f1a503eb.zip |
Auto merge of #12437 - gpoesia:tr_margin_fix, r=pcwalton
Handle row borders in border collapsing logic.
<!-- Please describe your changes on the following line: -->
Handle table row border when collapsing borders for a table row. The row border is combined with the cell's border using the already implemented conflict resolution logic.
This is a screenshot of the following test:
```html
<!doctype html>
<html><body>
<style>
table {
border-collapse: collapse;
}
tr {
border: 1px solid black;
}
</style>
<table>
<tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
<tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
<tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
<tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
</table>
</body>
</html>
```
<img src="https://dl.dropboxusercontent.com/u/10962672/Screenshots%20Servo/servo_tr_border_collapse.png"/>
The top border is missing, but I think that's a different bug, since it also does not show up when the border is in the cells, and not the rows. Also, when debugging the border collapsing structures, they seem ok (the top border seems to be there). I can look at that bug in a separate issue (or in this one too if you prefer).
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11527 (github issue number if applicable).
<!-- Either: -->
- [X] These changes do not require tests because I didn't find how to automatically test it (will be happy to provide a test if there's infrastructure for this kind of test already in place).
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Fixes #11527.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12437)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/table.rs')
-rw-r--r-- | components/layout/table.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/components/layout/table.rs b/components/layout/table.rs index 96475f4a9e2..a67312d1bc3 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -311,12 +311,13 @@ impl Flow for TableFlow { &mut self.collapsed_block_direction_border_widths_for_table); previous_collapsed_block_end_borders = PreviousBlockCollapsedBorders::FromPreviousRow( - row.final_collapsed_borders.block_end.clone()) + row.final_collapsed_borders.block_end.clone()); } first_row = false - } + }; } + computation.surrounding_size = computation.surrounding_size + self.total_horizontal_spacing(); @@ -425,7 +426,7 @@ impl Flow for TableFlow { collapsed_inline_direction_border_widths_for_table, &mut collapsed_block_direction_border_widths_for_table); } - }) + }); } fn assign_block_size<'a>(&mut self, _: &'a LayoutContext<'a>) { @@ -589,7 +590,7 @@ impl ColumnIntrinsicInlineSize { /// /// TODO(pcwalton): There will probably be some `border-collapse`-related info in here too /// eventually. -#[derive(RustcEncodable, Clone, Copy)] +#[derive(RustcEncodable, Clone, Copy, Debug)] pub struct ColumnComputedInlineSize { /// The computed size of this inline column. pub size: Au, @@ -629,27 +630,21 @@ fn perform_border_collapse_for_row(child_table_row: &mut TableRowFlow, next_block_borders: NextBlockCollapsedBorders, inline_spacing: &mut Vec<Au>, block_spacing: &mut Vec<Au>) { + let number_of_borders_inline_direction = child_table_row.preliminary_collapsed_borders.inline.len(); // Compute interior inline borders. for (i, this_inline_border) in child_table_row.preliminary_collapsed_borders .inline - .iter() + .iter_mut() .enumerate() { child_table_row.final_collapsed_borders.inline.push_or_set(i, *this_inline_border); + if i == 0 { + child_table_row.final_collapsed_borders.inline[i].combine(&table_inline_borders.start); + } else if i + 1 == number_of_borders_inline_direction { + child_table_row.final_collapsed_borders.inline[i].combine(&table_inline_borders.end); + } let inline_spacing = inline_spacing.get_mut_or_push(i, Au(0)); - *inline_spacing = cmp::max(*inline_spacing, this_inline_border.width) - } - - // Collapse edge interior borders with the table. - if let Some(ref mut first_inline_borders) = child_table_row.final_collapsed_borders - .inline - .get_mut(0) { - first_inline_borders.combine(&table_inline_borders.start) - } - if let Some(ref mut last_inline_borders) = child_table_row.final_collapsed_borders - .inline - .last_mut() { - last_inline_borders.combine(&table_inline_borders.end) + *inline_spacing = cmp::max(*inline_spacing, child_table_row.final_collapsed_borders.inline[i].width) } // Compute block-start borders. @@ -777,6 +772,7 @@ impl TableLikeFlow for BlockFlow { } /// Inline collapsed borders for the table itself. +#[derive(Debug)] struct TableInlineCollapsedBorders { /// The table border at the start of the inline direction. start: CollapsedBorder, |