diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-08-17 00:16:34 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-08-18 12:56:18 +0200 |
commit | d885958621b728ddb7b9f2296a87c55bf8d61951 (patch) | |
tree | ff878d79a1e41875ce568a9bde96eec1ecde07af /components/layout/table.rs | |
parent | 5ab9aa5013801a8ac2b9527a6079c62cc56ff81b (diff) | |
download | servo-d885958621b728ddb7b9f2296a87c55bf8d61951.tar.gz servo-d885958621b728ddb7b9f2296a87c55bf8d61951.zip |
Avoid a panic when handling collapsing borders (fixes #7144)
There is no need to compute next_collapsed_borders_in_block_direction for all
kind of flows when it's used only in the table row case. That also avoids a panic
when the next child is a table colgroup (this should not happen when iterating
over a table row).
Diffstat (limited to 'components/layout/table.rs')
-rw-r--r-- | components/layout/table.rs | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/components/layout/table.rs b/components/layout/table.rs index c3c63b85762..d9d65604c10 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -262,32 +262,6 @@ impl Flow for TableFlow { { let mut iterator = self.block_flow.base.child_iter().peekable(); while let Some(kid) = iterator.next() { - let next_index_and_sibling = iterator.peek(); - let next_collapsed_borders_in_block_direction = if collapsing_borders { - match next_index_and_sibling { - Some(next_sibling) => { - if next_sibling.is_table_rowgroup() { - NextBlockCollapsedBorders::FromNextRow( - &next_sibling.as_immutable_table_rowgroup() - .preliminary_collapsed_borders - .block_start) - } else { - NextBlockCollapsedBorders::FromNextRow( - &next_sibling.as_immutable_table_row() - .preliminary_collapsed_borders - .block_start) - } - } - None => { - NextBlockCollapsedBorders::FromTable( - CollapsedBorder::block_end(&*self.block_flow.fragment.style, - CollapsedBorderProvenance::FromTable)) - } - } - } else { - NextBlockCollapsedBorders::NotCollapsingBorders - }; - if kid.is_table_colgroup() { for specified_inline_size in &kid.as_table_colgroup().inline_sizes { self.column_intrinsic_inline_sizes.push(ColumnIntrinsicInlineSize { @@ -313,6 +287,28 @@ impl Flow for TableFlow { first_row, self.table_layout); if collapsing_borders { + let next_index_and_sibling = iterator.peek(); + let next_collapsed_borders_in_block_direction = + match next_index_and_sibling { + Some(next_sibling) => { + if next_sibling.is_table_rowgroup() { + NextBlockCollapsedBorders::FromNextRow( + &next_sibling.as_immutable_table_rowgroup() + .preliminary_collapsed_borders + .block_start) + } else { + NextBlockCollapsedBorders::FromNextRow( + &next_sibling.as_immutable_table_row() + .preliminary_collapsed_borders + .block_start) + } + } + None => { + NextBlockCollapsedBorders::FromTable( + CollapsedBorder::block_end(&*self.block_flow.fragment.style, + CollapsedBorderProvenance::FromTable)) + } + }; perform_border_collapse_for_row( kid.as_table_row(), table_inline_collapsed_borders.as_ref().unwrap(), |