Bug 1496558 - Part 2: Move MozLength and MaxLength into generics r=emilio
authorBoris Chiou <boris.chiou@gmail.com>
Tue, 16 Oct 2018 01:07:41 +0000
changeset 489882 963840088024c60bc7e52d6046312989a2935705
parent 489881 7afc10b1bea13050b90796bcea2c66493e799f96
child 489883 af0263577e4d16da5c44df23ef5a44685c07a4d0
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersemilio
bugs1496558
milestone64.0a1
Bug 1496558 - Part 2: Move MozLength and MaxLength into generics r=emilio Move MozLength and MaxLength into generics, and drop the manual implementation of ToComputedValue. Depends on D8290 Differential Revision: https://phabricator.services.mozilla.com/D8291
servo/components/style/gecko/values.rs
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/values/animated/mod.rs
servo/components/style/values/computed/length.rs
servo/components/style/values/generics/length.rs
servo/components/style/values/generics/mod.rs
servo/components/style/values/specified/length.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/values.rs
+++ b/servo/components/style/gecko/values.rs
@@ -14,24 +14,25 @@ use gecko_bindings::structs::{self, Coun
 use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
 use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
 use media_queries::Device;
 use nsstring::{nsACString, nsCStr};
 use std::cmp::max;
 use values::{Auto, Either, None_, Normal};
 use values::computed::{Angle, ExtremumLength, Length, LengthOrPercentage, LengthOrPercentageOrAuto};
 use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
-use values::computed::{MaxLength, MozLength, Percentage};
+use values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength, Percentage};
 use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNegativeNumber};
 use values::computed::FlexBasis as ComputedFlexBasis;
 use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
 use values::generics::{CounterStyleOrNone, NonNegative};
 use values::generics::basic_shape::ShapeRadius;
 use values::generics::box_::Perspective;
 use values::generics::flex::FlexBasis;
+use values::generics::length::{MaxLength, MozLength};
 use values::generics::gecko::ScrollSnapPoint;
 use values::generics::grid::{TrackBreadth, TrackKeyword};
 
 /// A trait that defines an interface to convert from and to `nsStyleCoord`s.
 pub trait GeckoStyleCoordConvertible: Sized {
     /// Convert this to a `nsStyleCoord`.
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T);
     /// Given a `nsStyleCoord`, try to get a value of this type..
@@ -69,17 +70,17 @@ impl GeckoStyleCoordConvertible for Comp
             FlexBasis::Content => coord.set_value(CoordDataValue::Enumerated(
                 structs::NS_STYLE_FLEX_BASIS_CONTENT,
             )),
             FlexBasis::Width(ref w) => w.to_gecko_style_coord(coord),
         }
     }
 
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
-        if let Some(width) = MozLength::from_gecko_style_coord(coord) {
+        if let Some(width) = ComputedMozLength::from_gecko_style_coord(coord) {
             return Some(FlexBasis::Width(width));
         }
 
         if let CoordDataValue::Enumerated(structs::NS_STYLE_FLEX_BASIS_CONTENT) = coord.as_value() {
             return Some(FlexBasis::Content);
         }
 
         None
@@ -401,34 +402,34 @@ impl GeckoStyleCoordConvertible for Extr
             CoordDataValue::Enumerated(NS_STYLE_WIDTH_AVAILABLE) => {
                 Some(ExtremumLength::MozAvailable)
             },
             _ => None,
         }
     }
 }
 
-impl GeckoStyleCoordConvertible for MozLength {
+impl GeckoStyleCoordConvertible for ComputedMozLength {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match *self {
             MozLength::LengthOrPercentageOrAuto(ref lopoa) => lopoa.to_gecko_style_coord(coord),
             MozLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
         }
     }
 
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
         LengthOrPercentageOrAuto::from_gecko_style_coord(coord)
             .map(MozLength::LengthOrPercentageOrAuto)
             .or_else(|| {
                 ExtremumLength::from_gecko_style_coord(coord).map(MozLength::ExtremumLength)
             })
     }
 }
 
-impl GeckoStyleCoordConvertible for MaxLength {
+impl GeckoStyleCoordConvertible for ComputedMaxLength {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match *self {
             MaxLength::LengthOrPercentageOrNone(ref lopon) => lopon.to_gecko_style_coord(coord),
             MaxLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
         }
     }
 
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -30,17 +30,17 @@ use super::ComputedValues;
 use values::CSSFloat;
 use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
 use values::animated::color::Color as AnimatedColor;
 use values::animated::effects::Filter as AnimatedFilter;
 #[cfg(feature = "gecko")] use values::computed::TransitionProperty;
 use values::computed::{Angle, CalcLengthOrPercentage};
 use values::computed::{ClipRect, Context};
 use values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
-use values::computed::{LengthOrPercentageOrNone, MaxLength};
+use values::computed::LengthOrPercentageOrNone;
 use values::computed::{NonNegativeNumber, Number, NumberOrPercentage, Percentage};
 use values::computed::length::NonNegativeLengthOrPercentage;
 use values::computed::ToComputedValue;
 use values::computed::transform::{DirectionVector, Matrix, Matrix3D};
 use values::computed::transform::TransformOperation as ComputedTransformOperation;
 use values::computed::transform::Transform as ComputedTransform;
 use values::computed::transform::Rotate as ComputedRotate;
 use values::computed::transform::Translate as ComputedTranslate;
@@ -883,21 +883,16 @@ impl ToAnimatedZero for LengthOrPercenta
             LengthOrPercentageOrNone::Calc(_) => {
                 Ok(LengthOrPercentageOrNone::Length(Length::new(0.)))
             },
             LengthOrPercentageOrNone::None => Err(()),
         }
     }
 }
 
-impl ToAnimatedZero for MaxLength {
-    #[inline]
-    fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
-}
-
 impl ToAnimatedZero for FontWeight {
     #[inline]
     fn to_animated_zero(&self) -> Result<Self, ()> {
         Ok(FontWeight::normal())
     }
 }
 
 /// <https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def>
--- a/servo/components/style/values/animated/mod.rs
+++ b/servo/components/style/values/animated/mod.rs
@@ -287,28 +287,29 @@ impl ToAnimatedValue for ComputedMaxLeng
     #[inline]
     fn to_animated_value(self) -> Self {
         self
     }
 
     #[inline]
     fn from_animated_value(animated: Self::AnimatedValue) -> Self {
         use values::computed::{Length, LengthOrPercentageOrNone, Percentage};
+        use values::generics::length::MaxLength as GenericMaxLength;
         match animated {
-            ComputedMaxLength::LengthOrPercentageOrNone(lopn) => {
+            GenericMaxLength::LengthOrPercentageOrNone(lopn) => {
                 let result = match lopn {
                     LengthOrPercentageOrNone::Length(px) => {
                         LengthOrPercentageOrNone::Length(Length::new(px.px().max(0.)))
                     },
                     LengthOrPercentageOrNone::Percentage(percentage) => {
                         LengthOrPercentageOrNone::Percentage(Percentage(percentage.0.max(0.)))
                     },
                     _ => lopn,
                 };
-                ComputedMaxLength::LengthOrPercentageOrNone(result)
+                GenericMaxLength::LengthOrPercentageOrNone(result)
             },
             _ => animated,
         }
     }
 }
 
 impl ToAnimatedValue for ComputedMozLength {
     type AnimatedValue = Self;
@@ -316,28 +317,29 @@ impl ToAnimatedValue for ComputedMozLeng
     #[inline]
     fn to_animated_value(self) -> Self {
         self
     }
 
     #[inline]
     fn from_animated_value(animated: Self::AnimatedValue) -> Self {
         use values::computed::{Length, LengthOrPercentageOrAuto, Percentage};
+        use values::generics::length::MozLength as GenericMozLength;
         match animated {
-            ComputedMozLength::LengthOrPercentageOrAuto(lopa) => {
+            GenericMozLength::LengthOrPercentageOrAuto(lopa) => {
                 let result = match lopa {
                     LengthOrPercentageOrAuto::Length(px) => {
                         LengthOrPercentageOrAuto::Length(Length::new(px.px().max(0.)))
                     },
                     LengthOrPercentageOrAuto::Percentage(percentage) => {
                         LengthOrPercentageOrAuto::Percentage(Percentage(percentage.0.max(0.)))
                     },
                     _ => lopa,
                 };
-                ComputedMozLength::LengthOrPercentageOrAuto(result)
+                GenericMozLength::LengthOrPercentageOrAuto(result)
             },
             _ => animated,
         }
     }
 }
 
 impl ToAnimatedZero for Au {
     #[inline]
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -9,16 +9,17 @@ use ordered_float::NotNan;
 use std::fmt::{self, Write};
 use std::ops::{Add, Neg};
 use style_traits::{CssWriter, ToCss};
 use style_traits::values::specified::AllowedNumericType;
 use super::{Context, Number, Percentage, ToComputedValue};
 use values::{specified, Auto, CSSFloat, Either, Normal};
 use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
 use values::distance::{ComputeSquaredDistance, SquaredDistance};
+use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength};
 use values::generics::NonNegative;
 use values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength};
 use values::specified::length::ViewportPercentageLength;
 
 pub use super::image::Image;
 pub use values::specified::url::UrlOrNone;
 pub use values::specified::{Angle, BorderStyle, Time};
 
@@ -944,107 +945,38 @@ pub type NonNegativeLengthOrNormal = Eit
 
 /// Either a computed NonNegativeLengthOrPercentage or the `normal` keyword.
 pub type NonNegativeLengthOrPercentageOrNormal = Either<NonNegativeLengthOrPercentage, Normal>;
 
 /// A type for possible values for min- and max- flavors of width, height,
 /// block-size, and inline-size.
 #[allow(missing_docs)]
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss)]
+#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo,
+         ToComputedValue, ToCss)]
 pub enum ExtremumLength {
     MozMaxContent,
     MozMinContent,
     MozFitContent,
     MozAvailable,
 }
 
-/// A value suitable for a `min-width`, `min-height`, `width` or `height`
-/// property.
-///
-/// See values/specified/length.rs for more details.
-#[allow(missing_docs)]
-#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
-#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToAnimatedZero, ToCss)]
-pub enum MozLength {
-    LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
-    #[animation(error)]
-    ExtremumLength(ExtremumLength),
-}
+/// A computed value for `min-width`, `min-height`, `width` or `height` property.
+pub type MozLength = GenericMozLength<LengthOrPercentageOrAuto>;
 
 impl MozLength {
     /// Returns the `auto` value.
     #[inline]
     pub fn auto() -> Self {
-        MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
+        GenericMozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
     }
 }
 
-impl ToComputedValue for specified::MozLength {
-    type ComputedValue = MozLength;
-
-    #[inline]
-    fn to_computed_value(&self, context: &Context) -> MozLength {
-        match *self {
-            specified::MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
-                MozLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
-            },
-            specified::MozLength::ExtremumLength(ext) => MozLength::ExtremumLength(ext),
-        }
-    }
-
-    #[inline]
-    fn from_computed_value(computed: &MozLength) -> Self {
-        match *computed {
-            MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
-                specified::MozLength::LengthOrPercentageOrAuto(
-                    specified::LengthOrPercentageOrAuto::from_computed_value(lopoa),
-                )
-            },
-            MozLength::ExtremumLength(ext) => specified::MozLength::ExtremumLength(ext),
-        }
-    }
-}
-
-/// A value suitable for a `max-width` or `max-height` property.
-/// See values/specified/length.rs for more details.
-#[allow(missing_docs)]
-#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
-#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToCss)]
-pub enum MaxLength {
-    LengthOrPercentageOrNone(LengthOrPercentageOrNone),
-    #[animation(error)]
-    ExtremumLength(ExtremumLength),
-}
+/// A computed value for `max-width` or `min-height` property.
+pub type MaxLength = GenericMaxLength<LengthOrPercentageOrNone>;
 
 impl MaxLength {
     /// Returns the `none` value.
     #[inline]
     pub fn none() -> Self {
-        MaxLength::LengthOrPercentageOrNone(LengthOrPercentageOrNone::None)
+        GenericMaxLength::LengthOrPercentageOrNone(LengthOrPercentageOrNone::None)
     }
 }
-
-impl ToComputedValue for specified::MaxLength {
-    type ComputedValue = MaxLength;
-
-    #[inline]
-    fn to_computed_value(&self, context: &Context) -> MaxLength {
-        match *self {
-            specified::MaxLength::LengthOrPercentageOrNone(ref lopon) => {
-                MaxLength::LengthOrPercentageOrNone(lopon.to_computed_value(context))
-            },
-            specified::MaxLength::ExtremumLength(ext) => MaxLength::ExtremumLength(ext),
-        }
-    }
-
-    #[inline]
-    fn from_computed_value(computed: &MaxLength) -> Self {
-        match *computed {
-            MaxLength::LengthOrPercentageOrNone(ref lopon) => {
-                specified::MaxLength::LengthOrPercentageOrNone(
-                    specified::LengthOrPercentageOrNone::from_computed_value(&lopon),
-                )
-            },
-            MaxLength::ExtremumLength(ext) => specified::MaxLength::ExtremumLength(ext),
-        }
-    }
-}
new file mode 100644
--- /dev/null
+++ b/servo/components/style/values/generics/length.rs
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! Generic types for CSS values related to length.
+
+use values::computed::ExtremumLength;
+
+/// A generic value for the `width`, `height`, `min-width`, or `min-height` property.
+///
+/// Unlike `max-width` or `max-height` properties, a MozLength can be `auto`,
+/// and cannot be `none`.
+///
+/// Note that it only accepts non-negative values.
+#[allow(missing_docs)]
+#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
+#[derive(
+    Animate,
+    Clone,
+    ComputeSquaredDistance,
+    Copy,
+    Debug,
+    PartialEq,
+    SpecifiedValueInfo,
+    ToAnimatedZero,
+    ToComputedValue,
+    ToCss,
+)]
+pub enum MozLength<LengthOrPercentageOrAuto> {
+    LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
+    #[animation(error)]
+    ExtremumLength(ExtremumLength),
+}
+
+/// A generic value for the `max-width` or `max-height` property.
+#[allow(missing_docs)]
+#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
+#[derive(
+    Animate,
+    Clone,
+    ComputeSquaredDistance,
+    Copy,
+    Debug,
+    PartialEq,
+    SpecifiedValueInfo,
+    ToAnimatedZero,
+    ToComputedValue,
+    ToCss
+)]
+pub enum MaxLength<LengthOrPercentageOrNone> {
+    LengthOrPercentageOrNone(LengthOrPercentageOrNone),
+    #[animation(error)]
+    ExtremumLength(ExtremumLength),
+}
--- a/servo/components/style/values/generics/mod.rs
+++ b/servo/components/style/values/generics/mod.rs
@@ -22,16 +22,17 @@ pub mod column;
 pub mod counters;
 pub mod effects;
 pub mod flex;
 pub mod font;
 #[cfg(feature = "gecko")]
 pub mod gecko;
 pub mod grid;
 pub mod image;
+pub mod length;
 pub mod position;
 pub mod rect;
 pub mod size;
 pub mod svg;
 pub mod text;
 pub mod transform;
 pub mod ui;
 pub mod url;
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -13,16 +13,17 @@ use font_metrics::FontMetricsQueryResult
 use parser::{Parse, ParserContext};
 use std::cmp;
 use std::ops::{Add, Mul};
 use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind};
 use style_traits::values::specified::AllowedNumericType;
 use super::{AllowQuirks, Number, Percentage, ToComputedValue};
 use values::{Auto, CSSFloat, Either, Normal};
 use values::computed::{self, CSSPixelLength, Context, ExtremumLength};
+use values::generics::length::{MaxLength as GenericMaxLength, MozLength as GenericMozLength};
 use values::generics::NonNegative;
 use values::specified::calc::CalcNode;
 
 pub use values::specified::calc::CalcLengthOrPercentage;
 pub use super::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
 pub use super::image::{GradientKind, Image};
 
 /// Number of app units per pixel
@@ -1183,28 +1184,18 @@ impl LengthOrNumber {
 
     /// Returns `0`.
     #[inline]
     pub fn zero() -> Self {
         Either::Second(Number::new(0.))
     }
 }
 
-/// A value suitable for a `min-width` or `min-height` property.
-///
-/// Unlike `max-width` or `max-height` properties, a MozLength can be `auto`,
-/// and cannot be `none`.
-///
-/// Note that it only accepts non-negative values.
-#[allow(missing_docs)]
-#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
-pub enum MozLength {
-    LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
-    ExtremumLength(ExtremumLength),
-}
+/// A specified value for `min-width`, `min-height`, `width` or `height` property.
+pub type MozLength = GenericMozLength<LengthOrPercentageOrAuto>;
 
 impl Parse for MozLength {
     fn parse<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         MozLength::parse_quirky(context, input, AllowQuirks::No)
     }
@@ -1214,54 +1205,49 @@ impl MozLength {
     /// Parses, without quirks, and disallowing ExtremumLength values.
     ///
     /// Used for logical props in the block direction.
     pub fn parse_disallow_keyword<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         let length = LengthOrPercentageOrAuto::parse_non_negative(context, input)?;
-        Ok(MozLength::LengthOrPercentageOrAuto(length))
+        Ok(GenericMozLength::LengthOrPercentageOrAuto(length))
     }
 
     /// Parses, with quirks.
     pub fn parse_quirky<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
         allow_quirks: AllowQuirks,
     ) -> Result<Self, ParseError<'i>> {
         if let Ok(l) = input.try(ExtremumLength::parse) {
-            return Ok(MozLength::ExtremumLength(l));
+            return Ok(GenericMozLength::ExtremumLength(l));
         }
 
         let length =
             LengthOrPercentageOrAuto::parse_non_negative_quirky(context, input, allow_quirks)?;
-        Ok(MozLength::LengthOrPercentageOrAuto(length))
+        Ok(GenericMozLength::LengthOrPercentageOrAuto(length))
     }
 
     /// Returns `auto`.
     #[inline]
     pub fn auto() -> Self {
-        MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::auto())
+        GenericMozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::auto())
     }
 
     /// Returns `0%`.
     #[inline]
     pub fn zero_percent() -> Self {
-        MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero_percent())
+        GenericMozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::zero_percent())
     }
 }
 
-/// A value suitable for a `max-width` or `max-height` property.
-#[allow(missing_docs)]
-#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
-pub enum MaxLength {
-    LengthOrPercentageOrNone(LengthOrPercentageOrNone),
-    ExtremumLength(ExtremumLength),
-}
+/// A specified value for `max-width` or `max-height` property.
+pub type MaxLength = GenericMaxLength<LengthOrPercentageOrNone>;
 
 impl Parse for MaxLength {
     fn parse<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         MaxLength::parse_quirky(context, input, AllowQuirks::No)
     }
@@ -1271,26 +1257,26 @@ impl MaxLength {
     /// Parses, without quirks, and disallowing ExtremumLength values.
     ///
     /// Used for logical props in the block direction.
     pub fn parse_disallow_keyword<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         let length = LengthOrPercentageOrNone::parse_non_negative(context, input)?;
-        Ok(MaxLength::LengthOrPercentageOrNone(length))
+        Ok(GenericMaxLength::LengthOrPercentageOrNone(length))
     }
 
     /// Parses, with quirks.
     pub fn parse_quirky<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
         allow_quirks: AllowQuirks,
     ) -> Result<Self, ParseError<'i>> {
         if let Ok(l) = input.try(ExtremumLength::parse) {
-            return Ok(MaxLength::ExtremumLength(l));
+            return Ok(GenericMaxLength::ExtremumLength(l));
         }
 
         let length =
             LengthOrPercentageOrNone::parse_non_negative_quirky(context, input, allow_quirks)?;
-        Ok(MaxLength::LengthOrPercentageOrNone(length))
+        Ok(GenericMaxLength::LengthOrPercentageOrNone(length))
     }
 }
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -4187,17 +4187,18 @@ pub extern "C" fn Servo_DeclarationBlock
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32
 ) {
     use style::properties::{PropertyDeclaration, LonghandId};
     use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing;
-    use style::values::specified::{BorderSideWidth, MozLength, BorderCornerRadius};
+    use style::values::generics::length::MozLength;
+    use style::values::specified::{BorderSideWidth, BorderCornerRadius};
     use style::values::specified::length::{NoCalcLength, NonNegativeLength, LengthOrPercentage};
 
     let long = get_longhand_from_id!(property);
     let nocalc = NoCalcLength::from_px(value);
 
     let prop = match_wrap_declared! { long,
         Height => MozLength::LengthOrPercentageOrAuto(nocalc.into()),
         Width => MozLength::LengthOrPercentageOrAuto(nocalc.into()),
@@ -4244,17 +4245,17 @@ pub extern "C" fn Servo_DeclarationBlock
 pub extern "C" fn Servo_DeclarationBlock_SetLengthValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32,
     unit: structs::nsCSSUnit,
 ) {
     use style::properties::{PropertyDeclaration, LonghandId};
     use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
-    use style::values::specified::MozLength;
+    use style::values::generics::length::MozLength;
     use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
     use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
 
     let long = get_longhand_from_id!(property);
     let nocalc = match unit {
         structs::nsCSSUnit::eCSSUnit_EM => NoCalcLength::FontRelative(FontRelativeLength::Em(value)),
         structs::nsCSSUnit::eCSSUnit_XHeight => NoCalcLength::FontRelative(FontRelativeLength::Ex(value)),
         structs::nsCSSUnit::eCSSUnit_Pixel => NoCalcLength::Absolute(AbsoluteLength::Px(value)),
@@ -4302,17 +4303,17 @@ pub extern "C" fn Servo_DeclarationBlock
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32,
 ) {
     use style::properties::{PropertyDeclaration, LonghandId};
     use style::values::computed::Percentage;
-    use style::values::specified::MozLength;
+    use style::values::generics::length::MozLength;
     use style::values::specified::length::LengthOrPercentage;
 
     let long = get_longhand_from_id!(property);
     let pc = Percentage(value);
 
     let prop = match_wrap_declared! { long,
         Height => MozLength::LengthOrPercentageOrAuto(pc.into()),
         Width => MozLength::LengthOrPercentageOrAuto(pc.into()),