layout: Remove reflow damage after reflowing table rows.

This commit is contained in:
Patrick Walton 2016-09-20 16:20:09 -07:00
parent 132810e739
commit 83a73a979e

View file

@ -21,6 +21,7 @@ use gfx_traits::print_tree::PrintTree;
use layout_debug; use layout_debug;
use model::MaybeAuto; use model::MaybeAuto;
use rustc_serialize::{Encodable, Encoder}; use rustc_serialize::{Encodable, Encoder};
use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable}; use std::iter::{Enumerate, IntoIterator, Peekable};
@ -106,73 +107,84 @@ impl TableRowFlow {
/// methods /// methods
#[inline(always)] #[inline(always)]
fn assign_block_size_table_row_base(&mut self, layout_context: &LayoutContext) { fn assign_block_size_table_row_base(&mut self, layout_context: &LayoutContext) {
// Per CSS 2.1 § 17.5.3, find max_y = max(computed `block-size`, minimum block-size of all if self.block_flow.base.restyle_damage.contains(REFLOW) {
// cells). // Per CSS 2.1 § 17.5.3, find max_y = max(computed `block-size`, minimum block-size of
let mut max_block_size = Au(0); // all cells).
let thread_id = self.block_flow.base.thread_id; let mut max_block_size = Au(0);
for kid in self.block_flow.base.child_iter_mut() { let thread_id = self.block_flow.base.thread_id;
kid.place_float_if_applicable(); for kid in self.block_flow.base.child_iter_mut() {
if !flow::base(kid).flags.is_float() { kid.place_float_if_applicable();
kid.assign_block_size_for_inorder_child_if_necessary(layout_context, thread_id); if !flow::base(kid).flags.is_float() {
kid.assign_block_size_for_inorder_child_if_necessary(layout_context,
thread_id);
}
{
let child_fragment = kid.as_mut_table_cell().fragment();
// TODO: Percentage block-size
let child_specified_block_size =
MaybeAuto::from_style(child_fragment.style().content_block_size(),
Au(0)).specified_or_zero();
max_block_size =
max(max_block_size,
child_specified_block_size +
child_fragment.border_padding.block_start_end());
}
let child_node = flow::mut_base(kid);
child_node.position.start.b = Au(0);
max_block_size = max(max_block_size, child_node.position.size.block);
} }
{ let mut block_size = max_block_size;
let child_fragment = kid.as_mut_table_cell().fragment(); // TODO: Percentage block-size
// TODO: Percentage block-size block_size = match MaybeAuto::from_style(self.block_flow
let child_specified_block_size = .fragment
MaybeAuto::from_style(child_fragment.style().content_block_size(), .style()
Au(0)).specified_or_zero(); .content_block_size(),
max_block_size = Au(0)) {
max(max_block_size, MaybeAuto::Auto => block_size,
child_specified_block_size + MaybeAuto::Specified(value) => max(value, block_size),
child_fragment.border_padding.block_start_end()); };
// Assign the block-size of own fragment
let mut position = self.block_flow.fragment.border_box;
position.size.block = block_size;
self.block_flow.fragment.border_box = position;
self.block_flow.base.position.size.block = block_size;
// Assign the block-size of kid fragments, which is the same value as own block-size.
for kid in self.block_flow.base.child_iter_mut() {
let child_table_cell = kid.as_mut_table_cell();
{
let kid_fragment = child_table_cell.mut_fragment();
let mut position = kid_fragment.border_box;
position.size.block = block_size;
kid_fragment.border_box = position;
}
// Assign the child's block size.
child_table_cell.block_flow.base.position.size.block = block_size;
// Now we know the cell height, vertical align the cell's children.
child_table_cell.valign_children();
// Write in the size of the relative containing block for children. (This
// information is also needed to handle RTL.)
child_table_cell.block_flow.base.early_absolute_position_info =
EarlyAbsolutePositionInfo {
relative_containing_block_size: self.block_flow
.fragment
.content_box()
.size,
relative_containing_block_mode: self.block_flow
.fragment
.style()
.writing_mode,
};
} }
let child_node = flow::mut_base(kid);
child_node.position.start.b = Au(0);
max_block_size = max(max_block_size, child_node.position.size.block);
} }
let mut block_size = max_block_size; self.block_flow.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
// TODO: Percentage block-size
block_size = match MaybeAuto::from_style(self.block_flow
.fragment
.style()
.content_block_size(),
Au(0)) {
MaybeAuto::Auto => block_size,
MaybeAuto::Specified(value) => max(value, block_size),
};
// Assign the block-size of own fragment
let mut position = self.block_flow.fragment.border_box;
position.size.block = block_size;
self.block_flow.fragment.border_box = position;
self.block_flow.base.position.size.block = block_size;
// Assign the block-size of kid fragments, which is the same value as own block-size.
for kid in self.block_flow.base.child_iter_mut() {
let child_table_cell = kid.as_mut_table_cell();
{
let kid_fragment = child_table_cell.mut_fragment();
let mut position = kid_fragment.border_box;
position.size.block = block_size;
kid_fragment.border_box = position;
}
// Assign the child's block size.
child_table_cell.block_flow.base.position.size.block = block_size;
// Now we know the cell height, vertical align the cell's children.
child_table_cell.valign_children();
// Write in the size of the relative containing block for children. (This information
// is also needed to handle RTL.)
child_table_cell.block_flow.base.early_absolute_position_info =
EarlyAbsolutePositionInfo {
relative_containing_block_size: self.block_flow.fragment.content_box().size,
relative_containing_block_mode: self.block_flow.fragment.style().writing_mode,
};
}
} }
pub fn populate_collapsed_border_spacing<'a, I>( pub fn populate_collapsed_border_spacing<'a, I>(