mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
layout: Remove calculate_hypothetical_cross_size()
(#35821)
One of the callers was only used for an assert, and it was passing an inline size argument to a parameter expecting a block size, so it wasn't making much sense anyways. Just inline the code into the other caller, and for consistency remove the assert for replaced elements too. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
a5cf04c479
commit
0419a7818d
1 changed files with 23 additions and 34 deletions
|
@ -2021,7 +2021,6 @@ impl FlexItem<'_> {
|
||||||
Size::FitContent.into(),
|
Size::FitContent.into(),
|
||||||
flex_axis.vec2_to_flow_relative(self.pbm_auto_is_zero),
|
flex_axis.vec2_to_flow_relative(self.pbm_auto_is_zero),
|
||||||
);
|
);
|
||||||
let hypothetical_cross_size = flex_axis.vec2_to_flex_relative(size).cross;
|
|
||||||
|
|
||||||
if let Some(non_stretch_layout_result) = non_stretch_layout_result {
|
if let Some(non_stretch_layout_result) = non_stretch_layout_result {
|
||||||
if non_stretch_layout_result
|
if non_stretch_layout_result
|
||||||
|
@ -2030,14 +2029,11 @@ impl FlexItem<'_> {
|
||||||
size,
|
size,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert_eq!(
|
|
||||||
non_stretch_layout_result.hypothetical_cross_size,
|
|
||||||
hypothetical_cross_size
|
|
||||||
);
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hypothetical_cross_size = flex_axis.vec2_to_flex_relative(size).cross;
|
||||||
let fragments = replaced.make_fragments(
|
let fragments = replaced.make_fragments(
|
||||||
flex_context.layout_context,
|
flex_context.layout_context,
|
||||||
item_style,
|
item_style,
|
||||||
|
@ -2061,28 +2057,6 @@ impl FlexItem<'_> {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
IndependentFormattingContextContents::NonReplaced(non_replaced) => {
|
IndependentFormattingContextContents::NonReplaced(non_replaced) => {
|
||||||
let calculate_hypothetical_cross_size = |content_block_size: Au| {
|
|
||||||
if !cross_axis_is_item_block_axis {
|
|
||||||
return inline_size;
|
|
||||||
}
|
|
||||||
// This means that an auto size with stretch alignment will behave different than
|
|
||||||
// a stretch size. That's not what the spec says, but matches other browsers.
|
|
||||||
// To be discussed in https://github.com/w3c/csswg-drafts/issues/11784.
|
|
||||||
let stretch_size = containing_block
|
|
||||||
.size
|
|
||||||
.block
|
|
||||||
.to_definite()
|
|
||||||
.map(|size| Au::zero().max(size - self.pbm_auto_is_zero.cross));
|
|
||||||
self.content_cross_sizes.resolve(
|
|
||||||
Direction::Block,
|
|
||||||
Size::FitContent,
|
|
||||||
Au::zero(),
|
|
||||||
stretch_size,
|
|
||||||
|| content_block_size.into(),
|
|
||||||
self.is_table(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
let item_as_containing_block = ContainingBlock {
|
let item_as_containing_block = ContainingBlock {
|
||||||
size: ContainingBlockSize {
|
size: ContainingBlockSize {
|
||||||
inline: inline_size,
|
inline: inline_size,
|
||||||
|
@ -2095,12 +2069,6 @@ impl FlexItem<'_> {
|
||||||
if non_stretch_layout_result
|
if non_stretch_layout_result
|
||||||
.compatible_with_containing_block_size(&item_as_containing_block)
|
.compatible_with_containing_block_size(&item_as_containing_block)
|
||||||
{
|
{
|
||||||
assert_eq!(
|
|
||||||
non_stretch_layout_result.hypothetical_cross_size,
|
|
||||||
calculate_hypothetical_cross_size(
|
|
||||||
non_stretch_layout_result.content_size.inline,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2135,6 +2103,27 @@ impl FlexItem<'_> {
|
||||||
FragmentFlags::SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM))
|
FragmentFlags::SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let hypothetical_cross_size = if cross_axis_is_item_block_axis {
|
||||||
|
// This means that an auto size with stretch alignment will behave different than
|
||||||
|
// a stretch size. That's not what the spec says, but matches other browsers.
|
||||||
|
// To be discussed in https://github.com/w3c/csswg-drafts/issues/11784.
|
||||||
|
let stretch_size = containing_block
|
||||||
|
.size
|
||||||
|
.block
|
||||||
|
.to_definite()
|
||||||
|
.map(|size| Au::zero().max(size - self.pbm_auto_is_zero.cross));
|
||||||
|
self.content_cross_sizes.resolve(
|
||||||
|
Direction::Block,
|
||||||
|
Size::FitContent,
|
||||||
|
Au::zero(),
|
||||||
|
stretch_size,
|
||||||
|
|| content_block_size.into(),
|
||||||
|
self.is_table(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
inline_size
|
||||||
|
};
|
||||||
|
|
||||||
let item_writing_mode_is_orthogonal_to_container_writing_mode =
|
let item_writing_mode_is_orthogonal_to_container_writing_mode =
|
||||||
flex_context.config.writing_mode.is_horizontal() !=
|
flex_context.config.writing_mode.is_horizontal() !=
|
||||||
item_style.writing_mode.is_horizontal();
|
item_style.writing_mode.is_horizontal();
|
||||||
|
@ -2161,7 +2150,7 @@ impl FlexItem<'_> {
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(FlexItemLayoutResult {
|
Some(FlexItemLayoutResult {
|
||||||
hypothetical_cross_size: calculate_hypothetical_cross_size(content_block_size),
|
hypothetical_cross_size,
|
||||||
fragments,
|
fragments,
|
||||||
positioning_context,
|
positioning_context,
|
||||||
baseline_relative_to_margin_box,
|
baseline_relative_to_margin_box,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue