mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Allow table-layout:fixed to shrink cells to less than the border+padding (#33442)
A table cell with `width: auto` in fixed layout will now have an outer min-content width of zero, even if it has borders or padding. In a way, this is like allowing the content-box width to become negative. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
b4a0a240a7
commit
a2b8bdb903
14 changed files with 14 additions and 33 deletions
|
@ -203,7 +203,7 @@ impl<'a> TableLayout<'a> {
|
|||
block: padding.block_sum() + border.block_sum(),
|
||||
};
|
||||
|
||||
let (size, min_size, max_size) =
|
||||
let (size, min_size, max_size, inline_size_is_auto) =
|
||||
get_outer_sizes_from_style(&cell.style, writing_mode, &padding_border_sums);
|
||||
let percentage_contribution =
|
||||
get_size_percentage_contribution_from_style(&cell.style, writing_mode);
|
||||
|
@ -233,7 +233,13 @@ impl<'a> TableLayout<'a> {
|
|||
|
||||
// These formulas differ from the spec, but seem to match Gecko and Blink.
|
||||
let outer_min_content_width = if is_in_fixed_mode {
|
||||
size.inline.min(max_size.inline).max(min_size.inline)
|
||||
if inline_size_is_auto {
|
||||
// This is an outer size, but we deliberately ignore borders and padding.
|
||||
// This is like allowing the content-box width to be negative.
|
||||
Au::zero()
|
||||
} else {
|
||||
size.inline.min(max_size.inline).max(min_size.inline)
|
||||
}
|
||||
} else {
|
||||
inline_content_sizes
|
||||
.min_content
|
||||
|
@ -714,7 +720,7 @@ impl<'a> TableLayout<'a> {
|
|||
block: padding.block_sum() + border.block_sum() + margin.block_sum(),
|
||||
};
|
||||
|
||||
let (size, min_size, max_size) =
|
||||
let (size, min_size, max_size, _) =
|
||||
get_outer_sizes_from_style(&context.style, writing_mode, &padding_border_sums);
|
||||
let size_is_auto = context.style.box_size(writing_mode).inline.is_auto();
|
||||
|
||||
|
@ -2566,7 +2572,7 @@ impl Table {
|
|||
None => return CellOrTrackMeasure::zero(),
|
||||
};
|
||||
|
||||
let (size, min_size, max_size) =
|
||||
let (size, min_size, max_size, _) =
|
||||
get_outer_sizes_from_style(&column.style, writing_mode, &LogicalVec2::zero());
|
||||
let percentage_contribution =
|
||||
get_size_percentage_contribution_from_style(&column.style, writing_mode);
|
||||
|
@ -2755,7 +2761,7 @@ fn get_outer_sizes_from_style(
|
|||
style: &Arc<ComputedValues>,
|
||||
writing_mode: WritingMode,
|
||||
padding_border_sums: &LogicalVec2<Au>,
|
||||
) -> (LogicalVec2<Au>, LogicalVec2<Au>, LogicalVec2<Au>) {
|
||||
) -> (LogicalVec2<Au>, LogicalVec2<Au>, LogicalVec2<Au>, bool) {
|
||||
let box_sizing = style.get_position().box_sizing;
|
||||
let outer_size = |size: LogicalVec2<Au>| match box_sizing {
|
||||
BoxSizing::ContentBox => size + *padding_border_sums,
|
||||
|
@ -2774,10 +2780,12 @@ fn get_outer_sizes_from_style(
|
|||
.map_or(MAX_AU, Au::from)
|
||||
};
|
||||
|
||||
let size = style.box_size(writing_mode);
|
||||
(
|
||||
outer_size(style.box_size(writing_mode).map(get_size_for_axis)),
|
||||
outer_size(size.map(get_size_for_axis)),
|
||||
outer_size(style.min_box_size(writing_mode).map(get_size_for_axis)),
|
||||
outer_size(style.max_box_size(writing_mode).map(get_max_size_for_axis)),
|
||||
size.inline.is_auto(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a01.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a02.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a03.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a04.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a05.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003a06.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d01.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d02.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d03.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d04.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d05.xht]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[fixed-table-layout-003d06.xht]
|
||||
expected: FAIL
|
|
@ -1,7 +1,4 @@
|
|||
[table-width-redistribution-fixed-padding.html]
|
||||
[table 6]
|
||||
expected: FAIL
|
||||
|
||||
[table 10]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue