Fix size of tables in flow layout (#31455)

* Fix size of tables in flow layout

The contents of a table can make it bigger than what we would expect
from its 'width', 'min-width', 'height' and ' min-height' properties.
Also, 'width: auto' doesn't stretch it to fill the containing block.

We had to refactor the resolution of margins to happen after layout,
otherwise 'auto' margins wouldn't align correctly.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Feedback

* Consistently use `containing_block_for_table` in table layout

* Update test result

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2024-03-02 02:39:41 +01:00 committed by GitHub
parent c23999941a
commit 50fdb82246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 289 additions and 388 deletions

View file

@ -410,6 +410,7 @@ impl FlexContainer {
IndependentLayout {
fragments,
content_block_size: content_block_size.into(),
content_inline_size_for_table: None,
baselines: Baselines::default(),
}
}
@ -1108,6 +1109,7 @@ impl<'a> FlexItem<'a> {
flex_context.layout_context,
&mut positioning_context,
&item_as_containing_block,
&flex_context.containing_block,
);
let hypothetical_cross_size = self

View file

@ -251,6 +251,18 @@ impl<'a> PlacementAmongFloats<'a> {
}
}
/// After placing a table and then laying it out, it may turn out wider than what
/// we initially expected. This method takes care of updating the data so that
/// the next place() can find the right area for the new size.
/// Note that if the new size is smaller, placement won't backtrack to consider
/// areas that weren't big enough for the old size.
pub(crate) fn set_inline_size(&mut self, inline_size: Au, pbm: &PaddingBorderMargin) {
self.object_size.inline = inline_size;
self.max_inline_end = (self.float_context.containing_block_info.inline_end -
pbm.margin.inline_end.auto_is(Length::zero).into())
.max(self.min_inline_start + inline_size);
}
/// After placing an object with `height: auto` (and using the minimum inline and
/// block size as the object size) and then laying it out, try to fit the object into
/// the current set of bands, given block size after layout and the available inline
@ -939,6 +951,7 @@ impl FloatBox {
layout_context,
positioning_context,
&containing_block_for_children,
&containing_block,
);
content_size = LogicalVec2 {
inline: inline_size,

View file

@ -1940,24 +1940,32 @@ impl IndependentFormattingContext {
layout_context,
child_positioning_context.as_mut().unwrap(),
&containing_block_for_children,
&ifc.containing_block,
);
let (inline_size, block_size) =
match independent_layout.content_inline_size_for_table {
Some(inline) => (inline, independent_layout.content_block_size),
None => {
// https://drafts.csswg.org/css2/visudet.html#block-root-margin
let tentative_block_size = box_size
.block
.auto_is(|| independent_layout.content_block_size.into());
// https://drafts.csswg.org/css2/visudet.html#block-root-margin
let tentative_block_size = box_size
.block
.auto_is(|| independent_layout.content_block_size.into());
// https://drafts.csswg.org/css2/visudet.html#min-max-heights
// In this case “applying the rules above again” with a non-auto block-size
// always results in that size.
let block_size = tentative_block_size
.clamp_between_extremums(min_box_size.block, max_box_size.block);
// https://drafts.csswg.org/css2/visudet.html#min-max-heights
// In this case “applying the rules above again” with a non-auto block-size
// always results in that size.
let block_size = tentative_block_size
.clamp_between_extremums(min_box_size.block, max_box_size.block);
(inline_size.into(), block_size.into())
},
};
let content_rect = LogicalRect {
start_corner: pbm_sums.start_offset(),
size: LogicalVec2 {
block: block_size.into(),
inline: inline_size.into(),
block: block_size,
inline: inline_size,
},
};

View file

@ -243,6 +243,7 @@ impl BlockFormattingContext {
flow_layout.collapsible_margins_in_children.end.solve() +
clearance.unwrap_or_else(Au::zero).into())
.into(),
content_inline_size_for_table: None,
baselines: flow_layout.baselines,
}
}
@ -621,14 +622,20 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
mut sequential_layout_state: Option<&mut SequentialLayoutState>,
collapsible_with_parent_start_margin: Option<CollapsibleWithParentStartMargin>,
) -> BoxFragment {
let ContainingBlockPaddingBorderAndMargin {
let ContainingBlockPaddingAndBorder {
containing_block: containing_block_for_children,
pbm,
min_box_size,
max_box_size,
} = solve_containing_block_padding_and_border_for_in_flow_box(containing_block, style);
let ResolvedMargins {
margin,
effective_margin_inline_start,
} = solve_containing_block_padding_border_and_margin_for_in_flow_box(containing_block, style);
} = solve_margins(
containing_block,
&pbm,
containing_block_for_children.inline_size.into(),
);
let computed_block_size = style.content_block_size();
let start_margin_can_collapse_with_children =
@ -834,14 +841,12 @@ impl NonReplacedFormattingContext {
);
}
let ContainingBlockPaddingBorderAndMargin {
let ContainingBlockPaddingAndBorder {
containing_block: containing_block_for_children,
pbm,
min_box_size,
max_box_size,
margin,
effective_margin_inline_start,
} = solve_containing_block_padding_border_and_margin_for_in_flow_box(
} = solve_containing_block_padding_and_border_for_in_flow_box(
containing_block,
&self.style,
);
@ -850,14 +855,26 @@ impl NonReplacedFormattingContext {
layout_context,
positioning_context,
&containing_block_for_children,
&containing_block,
);
let block_size = containing_block_for_children.block_size.auto_is(|| {
layout.content_block_size.clamp_between_extremums(
min_box_size.block.into(),
max_box_size.block.map(|t| t.into()),
)
});
let (block_size, inline_size) = match layout.content_inline_size_for_table {
Some(inline_size) => (layout.content_block_size, inline_size),
None => (
containing_block_for_children.block_size.auto_is(|| {
layout.content_block_size.clamp_between_extremums(
min_box_size.block.into(),
max_box_size.block.map(|t| t.into()),
)
}),
containing_block_for_children.inline_size,
),
};
let ResolvedMargins {
margin,
effective_margin_inline_start,
} = solve_margins(containing_block, &pbm, inline_size.into());
let content_rect = LogicalRect {
start_corner: LogicalVec2 {
@ -868,7 +885,7 @@ impl NonReplacedFormattingContext {
},
size: LogicalVec2 {
block: block_size,
inline: containing_block_for_children.inline_size,
inline: inline_size,
},
};
@ -940,20 +957,24 @@ impl NonReplacedFormattingContext {
block_size: block_size.map(|t| t.into()),
style: &self.style,
},
containing_block,
);
content_size = LogicalVec2 {
inline: inline_size,
block: block_size.auto_is(|| {
layout
.content_block_size
.clamp_between_extremums(
min_box_size.block.into(),
max_box_size.block.map(|t| t.into()),
)
.into()
}),
};
if let Some(inline_size) = layout.content_inline_size_for_table {
content_size = LogicalVec2 {
block: layout.content_block_size,
inline: inline_size,
}
.into();
} else {
content_size = LogicalVec2 {
block: block_size.auto_is(|| {
Length::from(layout.content_block_size)
.clamp_between_extremums(min_box_size.block, max_box_size.block)
}),
inline: inline_size,
};
}
(
clearance,
@ -1013,19 +1034,37 @@ impl NonReplacedFormattingContext {
block_size: block_size.map(|t| t.into()),
style: &self.style,
},
containing_block,
);
content_size = LogicalVec2 {
inline: proposed_inline_size,
block: block_size.auto_is(|| {
layout
.content_block_size
.clamp_between_extremums(
min_box_size.block.into(),
max_box_size.block.map(|t| t.into()),
)
.into()
}),
};
if let Some(inline_size) = layout.content_inline_size_for_table {
// If this is a table, it's impossible to know the inline size it will take
// up until after trying to place it. If the table doesn't fit into this
// positioning rectangle due to incompatibility in the inline axis,
// then retry at another location.
// Even if it would fit in the inline axis, we may end up having to retry
// at another location due to incompatibility in the block axis. Therefore,
// always update the size in the PlacementAmongFloats as an optimization.
let outer_inline_size = inline_size + pbm.padding_border_sums.inline;
placement.set_inline_size(outer_inline_size, &pbm);
if outer_inline_size > placement_rect.size.inline {
positioning_context.truncate(&positioning_context_length);
continue;
}
content_size = LogicalVec2 {
block: layout.content_block_size,
inline: inline_size,
}
.into();
} else {
content_size = LogicalVec2 {
block: block_size.auto_is(|| {
Length::from(layout.content_block_size)
.clamp_between_extremums(min_box_size.block, max_box_size.block)
}),
inline: proposed_inline_size,
};
}
// Now we know the block size of this attempted layout of a box with block
// size of auto. Try to fit it into our precalculated placement among the
@ -1224,11 +1263,15 @@ fn layout_in_flow_replaced_block_level<'a>(
)
}
struct ContainingBlockPaddingBorderAndMargin<'a> {
struct ContainingBlockPaddingAndBorder<'a> {
containing_block: ContainingBlock<'a>,
pbm: PaddingBorderMargin,
min_box_size: LogicalVec2<Length>,
max_box_size: LogicalVec2<Option<Length>>,
}
struct ResolvedMargins {
/// Used value for the margin properties, as exposed in getComputedStyle().
margin: LogicalSides<Length>,
/// Distance between the border box and the containing block on the inline-start side.
@ -1240,15 +1283,15 @@ struct ContainingBlockPaddingBorderAndMargin<'a> {
effective_margin_inline_start: Length,
}
/// Given the style for in in flow box and its containing block, determine the containing
/// block for its children and the margin it should use.
/// Given the style for an in-flow box and its containing block, determine the containing
/// block for its children.
/// Note that in the presence of floats, this shouldn't be used for a block-level box
/// that establishes an independent formatting context (or is replaced), since the margins
/// and inline size could then be incorrect.
fn solve_containing_block_padding_border_and_margin_for_in_flow_box<'a>(
/// that establishes an independent formatting context (or is replaced), since the
/// inline size could then be incorrect.
fn solve_containing_block_padding_and_border_for_in_flow_box<'a>(
containing_block: &ContainingBlock<'_>,
style: &'a Arc<ComputedValues>,
) -> ContainingBlockPaddingBorderAndMargin<'a> {
) -> ContainingBlockPaddingAndBorder<'a> {
let pbm = style.padding_border_margin(containing_block);
let box_size = style.content_box_size(containing_block, &pbm);
let max_box_size = style.content_max_box_size(containing_block, &pbm);
@ -1269,16 +1312,6 @@ fn solve_containing_block_padding_border_and_margin_for_in_flow_box<'a>(
})
.clamp_between_extremums(min_box_size.inline, max_box_size.inline);
let (inline_margins, effective_margin_inline_start) =
solve_inline_margins_for_in_flow_block_level(containing_block, &pbm, inline_size);
let block_margins = solve_block_margins_for_in_flow_block_level(&pbm);
let margin = LogicalSides {
inline_start: inline_margins.0,
inline_end: inline_margins.1,
block_start: block_margins.0,
block_end: block_margins.1,
};
// https://drafts.csswg.org/css2/#the-height-property
// https://drafts.csswg.org/css2/visudet.html#min-max-heights
let mut block_size = box_size.block;
@ -1296,12 +1329,33 @@ fn solve_containing_block_padding_border_and_margin_for_in_flow_box<'a>(
containing_block.style.writing_mode, containing_block_for_children.style.writing_mode,
"Mixed writing modes are not supported yet"
);
ContainingBlockPaddingBorderAndMargin {
ContainingBlockPaddingAndBorder {
containing_block: containing_block_for_children,
pbm,
min_box_size,
max_box_size,
margin,
}
}
/// Given the containing block and size of an in-flow box, determine the margins.
/// Note that in the presence of floats, this shouldn't be used for a block-level box
/// that establishes an independent formatting context (or is replaced), since the
/// margins could then be incorrect.
fn solve_margins(
containing_block: &ContainingBlock<'_>,
pbm: &PaddingBorderMargin,
inline_size: Length,
) -> ResolvedMargins {
let (inline_margins, effective_margin_inline_start) =
solve_inline_margins_for_in_flow_block_level(containing_block, &pbm, inline_size);
let block_margins = solve_block_margins_for_in_flow_block_level(&pbm);
ResolvedMargins {
margin: LogicalSides {
inline_start: inline_margins.0,
inline_end: inline_margins.1,
block_start: block_margins.0,
block_end: block_margins.1,
},
effective_margin_inline_start,
}
}
@ -1347,7 +1401,7 @@ fn justify_self_alignment(containing_block: &ContainingBlock, free_space: Length
/// that establishes an independent formatting context (or is replaced).
///
/// In addition to the used margins, it also returns the effective margin-inline-start
/// (see ContainingBlockPaddingBorderAndMargin).
/// (see ContainingBlockPaddingAndBorder).
fn solve_inline_margins_for_in_flow_block_level(
containing_block: &ContainingBlock,
pbm: &PaddingBorderMargin,
@ -1384,7 +1438,7 @@ fn solve_inline_margins_for_in_flow_block_level(
/// they align within the provided rect (instead of the containing block),
/// to avoid overlapping floats.
/// In addition to the used margins, it also returns the effective
/// margin-inline-start (see ContainingBlockPaddingBorderAndMargin).
/// margin-inline-start (see ContainingBlockPaddingAndBorder).
/// It may differ from the used inline-start margin if the computed value
/// wasn't 'auto' and there are floats to avoid or the box is justified.
/// See <https://github.com/w3c/csswg-drafts/issues/9174>

View file

@ -73,6 +73,11 @@ pub(crate) struct IndependentLayout {
/// <https://drafts.csswg.org/css2/visudet.html#root-height>
pub content_block_size: Au,
/// The contents of a table may force it to become wider than what we would expect
/// from 'width' and 'min-width'. This is the resulting inline content size,
/// or None for non-table layouts.
pub content_inline_size_for_table: Option<Au>,
/// The offset of the last inflow baseline of this layout in the content area, if
/// there was one. This is used to propagate baselines to the ancestors of `display:
/// inline-block`.
@ -187,18 +192,26 @@ impl NonReplacedFormattingContext {
&self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
containing_block_for_children: &ContainingBlock,
containing_block: &ContainingBlock,
) -> IndependentLayout {
match &self.contents {
NonReplacedFormattingContextContents::Flow(bfc) => {
bfc.layout(layout_context, positioning_context, containing_block)
},
NonReplacedFormattingContextContents::Flex(fc) => {
fc.layout(layout_context, positioning_context, containing_block)
},
NonReplacedFormattingContextContents::Table(table) => {
table.layout(layout_context, positioning_context, containing_block)
},
NonReplacedFormattingContextContents::Flow(bfc) => bfc.layout(
layout_context,
positioning_context,
containing_block_for_children,
),
NonReplacedFormattingContextContents::Flex(fc) => fc.layout(
layout_context,
positioning_context,
containing_block_for_children,
),
NonReplacedFormattingContextContents::Table(table) => table.layout(
layout_context,
positioning_context,
containing_block_for_children,
containing_block,
),
}
}

View file

@ -625,6 +625,7 @@ impl HoistedAbsolutelyPositionedBox {
layout_context,
&mut positioning_context,
&containing_block_for_children,
&containing_block.into(),
);
let block_size = size.auto_is(|| independent_layout.content_block_size);
Result {

View file

@ -79,6 +79,7 @@ struct TableLayout<'a> {
columns: Vec<ColumnLayout>,
cell_measures: Vec<Vec<LogicalVec2<CellOrTrackMeasure>>>,
assignable_width: Au,
final_table_height: Au,
column_measures: Vec<CellOrTrackMeasure>,
distributed_column_widths: Vec<Au>,
row_sizes: Vec<Au>,
@ -115,6 +116,7 @@ impl<'a> TableLayout<'a> {
columns: Vec::new(),
cell_measures: Vec::new(),
assignable_width: Au::zero(),
final_table_height: Au::zero(),
column_measures: Vec::new(),
distributed_column_widths: Vec::new(),
row_sizes: Vec::new(),
@ -130,18 +132,27 @@ impl<'a> TableLayout<'a> {
&mut self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
containing_block_for_children: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
) {
let writing_mode = containing_block.style.writing_mode;
let writing_mode = containing_block_for_children.style.writing_mode;
self.compute_track_constrainedness_and_has_originating_cells(writing_mode);
self.compute_cell_measures(layout_context, containing_block);
self.compute_column_measures(containing_block.style.writing_mode);
self.compute_table_width(containing_block);
self.compute_cell_measures(layout_context, containing_block_for_children);
self.compute_column_measures(writing_mode);
self.compute_table_width(containing_block_for_children, containing_block_for_table);
self.distributed_column_widths = self.distribute_width_to_columns();
self.layout_cells_in_row(layout_context, containing_block, positioning_context);
self.layout_cells_in_row(
layout_context,
containing_block_for_children,
positioning_context,
);
let first_layout_row_heights = self.do_first_row_layout(writing_mode);
self.compute_table_height_and_final_row_heights(first_layout_row_heights, containing_block);
self.compute_table_height_and_final_row_heights(
first_layout_row_heights,
containing_block_for_children,
containing_block_for_table,
);
}
/// This is an implementation of *Computing Cell Measures* from
@ -149,12 +160,12 @@ impl<'a> TableLayout<'a> {
pub(crate) fn compute_cell_measures(
&mut self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
) {
let row_measures = vec![LogicalVec2::zero(); self.table.size.width];
self.cell_measures = vec![row_measures; self.table.size.height];
let writing_mode = containing_block.style.writing_mode;
let writing_mode = containing_block_for_table.style.writing_mode;
for row_index in 0..self.table.size.height {
for column_index in 0..self.table.size.width {
let cell = match self.table.slots[row_index][column_index] {
@ -623,57 +634,70 @@ impl<'a> TableLayout<'a> {
(next_span_n, new_content_sizes_for_columns)
}
fn compute_table_width(&mut self, containing_block: &ContainingBlock) {
fn compute_table_width(
&mut self,
containing_block_for_children: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
) {
// https://drafts.csswg.org/css-tables/#gridmin:
// > The row/column-grid width minimum (GRIDMIN) width is the sum of the min-content width of
// > all the columns plus cell spacing or borders.
// https://drafts.csswg.org/css-tables/#gridmax:
// > The row/column-grid width maximum (GRIDMAX) width is the sum of the max-content width of
// > all the columns plus cell spacing or borders.
let mut grid_min_and_max = self
let ContentSizes {
min_content: mut gridmin,
max_content: mut gridmax,
} = self
.column_measures
.iter()
.fold(ContentSizes::zero(), |result, measure| {
result + measure.content_sizes
});
// TODO: GRIDMAX should never be smaller than GRIDMIN!
gridmax = gridmax.max(gridmin);
let border_spacing = self.table.border_spacing();
let inline_border_spacing = border_spacing.inline * (self.table.size.width as i32 + 1);
grid_min_and_max.min_content += inline_border_spacing;
grid_min_and_max.max_content += inline_border_spacing;
let inline_border_spacing = if self.table.size.width > 0 {
border_spacing.inline * (self.table.size.width as i32 + 1)
} else {
Au::zero()
};
gridmin += inline_border_spacing;
gridmax += inline_border_spacing;
self.pbm = self.table.style.padding_border_margin(containing_block);
let content_box_size = self
.table
.style
.content_box_size(containing_block, &self.pbm);
let min_content_sizes = self
.table
.style
.content_min_box_size(containing_block, &self.pbm)
.auto_is(Length::zero);
let style = &self.table.style;
self.pbm = style.padding_border_margin(containing_block_for_table);
// https://drafts.csswg.org/css-tables/#used-min-width-of-table
// > The used min-width of a table is the greater of the resolved min-width, CAPMIN, and GRIDMIN.
let used_min_width_of_table = grid_min_and_max
.min_content
.max(min_content_sizes.inline.into());
// https://drafts.csswg.org/css-tables/#resolved-table-width
// * If inline-size computes to 'auto', this is the stretch-fit size
// (https://drafts.csswg.org/css-sizing-3/#stretch-fit-size).
// * Otherwise, it's the resulting length (with percentages resolved).
// In both cases, it's clamped between min-inline-size and max-inline-size.
// This diverges a little from the specification.
let resolved_table_width = containing_block_for_children.inline_size;
// https://drafts.csswg.org/css-tables/#used-width-of-table
// > The used width of a table depends on the columns and captions widths as follows:
// > * If the table-roots width property has a computed value (resolving to
// > resolved-table-width) other than auto, the used width is the greater of
// > resolved-table-width, and the used min-width of the table.
// > * If the table-root has 'width: auto', the used width is the greater of min(GRIDMAX,
// > the tables containing block width), the used min-width of the table.
let used_width_of_table = match content_box_size.inline {
LengthPercentage(length_percentage) => {
Au::from(length_percentage).max(used_min_width_of_table)
// * If table-root has a computed value for inline-size different than auto:
// use the maximum of the resolved table width and GRIDMIN.
// * If auto: use the resolved_table_width, clamped between GRIDMIN and GRIDMAX,
// but at least as big as min-inline-size.
// This diverges a little from the specification, but should be equivalent
// (other than using the stretch-fit size instead of the containing block width).
let used_width_of_table = match style
.content_box_size(containing_block_for_table, &self.pbm)
.inline
{
LengthPercentage(_) => resolved_table_width.max(gridmin),
Auto => {
let min_width: Au = style
.content_min_box_size(containing_block_for_table, &self.pbm)
.inline
.auto_is(Length::zero)
.into();
resolved_table_width.clamp(gridmin, gridmax).max(min_width)
},
Auto => grid_min_and_max
.max_content
.min(containing_block.inline_size)
.max(used_min_width_of_table),
};
// > The assignable table width is the used width of the table minus the total horizontal
@ -976,7 +1000,7 @@ impl<'a> TableLayout<'a> {
fn layout_cells_in_row(
&mut self,
layout_context: &LayoutContext,
containing_block: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
parent_positioning_context: &mut PositioningContext,
) {
for row_index in 0..self.table.slots.len() {
@ -996,10 +1020,12 @@ impl<'a> TableLayout<'a> {
total_width += self.distributed_column_widths[width_index];
}
let border = cell.style.border_width(containing_block.style.writing_mode);
let border = cell
.style
.border_width(containing_block_for_table.style.writing_mode);
let padding = cell
.style
.padding(containing_block.style.writing_mode)
.padding(containing_block_for_table.style.writing_mode)
.percentages_relative_to(self.basis_for_cell_padding_percentage.into());
let inline_border_padding_sum = border.inline_sum() + padding.inline_sum();
let mut total_width: CSSPixelLength =
@ -1327,27 +1353,37 @@ impl<'a> TableLayout<'a> {
fn compute_table_height_and_final_row_heights(
&mut self,
mut row_sizes: Vec<Au>,
containing_block: &ContainingBlock,
containing_block_for_children: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
) {
// The table content height is the maximum of the computed table height from style and the
// sum of computed row heights from row layout plus size from borders and spacing.
let table_height_from_style = self
.table
.style
.content_box_size(containing_block, &self.pbm)
// When block-size doesn't compute to auto, `containing_block_for children` will have
// the resulting length, properly clamped between min-block-size and max-block-size.
let style = &self.table.style;
let table_height_from_style = match style
.content_box_size(containing_block_for_table, &self.pbm)
.block
.auto_is(Length::zero)
.into();
{
LengthPercentage(_) => containing_block_for_children.block_size,
Auto => style
.content_min_box_size(containing_block_for_table, &self.pbm)
.block
.map(Au::from),
}
.auto_is(Au::zero);
let border_spacing = self.table.border_spacing();
let border_and_spacing = self.pbm.border.block_sum() +
border_spacing.block * (self.table.size.height as i32 + 1);
let table_height_from_rows = row_sizes.iter().sum::<Au>() + border_and_spacing;
let final_table_height = table_height_from_rows.max(table_height_from_style);
let block_border_spacing = if self.table.size.height > 0 {
self.table.border_spacing().block * (self.table.size.height as i32 + 1)
} else {
Au::zero()
};
let table_height_from_rows = row_sizes.iter().sum::<Au>() + block_border_spacing;
self.final_table_height = table_height_from_rows.max(table_height_from_style);
// If the table height is defined by the rows sizes, there is no extra space to distribute
// to rows.
if final_table_height == table_height_from_rows {
if self.final_table_height == table_height_from_rows {
self.row_sizes = row_sizes;
return;
}
@ -1357,10 +1393,10 @@ impl<'a> TableLayout<'a> {
// space.
// TODO: This should first distribute space to row groups and then to rows.
self.distribute_extra_size_to_rows(
final_table_height - table_height_from_rows,
self.final_table_height - table_height_from_rows,
0..self.table.size.height,
&mut row_sizes,
Some(final_table_height),
Some(self.final_table_height),
false, /* rowspan_distribution */
);
self.row_sizes = row_sizes;
@ -1378,7 +1414,8 @@ impl<'a> TableLayout<'a> {
if self.table.size.width == 0 || self.table.size.height == 0 {
return IndependentLayout {
fragments,
content_block_size: Au::zero(),
content_block_size: self.final_table_height,
content_inline_size_for_table: Some(self.assignable_width),
baselines,
};
}
@ -1487,6 +1524,7 @@ impl<'a> TableLayout<'a> {
IndependentLayout {
fragments,
content_block_size: dimensions.table_rect.max_block_position(),
content_inline_size_for_table: Some(dimensions.table_rect.max_inline_position()),
baselines,
}
}
@ -1780,10 +1818,16 @@ impl Table {
&self,
layout_context: &LayoutContext,
positioning_context: &mut PositioningContext,
containing_block: &ContainingBlock,
containing_block_for_children: &ContainingBlock,
containing_block_for_table: &ContainingBlock,
) -> IndependentLayout {
let mut table_layout = TableLayout::new(self);
table_layout.compute_measures(layout_context, positioning_context, containing_block);
table_layout.compute_measures(
layout_context,
positioning_context,
containing_block_for_children,
containing_block_for_table,
);
table_layout.layout(positioning_context)
}
}

View file

@ -1,2 +0,0 @@
[floats-014.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-015.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-wrap-bfc-001-left-table.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-wrap-bfc-001-right-table.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-wrap-bfc-003-left-table.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-wrap-bfc-003-right-table.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[floats-wrap-bfc-004.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[caption-side-applies-to-017.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[separated-border-model-007.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[separated-border-model-008.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[separated-border-model-009.xht]
expected: FAIL

View file

@ -1,2 +0,0 @@
[table-backgrounds-bs-table-001.xht]
expected: FAIL

View file

@ -1,24 +0,0 @@
[absolute-tables-001.html]
[.tbl 1]
expected: FAIL
[.tbl 2]
expected: FAIL
[.tbl 3]
expected: FAIL
[.tbl 4]
expected: FAIL
[.tbl 5]
expected: FAIL
[.tbl 6]
expected: FAIL
[.tbl 7]
expected: FAIL
[.tbl 8]
expected: FAIL

View file

@ -1,2 +0,0 @@
[anonymous-table-cell-margin-collapsing.html]
expected: FAIL

View file

@ -1,15 +0,0 @@
[bounding-box-computation-2.html]
[Table-cell is 100px tall]
expected: FAIL
[Table-row is 100px tall]
expected: FAIL
[Table-row-group is 100px tall]
expected: FAIL
[Table-column is 100px tall]
expected: FAIL
[Table-column-group is 100px tall]
expected: FAIL

View file

@ -1,7 +1,4 @@
[bounding-box-computation-3.html]
[Control test: Table width is 120px]
expected: FAIL
[First (empty) table-row-group should be located at 10px left]
expected: FAIL

View file

@ -8,9 +8,6 @@
[main table 5]
expected: FAIL
[main table 6]
expected: FAIL
[main table 10]
expected: FAIL
@ -20,9 +17,6 @@
[main table 12]
expected: FAIL
[main table 13]
expected: FAIL
[main table 9]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dynamic-rowspan-change.html]
[main table 1]
expected: FAIL
[main table 2]
expected: FAIL

View file

@ -1,2 +0,0 @@
[html-display-table.html]
expected: FAIL

View file

@ -1,9 +0,0 @@
[html-to-css-mapping-1.html]
[HTML -> CSS Mapping is applied correctly on proper table markup (border-spacing, padding)]
expected: FAIL
[HTML -> CSS Mapping is applied correctly on improper table markup (no td => border-spacing, but no padding)]
expected: FAIL
[HTML -> CSS Mapping is applied correctly on empty table markup (no content => no border-spacing, no padding)]
expected: FAIL

View file

@ -1,15 +1,9 @@
[html5-table-formatting-1.html]
[Empty tables can still get a lsyout]
expected: FAIL
[Empty tables do not take table-columns into account]
expected: FAIL
[Table-columns are taken into account after missing cells are generated (empty line)]
expected: FAIL
[Table-columns are taken into account after missing cells are generated (partially empty line)]
expected: FAIL
[Table-columns are taken into account after missing cells are generated (non-empty line)]
[Empty tables do not take table-rows into account]
expected: FAIL

View file

@ -5,20 +5,5 @@
[Border-spacing is added between any two unmerged columns (1)]
expected: FAIL
[Border-spacing is added between any two unmerged rows (1)]
expected: FAIL
[Border-spacing is added between any two unmerged columns (2)]
expected: FAIL
[Border-spacing is added between any two unmerged columns (3)]
expected: FAIL
[Border-spacing is added between any two unmerged columns (4)]
expected: FAIL
[Border-spacing is added between any two unmerged columns (5)]
expected: FAIL
[Explicitely defined rows are not merged]
expected: FAIL

View file

@ -1,13 +1,7 @@
[html5-table-formatting-3.html]
[Control test for table-cell padding and border-spacing, etc (width)]
expected: FAIL
[Anonymous consecutive columns spanned by the same set of cells are merged]
expected: FAIL
[Explicitely-defined consecutive columns spanned by the same set of cells are not merged]
expected: FAIL
[Explicitely-defined consecutive columns spanned by the same set of cells are not merged, and cells span across border-spacing]
expected: FAIL

View file

@ -1,3 +0,0 @@
[html5-table-formatting-fixed-layout-1.html]
[Redundant columns of fixed-layout tables are not being merged]
expected: FAIL

View file

@ -1,2 +0,0 @@
[max-height-table.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[min-max-size-table-content-box.html]
expected: FAIL

View file

@ -1,2 +0,0 @@
[subpixel-table-cell-width-001.html]
expected: FAIL

View file

@ -8,9 +8,6 @@
[table 3]
expected: FAIL
[table 6]
expected: FAIL
[table 7]
expected: FAIL

View file

@ -11,8 +11,5 @@
[table 4]
expected: FAIL
[table 5]
expected: FAIL
[table 6]
expected: FAIL

View file

@ -59,9 +59,6 @@
[table 24]
expected: FAIL
[table 25]
expected: FAIL
[table 26]
expected: FAIL

View file

@ -2,48 +2,24 @@
[table 1]
expected: FAIL
[table 2]
expected: FAIL
[table 3]
expected: FAIL
[table 5]
expected: FAIL
[table 6]
expected: FAIL
[table 7]
expected: FAIL
[table 8]
expected: FAIL
[table 9]
expected: FAIL
[table 10]
expected: FAIL
[table 11]
expected: FAIL
[table 12]
expected: FAIL
[table 13]
expected: FAIL
[table 14]
expected: FAIL
[table 15]
expected: FAIL
[table 16]
expected: FAIL
[table 17]
expected: FAIL
@ -53,9 +29,6 @@
[table 19]
expected: FAIL
[table 20]
expected: FAIL
[table 21]
expected: FAIL
@ -74,23 +47,14 @@
[table 26]
expected: FAIL
[table 27]
expected: FAIL
[table 28]
expected: FAIL
[table 29]
expected: FAIL
[table 30]
expected: FAIL
[table 31]
expected: FAIL
[table 32]
expected: FAIL
[table 33]
expected: FAIL
[table 4]
expected: FAIL

View file

@ -13,3 +13,6 @@
[table's width inside grid width:max-content is infinite]
expected: FAIL
[table's width inside a table cell is infinite]
expected: FAIL

View file

@ -5,32 +5,11 @@
[table 5]
expected: FAIL
[table 6]
[table 16]
expected: FAIL
[table 7]
expected: FAIL
[table 8]
expected: FAIL
[table 9]
expected: FAIL
[table 11]
expected: FAIL
[table 12]
[table 1]
expected: FAIL
[table 13]
expected: FAIL
[table 14]
expected: FAIL
[table 15]
expected: FAIL
[table 16]
expected: FAIL

View file

@ -5,8 +5,5 @@
[table 2]
expected: FAIL
[table 5]
expected: FAIL
[table 3]
expected: FAIL

View file

@ -1,7 +1,4 @@
[table-width-redistribution-fixed.html]
[table 1]
expected: FAIL
[table 3]
expected: FAIL

View file

@ -41,8 +41,5 @@
[table 20]
expected: FAIL
[table 21]
expected: FAIL
[table 22]
expected: FAIL

View file

@ -2,9 +2,6 @@
[table 1]
expected: FAIL
[table 2]
expected: FAIL
[table 3]
expected: FAIL
@ -31,3 +28,6 @@
[table 10]
expected: FAIL
[table 2]
expected: FAIL

View file

@ -5,9 +5,6 @@
[table 2]
expected: FAIL
[table 5]
expected: FAIL
[table 6]
expected: FAIL
@ -23,8 +20,5 @@
[table 11]
expected: FAIL
[table 13]
expected: FAIL
[table 14]
expected: FAIL

View file

@ -1,3 +0,0 @@
[visibility-hidden-col-001.html]
[visibility:hidden doesn't change table width]
expected: FAIL

View file

@ -1,3 +0,0 @@
[visibility-hidden-nested-001.html]
[table visibility:hidden doesn't change table width]
expected: FAIL

View file

@ -1,12 +1,3 @@
[computing-column-measure-0.html]
[Checking intermediate min-content width for span 1 (1)]
expected: FAIL
[Checking intermediate min-content width for span 1 (2)]
expected: FAIL
[Checking intermediate min-content width for span 1 (3)]
expected: FAIL
[Checking intermediate min-content width for span 1 (4)]
expected: FAIL

View file

@ -1,3 +0,0 @@
[computing-column-measure-2.html]
[Table recalculations should match the reference]
expected: FAIL

View file

@ -1,3 +0,0 @@
[computing-table-width-1.html]
[The box should be 300px since that is the size of the content]
expected: FAIL

View file

@ -1,3 +0,0 @@
[distribution-algo-1.html]
[The box should be 300px since that is the size of the content]
expected: FAIL

View file

@ -1,3 +0,0 @@
[distribution-algo-2.html]
[The box should be 300px since that is the size of the content]
expected: FAIL

View file

@ -1,3 +0,0 @@
[distribution-algo-min-content-guess.html]
[The box should be 300px since that is the size of the content]
expected: FAIL

View file

@ -1,2 +0,0 @@
[width.html]
expected: FAIL