Fix table vertical alignment (middle, bottom, not yet baseline) with differing height cells

Includes reftest for this behaviour
Patch fixes margin-collapse-clear-002,3,8,9
This commit is contained in:
Adam Casey 2016-07-23 01:07:16 +01:00
parent 2de3b119a9
commit b1debc40be
9 changed files with 102 additions and 12 deletions

View file

@ -80,6 +80,10 @@ impl TableCellFlow {
if !flow::base(self).restyle_damage.contains(REFLOW) {
return;
}
}
/// Position this cell's children according to vertical-align.
pub fn valign_children(&mut self) {
// Note to the reader: this code has been tested with negative margins.
// We end up with a "end" that's before the "start," but the math still works out.
let first_start = flow::base(self).children.front().map(|kid| {
@ -106,6 +110,9 @@ impl TableCellFlow {
let self_size = flow::base(self).position.size.block -
self.block_flow.fragment.border_padding.block_start_end();
let kids_self_gap = self_size - kids_size;
// This offset should also account for vertical_align::T::baseline.
// Need max cell ascent from the first row of this cell.
let offset = match self.block_flow.fragment.style().get_box().vertical_align {
vertical_align::T::middle => kids_self_gap / 2,
vertical_align::T::bottom => kids_self_gap,

View file

@ -162,6 +162,9 @@ impl TableRowFlow {
// 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 =