layout: Generalize ContainingBlock's block size to a SizeConstraint (#34946)

It used to be an `AuOrAuto`, turning it into a `SizeConstraint` allows
passing the information about the min and max constraints when the
containing block doesn't have a definite block size.

This will be useful for table layout.

Note that in most cases we were already constructing the containing
block from a `SizeConstraint`, but we were calling `to_auto_or()` to
turn it into an `AuOrAuto`.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-01-13 02:25:33 -08:00 committed by GitHub
parent de780dcde4
commit f66cd172d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 71 additions and 69 deletions

View file

@ -35,7 +35,7 @@ use crate::fragment_tree::{
};
use crate::geom::{
AuOrAuto, LogicalRect, LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides,
Size, ToLogical, ToLogicalWithContainingBlock,
Size, SizeConstraint, ToLogical, ToLogicalWithContainingBlock,
};
use crate::positioned::{relative_adjustement, PositioningContext, PositioningContextLength};
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
@ -1228,7 +1228,7 @@ impl<'a> TableLayout<'a> {
let containing_block_for_children = ContainingBlock {
size: ContainingBlockSize {
inline: total_cell_width,
block: AuOrAuto::Auto,
block: SizeConstraint::default(),
},
style: &cell.base.style,
};
@ -1561,7 +1561,7 @@ impl<'a> TableLayout<'a> {
.content_box_size_deprecated(containing_block_for_table, &self.pbm)
.block
{
LengthPercentage(_) => containing_block_for_children.size.block,
LengthPercentage(_) => containing_block_for_children.size.block.to_auto_or(),
Auto => style
.content_min_box_size_deprecated(containing_block_for_table, &self.pbm)
.block
@ -1605,7 +1605,7 @@ impl<'a> TableLayout<'a> {
let containing_block = &ContainingBlock {
size: ContainingBlockSize {
inline: self.table_width + self.pbm.padding_border_sums.inline,
block: AuOrAuto::Auto,
block: SizeConstraint::default(),
},
style: &self.table.style,
};
@ -2330,7 +2330,7 @@ impl<'a> RowFragmentLayout<'a> {
let containing_block = ContainingBlock {
size: ContainingBlockSize {
inline: rect.size.inline,
block: AuOrAuto::LengthPercentage(rect.size.block),
block: SizeConstraint::Definite(rect.size.block),
},
style: table_style,
};
@ -2360,7 +2360,7 @@ impl<'a> RowFragmentLayout<'a> {
self.rect.start_corner -= row_group_layout.rect.start_corner;
(
row_group_layout.rect.size.inline,
AuOrAuto::LengthPercentage(row_group_layout.rect.size.block),
SizeConstraint::Definite(row_group_layout.rect.size.block),
)
} else {
(