Skip to content

Commit

Permalink
Preserve information on incoming row sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Feb 27, 2018
1 parent e894c8b commit 216082c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions components/layout/table.rs
Expand Up @@ -784,14 +784,14 @@ impl TableLikeFlow for BlockFlow {

if self.base.restyle_damage.contains(ServoRestyleDamage::REFLOW) {
let mut sizes = vec![];
let mut incoming_rowspan_data = vec![];

for kid in self.base.child_iter_mut() {
if kid.is_table_row() {
sizes.push(kid.as_mut_table_row()
.compute_block_size_table_row_base(layout_context))
.compute_block_size_table_row_base(layout_context, &mut incoming_rowspan_data))
}
}

let mut effects_rows = 0;
let mut i = 0;
for kid in self.base.child_iter_mut() {
Expand Down
39 changes: 31 additions & 8 deletions components/layout/table_row.rs
Expand Up @@ -114,8 +114,20 @@ impl TableRowFlow {
/// inline(always) because this is only ever called by in-order or non-in-order top-level
/// methods
#[inline(always)]
pub fn compute_block_size_table_row_base<'a>(&'a mut self, layout_context: &LayoutContext) -> Au {
pub fn compute_block_size_table_row_base<'a>(&'a mut self, layout_context: &LayoutContext, incoming_rowspan_data: &mut Vec<Au>) -> Au {
if self.block_flow.base.restyle_damage.contains(ServoRestyleDamage::REFLOW) {
fn include_sizes_from_previous_rows(col: &mut usize,
incoming_rowspan: &[u32],
incoming_rowspan_data: &mut Vec<Au>,
max_block_size: &mut Au) {
while let Some(span) = incoming_rowspan.get(*col) {
if *span <= 1 {
break;
}
*max_block_size = max(*max_block_size, incoming_rowspan_data[*col]);
*col += 1;
}
}
// Per CSS 2.1 § 17.5.3, find max_y = max(computed `block-size`, minimum block-size of
// all cells).
let mut max_block_size = Au(0);
Expand All @@ -124,7 +136,9 @@ impl TableRowFlow {
- self.block_flow.fragment.border_padding
- self.block_flow.fragment.margin;

let mut col = 0;
for kid in self.block_flow.base.child_iter_mut() {
include_sizes_from_previous_rows(&mut col, &self.incoming_rowspan, incoming_rowspan_data, &mut max_block_size);
kid.place_float_if_applicable();
if !kid.base().flags.is_float() {
kid.assign_block_size_for_inorder_child_if_necessary(layout_context,
Expand All @@ -133,19 +147,28 @@ impl TableRowFlow {
}

let row_span;
let column_span;
let cell_total;
{
let cell = kid.as_mut_table_cell();
row_span = cell.row_span as i32;
max_block_size =
max(max_block_size, cell.total_block_size() / row_span);
column_span = cell.column_span as usize;
cell_total = cell.total_block_size();
}
{
let child_node = kid.mut_base();
child_node.position.start.b = Au(0);
max_block_size = max(max_block_size, child_node.position.size.block / row_span);
let child_node = kid.mut_base();
child_node.position.start.b = Au(0);
let cell_block_size = max(cell_total, child_node.position.size.block);
max_block_size = max(max_block_size, cell_block_size / row_span);

if row_span > 1 {
if incoming_rowspan_data.len() <= col {
incoming_rowspan_data.resize(col + 1, Au(0));
}
incoming_rowspan_data[col] = cell_block_size / row_span;
}
col += column_span;
}
// XXXManishearth include overages from spanning cells from previous rows
include_sizes_from_previous_rows(&mut col, &self.incoming_rowspan, incoming_rowspan_data, &mut max_block_size);

let mut block_size = max_block_size;
// TODO: Percentage block-size
Expand Down

0 comments on commit 216082c

Please sign in to comment.