diff options
Diffstat (limited to 'components/layout/model.rs')
-rw-r--r-- | components/layout/model.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/components/layout/model.rs b/components/layout/model.rs index 8382c9af7d0..a6d64e557ac 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -408,13 +408,21 @@ impl MaybeAuto { MaybeAuto::Specified(containing_length.scale_by(percent)) } LengthOrPercentageOrAuto::Calc(calc) => { - MaybeAuto::Specified(calc.length() + containing_length.scale_by(calc.percentage())) + MaybeAuto::from_option(calc.to_computed(Some(containing_length))) } LengthOrPercentageOrAuto::Length(length) => MaybeAuto::Specified(length) } } #[inline] + pub fn from_option(au: Option<Au>) -> MaybeAuto { + match au { + Some(l) => MaybeAuto::Specified(l), + _ => MaybeAuto::Auto, + } + } + + #[inline] pub fn specified_or_default(&self, default: Au) -> Au { match *self { MaybeAuto::Auto => default, @@ -455,8 +463,7 @@ pub fn specified_or_none(length: LengthOrPercentageOrNone, containing_length: Au match length { LengthOrPercentageOrNone::None => None, LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent)), - LengthOrPercentageOrNone::Calc(calc) => - Some(containing_length.scale_by(calc.percentage()) + calc.length()), + LengthOrPercentageOrNone::Calc(calc) => calc.to_computed(Some(containing_length)), LengthOrPercentageOrNone::Length(length) => Some(length), } } |