Consistent resolution of cyclic percentages in min sizing properties (#33988)

The spec says that cyclic percentages in min sizing properties should
be resolved against zero when computing intrinsic contributions.
We were already doing that in the inline axis, but we were treating
the entire expression as `auto` in the block axis.

With this patch we will follow the spec in both axes. But note that
browsers don't follo the spec in either axis, so we may have to revisit
(see https://github.com/w3c/csswg-drafts/issues/10969).

calc-min-height-block-1.html now fails because it tests what browsers
do instead of what the spec says.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-10-24 14:03:32 +02:00 committed by GitHub
parent 202cb53d5b
commit 9ad59d1459
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 125 additions and 43 deletions

View file

@ -67,6 +67,29 @@ impl<T: Default> Default for LogicalVec2<T> {
}
}
impl<T> LogicalVec2<T> {
pub fn map_inline_and_block_axes<U>(
&self,
inline_f: impl FnOnce(&T) -> U,
block_f: impl FnOnce(&T) -> U,
) -> LogicalVec2<U> {
LogicalVec2 {
inline: inline_f(&self.inline),
block: block_f(&self.block),
}
}
}
impl<T: Clone> LogicalVec2<Size<T>> {
pub fn map_inline_and_block_sizes<U>(
&self,
inline_f: impl FnOnce(T) -> U,
block_f: impl FnOnce(T) -> U,
) -> LogicalVec2<Size<U>> {
self.map_inline_and_block_axes(|size| size.map(inline_f), |size| size.map(block_f))
}
}
impl<T: Clone> LogicalVec2<T> {
pub fn from_physical_size(physical_size: &PhysicalSize<T>, mode: WritingMode) -> Self {
// https://drafts.csswg.org/css-writing-modes/#logical-to-physical
@ -734,15 +757,14 @@ impl LogicalVec2<Size<LengthPercentage>> {
&self,
containing_block: &ContainingBlock,
) -> LogicalVec2<Size<Au>> {
LogicalVec2 {
inline: self
.inline
.map(|lp| lp.to_used_value(containing_block.inline_size)),
block: self
.block
.maybe_map(|lp| lp.maybe_to_used_value(containing_block.block_size.non_auto()))
.unwrap_or_default(),
}
self.map_inline_and_block_axes(
|inline_size| inline_size.map(|lp| lp.to_used_value(containing_block.inline_size)),
|block_size| {
block_size
.maybe_map(|lp| lp.maybe_to_used_value(containing_block.block_size.non_auto()))
.unwrap_or_default()
},
)
}
pub(crate) fn maybe_percentages_relative_to_basis(