mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
dbd0a79b3e
commit
50eb69a7e0
4 changed files with 21 additions and 36 deletions
|
@ -1940,20 +1940,16 @@ impl FlexItemBox {
|
||||||
.outer_inline_content_sizes(layout_context, container_writing_mode, || {
|
.outer_inline_content_sizes(layout_context, container_writing_mode, || {
|
||||||
automatic_min_size
|
automatic_min_size
|
||||||
}),
|
}),
|
||||||
FlexAxis::Column => {
|
FlexAxis::Column => self
|
||||||
let size = self.layout_for_block_content_size(
|
.layout_for_block_content_size(
|
||||||
flex_context_getter(),
|
flex_context_getter(),
|
||||||
&pbm,
|
&pbm,
|
||||||
content_box_size,
|
content_box_size,
|
||||||
content_min_size_no_auto,
|
content_min_size_no_auto,
|
||||||
content_max_size,
|
content_max_size,
|
||||||
IntrinsicSizingMode::Contribution,
|
IntrinsicSizingMode::Contribution,
|
||||||
);
|
)
|
||||||
ContentSizes {
|
.into(),
|
||||||
min_content: size,
|
|
||||||
max_content: size,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let content_box_size = flex_axis.vec2_to_flex_relative(content_box_size);
|
let content_box_size = flex_axis.vec2_to_flex_relative(content_box_size);
|
||||||
|
|
|
@ -255,14 +255,10 @@ impl ReplacedContent {
|
||||||
// FIXME: min/max-content of replaced elements is not defined in
|
// FIXME: min/max-content of replaced elements is not defined in
|
||||||
// https://dbaron.org/css/intrinsic/
|
// https://dbaron.org/css/intrinsic/
|
||||||
// This seems sensible?
|
// This seems sensible?
|
||||||
let inline = self
|
self.flow_relative_intrinsic_size(style)
|
||||||
.flow_relative_intrinsic_size(style)
|
|
||||||
.inline
|
.inline
|
||||||
.unwrap_or(Au::zero());
|
.unwrap_or(Au::zero())
|
||||||
ContentSizes {
|
.into()
|
||||||
min_content: inline,
|
|
||||||
max_content: inline,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_fragments(
|
pub fn make_fragments(
|
||||||
|
|
|
@ -68,10 +68,7 @@ impl ContentSizes {
|
||||||
|
|
||||||
impl Zero for ContentSizes {
|
impl Zero for ContentSizes {
|
||||||
fn zero() -> Self {
|
fn zero() -> Self {
|
||||||
Self {
|
Au::zero().into()
|
||||||
min_content: Au::zero(),
|
|
||||||
max_content: Au::zero(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_zero(&self) -> bool {
|
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(
|
pub(crate) fn outer_inline(
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
containing_block_writing_mode: WritingMode,
|
containing_block_writing_mode: WritingMode,
|
||||||
|
@ -159,10 +165,7 @@ pub(crate) fn outer_inline(
|
||||||
BoxSizing::ContentBox => clamped + pb_lengths,
|
BoxSizing::ContentBox => clamped + pb_lengths,
|
||||||
BoxSizing::BorderBox => clamped,
|
BoxSizing::BorderBox => clamped,
|
||||||
};
|
};
|
||||||
ContentSizes {
|
border_box_size.into()
|
||||||
min_content: border_box_size,
|
|
||||||
max_content: border_box_size,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
None => get_content_size().map(|content_box_size| {
|
None => get_content_size().map(|content_box_size| {
|
||||||
match box_sizing {
|
match box_sizing {
|
||||||
|
|
|
@ -248,10 +248,7 @@ impl<'a> TableLayout<'a> {
|
||||||
// These sizes are incorporated after the first row layout pass, when the block size
|
// These sizes are incorporated after the first row layout pass, when the block size
|
||||||
// of the layout is known.
|
// of the layout is known.
|
||||||
let block_measure = CellOrTrackMeasure {
|
let block_measure = CellOrTrackMeasure {
|
||||||
content_sizes: ContentSizes {
|
content_sizes: size.block.into(),
|
||||||
min_content: size.block,
|
|
||||||
max_content: size.block,
|
|
||||||
},
|
|
||||||
percentage: percentage_contribution.block,
|
percentage: percentage_contribution.block,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1204,14 +1201,10 @@ impl<'a> TableLayout<'a> {
|
||||||
continue;
|
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]
|
self.cell_measures[row_index][column_index]
|
||||||
.block
|
.block
|
||||||
.content_sizes
|
.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);
|
get_size_percentage_contribution_from_style(&row.style, writing_mode);
|
||||||
|
|
||||||
CellOrTrackMeasure {
|
CellOrTrackMeasure {
|
||||||
content_sizes: ContentSizes {
|
content_sizes: size.into(),
|
||||||
min_content: size,
|
|
||||||
max_content: size,
|
|
||||||
},
|
|
||||||
percentage: percentage_contribution.block,
|
percentage: percentage_contribution.block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue