Allow creating a ContentSizes from Au (#33208)

No change in behavior, it just simplies some code a little bit.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-08-27 17:22:47 +02:00 committed by GitHub
parent dbd0a79b3e
commit 50eb69a7e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 36 deletions

View file

@ -1940,20 +1940,16 @@ impl FlexItemBox {
.outer_inline_content_sizes(layout_context, container_writing_mode, || {
automatic_min_size
}),
FlexAxis::Column => {
let size = self.layout_for_block_content_size(
FlexAxis::Column => self
.layout_for_block_content_size(
flex_context_getter(),
&pbm,
content_box_size,
content_min_size_no_auto,
content_max_size,
IntrinsicSizingMode::Contribution,
);
ContentSizes {
min_content: size,
max_content: size,
}
},
)
.into(),
};
let content_box_size = flex_axis.vec2_to_flex_relative(content_box_size);

View file

@ -255,14 +255,10 @@ impl ReplacedContent {
// FIXME: min/max-content of replaced elements is not defined in
// https://dbaron.org/css/intrinsic/
// This seems sensible?
let inline = self
.flow_relative_intrinsic_size(style)
self.flow_relative_intrinsic_size(style)
.inline
.unwrap_or(Au::zero());
ContentSizes {
min_content: inline,
max_content: inline,
}
.unwrap_or(Au::zero())
.into()
}
pub fn make_fragments(

View file

@ -68,10 +68,7 @@ impl ContentSizes {
impl Zero for ContentSizes {
fn zero() -> Self {
Self {
min_content: Au::zero(),
max_content: Au::zero(),
}
Au::zero().into()
}
fn is_zero(&self) -> bool {
@ -103,6 +100,15 @@ impl ContentSizes {
}
}
impl From<Au> for ContentSizes {
fn from(size: Au) -> Self {
Self {
min_content: size,
max_content: size,
}
}
}
pub(crate) fn outer_inline(
style: &ComputedValues,
containing_block_writing_mode: WritingMode,
@ -159,10 +165,7 @@ pub(crate) fn outer_inline(
BoxSizing::ContentBox => clamped + pb_lengths,
BoxSizing::BorderBox => clamped,
};
ContentSizes {
min_content: border_box_size,
max_content: border_box_size,
}
border_box_size.into()
},
None => get_content_size().map(|content_box_size| {
match box_sizing {

View file

@ -248,10 +248,7 @@ impl<'a> TableLayout<'a> {
// These sizes are incorporated after the first row layout pass, when the block size
// of the layout is known.
let block_measure = CellOrTrackMeasure {
content_sizes: ContentSizes {
min_content: size.block,
max_content: size.block,
},
content_sizes: size.block.into(),
percentage: percentage_contribution.block,
};
@ -1204,14 +1201,10 @@ impl<'a> TableLayout<'a> {
continue;
};
let content_size_from_layout = ContentSizes {
min_content: layout.layout.content_block_size,
max_content: layout.layout.content_block_size,
};
self.cell_measures[row_index][column_index]
.block
.content_sizes
.max_assign(content_size_from_layout);
.max_assign(layout.layout.content_block_size.into());
}
}
}
@ -2524,10 +2517,7 @@ impl Table {
get_size_percentage_contribution_from_style(&row.style, writing_mode);
CellOrTrackMeasure {
content_sizes: ContentSizes {
min_content: size,
max_content: size,
},
content_sizes: size.into(),
percentage: percentage_contribution.block,
}
}