diff options
author | Oriol Brufau <obrufau@igalia.com> | 2024-09-20 16:48:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 14:48:27 +0000 |
commit | 9597390d2bc6f68492cc9fae6287d0a456cdb3c1 (patch) | |
tree | 470d803926620b39f272c38eb455ec4093eec48e /components/layout/model.rs | |
parent | 4bde9af5159b18eba1b65256de0d2dda328a1eb2 (diff) | |
download | servo-9597390d2bc6f68492cc9fae6287d0a456cdb3c1.tar.gz servo-9597390d2bc6f68492cc9fae6287d0a456cdb3c1.zip |
Enable min-content, max-content, fit-content and stretch (#33492)
For the sizing properties.
We don't actually support them yet, just treating them as
the initial value.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/layout/model.rs')
-rw-r--r-- | components/layout/model.rs | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/components/layout/model.rs b/components/layout/model.rs index ee6d9e334c8..83b3e3a8879 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -147,14 +147,12 @@ impl MarginCollapseInfo { ) -> (CollapsibleMargins, Au) { let state = match self.state { MarginCollapseState::AccumulatingCollapsibleTopMargin => { + let content_block_size = fragment.style().content_block_size(); may_collapse_through = may_collapse_through && - match fragment.style().content_block_size() { - Size::Auto => true, - Size::LengthPercentage(ref lp) => { - lp.is_definitely_zero() || - lp.maybe_to_used_value(containing_block_size).is_none() - }, - }; + content_block_size.is_definitely_zero() || + content_block_size + .maybe_to_used_value(containing_block_size) + .is_none(); if may_collapse_through { if fragment.style.min_block_size().is_auto() || @@ -522,12 +520,7 @@ impl MaybeAuto { /// /// `style_length`: content size as given in the CSS. pub fn style_length(style_length: &Size, container_size: Option<Au>) -> MaybeAuto { - match style_length { - Size::Auto => MaybeAuto::Auto, - Size::LengthPercentage(ref lp) => { - MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size)) - }, - } + MaybeAuto::from_option(style_length.maybe_to_used_value(container_size)) } #[inline] @@ -595,17 +588,10 @@ impl SizeConstraint { max_size: &MaxSize, border: Option<Au>, ) -> SizeConstraint { - let mut min_size = match min_size { - Size::Auto => Au(0), - Size::LengthPercentage(ref lp) => { - lp.maybe_to_used_value(container_size).unwrap_or(Au(0)) - }, - }; - - let mut max_size = match max_size { - MaxSize::None => None, - MaxSize::LengthPercentage(ref lp) => lp.maybe_to_used_value(container_size), - }; + let mut min_size = min_size + .maybe_to_used_value(container_size) + .unwrap_or(Au(0)); + let mut max_size = max_size.maybe_to_used_value(container_size); // Make sure max size is not smaller than min size. max_size = max_size.map(|x| max(x, min_size)); |