Skip to content

Commit

Permalink
Merge fourth and fifth (assign block sizes / positions) passes
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Feb 27, 2018
1 parent ef983c3 commit 19974e3
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions components/layout/table.rs
Expand Up @@ -830,12 +830,21 @@ impl TableLikeFlow for BlockFlow {
sizes[i - 1].0 = cmp::max(sizes[i - 1].0, overflow);
}

// Third pass: Assign block sizes to rows and cells

// 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;

// Third pass: Assign block sizes and positions to rows, cells, and other children
// [expensive: iterates over cells]
// At this point, `current_block_offset` is at the content edge of our box. Now iterate
// over children.
let mut effects_rows = 0;
let mut i = 0;
for kid in self.base.child_iter_mut() {
if kid.is_table_row() {
has_rows = true;
let row = kid.as_mut_table_row();
if row.mut_base().restyle_damage.contains(ServoRestyleDamage::REFLOW) ||
effects_rows != 0 {
Expand All @@ -844,33 +853,15 @@ impl TableLikeFlow for BlockFlow {
.remove(ServoRestyleDamage::REFLOW_OUT_OF_FLOW |
ServoRestyleDamage::REFLOW);
}
current_block_offset = current_block_offset +
border_spacing_for_row(&self.fragment, row,
block_direction_spacing);
// may happen for empty rows
if effects_rows != 0 {
effects_rows -= 1;
}
i += 1;
}
}

// 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;

// Fourth pass: Compute block positions
// XXXManishearth this can be merged with the third pass

// At this point, `current_block_offset` is at the content edge of our box. Now iterate
// over children.
for kid in self.base.child_iter_mut() {
// 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 +
border_spacing_for_row(&self.fragment, child_table_row,
block_direction_spacing)
}

// At this point, `current_block_offset` is at the border edge of the child.
kid.mut_base().position.start.b = current_block_offset;
Expand Down Expand Up @@ -914,7 +905,7 @@ impl TableLikeFlow for BlockFlow {
self.fragment.border_box.start.b = Au(0);
self.base.position.size.block = current_block_offset;

// Fifth pass: Assign absolute position info
// Fourth pass: Assign absolute position info
// Write in the size of the relative containing block for children. (This information
// is also needed to handle RTL.)
for kid in self.base.child_iter_mut() {
Expand Down

0 comments on commit 19974e3

Please sign in to comment.