diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 78c94e26215..2ea32e99845 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -166,7 +166,7 @@ ${helpers.predefined_type("order", "Integer", "0", logical=False, spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", extra_prefixes="webkit", - animation_value_type="ComputedValue")} + animation_value_type="MozLength")} % else: // FIXME: This property should be animatable. ${helpers.predefined_type("flex-basis", @@ -187,17 +187,17 @@ ${helpers.predefined_type("order", "Integer", "0", ${helpers.gecko_size_type("%s" % size, "MozLength", "auto()", logical, spec=spec % size, - animation_value_type="ComputedValue")} + animation_value_type="MozLength")} // min-width, min-height, min-block-size, min-inline-size, // max-width, max-height, max-block-size, max-inline-size ${helpers.gecko_size_type("min-%s" % size, "MozLength", "auto()", logical, spec=spec % size, - animation_value_type="ComputedValue")} + animation_value_type="MozLength")} ${helpers.gecko_size_type("max-%s" % size, "MaxLength", "none()", logical, spec=spec % size, - animation_value_type="ComputedValue")} + animation_value_type="MaxLength")} % else: // servo versions (no keyword support) ${helpers.predefined_type("%s" % size, diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index 6a3ef1d1f4b..32dfdb7a6b6 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -13,6 +13,8 @@ use std::cmp::max; use values::computed::Angle as ComputedAngle; use values::computed::BorderCornerRadius as ComputedBorderCornerRadius; use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqualToOneNumber; +use values::computed::MaxLength as ComputedMaxLength; +use values::computed::MozLength as ComputedMozLength; use values::computed::NonNegativeAu; use values::computed::NonNegativeLengthOrPercentage as ComputedNonNegativeLengthOrPercentage; use values::computed::NonNegativeNumber as ComputedNonNegativeNumber; @@ -180,6 +182,64 @@ impl ToAnimatedValue for ComputedBorderCornerRadius { } } +impl ToAnimatedValue for ComputedMaxLength { + type AnimatedValue = Self; + + #[inline] + fn to_animated_value(self) -> Self { + self + } + + #[inline] + fn from_animated_value(animated: Self::AnimatedValue) -> Self { + use values::computed::{LengthOrPercentageOrNone, Percentage}; + match animated { + ComputedMaxLength::LengthOrPercentageOrNone(lopn) => { + let result = match lopn { + LengthOrPercentageOrNone::Length(au) => { + LengthOrPercentageOrNone::Length(max(au, Au(0))) + }, + LengthOrPercentageOrNone::Percentage(percentage) => { + LengthOrPercentageOrNone::Percentage(Percentage(percentage.0.max(0.))) + } + _ => lopn + }; + ComputedMaxLength::LengthOrPercentageOrNone(result) + }, + _ => animated + } + } +} + +impl ToAnimatedValue for ComputedMozLength { + type AnimatedValue = Self; + + #[inline] + fn to_animated_value(self) -> Self { + self + } + + #[inline] + fn from_animated_value(animated: Self::AnimatedValue) -> Self { + use values::computed::{LengthOrPercentageOrAuto, Percentage}; + match animated { + ComputedMozLength::LengthOrPercentageOrAuto(lopa) => { + let result = match lopa { + LengthOrPercentageOrAuto::Length(au) => { + LengthOrPercentageOrAuto::Length(max(au, Au(0))) + }, + LengthOrPercentageOrAuto::Percentage(percentage) => { + LengthOrPercentageOrAuto::Percentage(Percentage(percentage.0.max(0.))) + } + _ => lopa + }; + ComputedMozLength::LengthOrPercentageOrAuto(result) + }, + _ => animated + } + } +} + /// Returns a value similar to `self` that represents zero. pub trait ToAnimatedZero: Sized { /// Returns a value that, when added with an underlying value, will produce the underlying