Bug 1526736 - Rename MozLength to Size, and MaxLength to MaxSize. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 11 Feb 2019 10:59:49 +0000
changeset 458487 51d4957627fb25a8ec6ed9d43c6ea4c71ba0b6e9
parent 458486 f7716de1fce57a5548afacd5f756d3d2c327b0b7
child 458488 0d65ca0a00195e03b4b7976d6bbbf5c5cb0c9d93
push id77859
push userealvarez@mozilla.com
push dateMon, 11 Feb 2019 11:01:04 +0000
treeherderautoland@51d4957627fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1526736
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526736 - Rename MozLength to Size, and MaxLength to MaxSize. r=heycam MozLength is not a very descriptive name. If we're going to use it in both Gecko and Servo we may as well name it something more accurate. I would've chosen `ContentSize` per CSS2[1][2] if it wasn't a lie in presence of box-sizing. I don't have better ideas than `Size`, given that. [1]: https://drafts.csswg.org/css2/visudet.html#propdef-width [2]: https://drafts.csswg.org/css2/box.html#content-width Differential Revision: https://phabricator.services.mozilla.com/D19280
servo/components/style/gecko/values.rs
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhands/position.mako.rs
servo/components/style/properties/properties.mako.rs
servo/components/style/values/computed/flex.rs
servo/components/style/values/computed/length.rs
servo/components/style/values/computed/mod.rs
servo/components/style/values/generics/length.rs
servo/components/style/values/specified/flex.rs
servo/components/style/values/specified/length.rs
servo/components/style/values/specified/mod.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/values.rs
+++ b/servo/components/style/gecko/values.rs
@@ -9,25 +9,25 @@
 use crate::counter_style::{Symbol, Symbols};
 use crate::gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
 use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
 use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
 use crate::media_queries::Device;
 use crate::values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
 use crate::values::computed::FlexBasis as ComputedFlexBasis;
 use crate::values::computed::{Angle, ExtremumLength, Length, LengthPercentage};
-use crate::values::computed::{MaxLength as ComputedMaxLength, MozLength as ComputedMozLength};
+use crate::values::computed::{MaxSize as ComputedMaxSize, Size as ComputedSize};
 use crate::values::computed::{NonNegativeLengthPercentage, Percentage};
 use crate::values::computed::{Number, NumberOrPercentage};
 use crate::values::generics::basic_shape::ShapeRadius;
 use crate::values::generics::box_::Perspective;
 use crate::values::generics::flex::FlexBasis;
 use crate::values::generics::gecko::ScrollSnapPoint;
 use crate::values::generics::grid::{TrackBreadth, TrackKeyword};
-use crate::values::generics::length::{LengthPercentageOrAuto, MaxLength, MozLength};
+use crate::values::generics::length::{LengthPercentageOrAuto, MaxSize, Size};
 use crate::values::generics::{CounterStyleOrNone, NonNegative};
 use crate::values::{Auto, Either, None_, Normal};
 use crate::Atom;
 use app_units::Au;
 use cssparser::RGBA;
 use nsstring::{nsACString, nsCStr};
 use std::cmp::max;
 
@@ -86,17 +86,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) = ComputedMozLength::from_gecko_style_coord(coord) {
+        if let Some(width) = ComputedSize::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
@@ -345,53 +345,53 @@ impl GeckoStyleCoordConvertible for Extr
         use num_traits::FromPrimitive;
         match coord.as_value() {
             CoordDataValue::Enumerated(v) => ExtremumLength::from_u32(v),
             _ => None,
         }
     }
 }
 
-impl GeckoStyleCoordConvertible for ComputedMozLength {
+impl GeckoStyleCoordConvertible for ComputedSize {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match *self {
-            MozLength::LengthPercentage(ref lpoa) => lpoa.to_gecko_style_coord(coord),
-            MozLength::Auto => coord.set_value(CoordDataValue::Auto),
-            MozLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
+            Size::LengthPercentage(ref lpoa) => lpoa.to_gecko_style_coord(coord),
+            Size::Auto => coord.set_value(CoordDataValue::Auto),
+            Size::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
         }
     }
 
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
         if let CoordDataValue::Auto = coord.as_value() {
-            return Some(MozLength::Auto);
+            return Some(Size::Auto);
         }
         if let Some(lp) = NonNegativeLengthPercentage::from_gecko_style_coord(coord) {
-            return Some(MozLength::LengthPercentage(lp));
+            return Some(Size::LengthPercentage(lp));
         }
-        ExtremumLength::from_gecko_style_coord(coord).map(MozLength::ExtremumLength)
+        ExtremumLength::from_gecko_style_coord(coord).map(Size::ExtremumLength)
     }
 }
 
-impl GeckoStyleCoordConvertible for ComputedMaxLength {
+impl GeckoStyleCoordConvertible for ComputedMaxSize {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match *self {
-            MaxLength::LengthPercentage(ref lpon) => lpon.to_gecko_style_coord(coord),
-            MaxLength::None => coord.set_value(CoordDataValue::None),
-            MaxLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
+            MaxSize::LengthPercentage(ref lpon) => lpon.to_gecko_style_coord(coord),
+            MaxSize::None => coord.set_value(CoordDataValue::None),
+            MaxSize::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
         }
     }
 
     fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
         if let CoordDataValue::None = coord.as_value() {
-            return Some(MaxLength::None);
+            return Some(MaxSize::None);
         }
         if let Some(lp) = NonNegativeLengthPercentage::from_gecko_style_coord(coord) {
-            return Some(MaxLength::LengthPercentage(lp));
+            return Some(MaxSize::LengthPercentage(lp));
         }
-        ExtremumLength::from_gecko_style_coord(coord).map(MaxLength::ExtremumLength)
+        ExtremumLength::from_gecko_style_coord(coord).map(MaxSize::ExtremumLength)
     }
 }
 
 impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthPercentage> {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match self.repeated() {
             None => coord.set_value(CoordDataValue::None),
             Some(l) => l.to_gecko_style_coord(coord),
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1385,18 +1385,18 @@ impl Clone for ${style_struct.gecko_stru
         "length::NonNegativeLengthOrAuto": impl_style_coord,
         "length::NonNegativeLengthPercentageOrNormal": impl_style_coord,
         "FillRule": impl_simple,
         "FlexBasis": impl_style_coord,
         "Length": impl_absolute_length,
         "LengthOrNormal": impl_style_coord,
         "LengthPercentage": impl_simple,
         "LengthPercentageOrAuto": impl_style_coord,
-        "MaxLength": impl_style_coord,
-        "MozLength": impl_style_coord,
+        "MaxSize": impl_style_coord,
+        "Size": impl_style_coord,
         "MozScriptMinSize": impl_absolute_length,
         "MozScriptSizeMultiplier": impl_simple,
         "NonNegativeLengthPercentage": impl_simple,
         "NonNegativeNumber": impl_simple,
         "Number": impl_simple,
         "Opacity": impl_simple,
         "OverflowWrap": impl_simple,
         "OverflowAnchor": impl_simple,
--- a/servo/components/style/properties/longhands/position.mako.rs
+++ b/servo/components/style/properties/longhands/position.mako.rs
@@ -239,75 +239,50 @@ macro_rules! impl_align_conversions {
 )}
 
 % for (size, logical) in ALL_SIZES:
     <%
         spec = "https://drafts.csswg.org/css-box/#propdef-%s"
         if logical:
             spec = "https://drafts.csswg.org/css-logical-props/#propdef-%s"
     %>
-    % if product == "gecko":
-        // width, height, block-size, inline-size
-        ${helpers.predefined_type(
-            size,
-            "MozLength",
-            "computed::MozLength::auto()",
-            logical=logical,
-            logical_group="size",
-            allow_quirks=not logical,
-            spec=spec % size,
-            animation_value_type="MozLength",
-            flags="GETCS_NEEDS_LAYOUT_FLUSH",
-            servo_restyle_damage="reflow",
-        )}
-        // min-width, min-height, min-block-size, min-inline-size,
-        ${helpers.predefined_type(
-            "min-%s" % size,
-            "MozLength",
-            "computed::MozLength::auto()",
-            logical=logical,
-            logical_group="min-size",
-            allow_quirks=not logical,
-            spec=spec % size,
-            animation_value_type="MozLength",
-            servo_restyle_damage="reflow",
-        )}
-    % else:
-        // servo versions (no keyword support)
-        ${helpers.predefined_type(
-            size,
-            "NonNegativeLengthPercentageOrAuto",
-            "computed::NonNegativeLengthPercentageOrAuto::auto()",
-            spec=spec % size,
-            logical_group="size",
-            allow_quirks=not logical,
-            animation_value_type="ComputedValue", logical = logical,
-            servo_restyle_damage="reflow",
-        )}
-        ${helpers.predefined_type(
-            "min-%s" % size,
-            "NonNegativeLengthPercentage",
-            "computed::NonNegativeLengthPercentage::zero()",
-            spec=spec % ("min-%s" % size),
-            logical_group="min-size",
-            animation_value_type="ComputedValue",
-            logical=logical,
-            allow_quirks=not logical,
-            servo_restyle_damage="reflow",
-        )}
-    % endif
+    // width, height, block-size, inline-size
+    ${helpers.predefined_type(
+        size,
+        "Size",
+        "computed::Size::auto()",
+        logical=logical,
+        logical_group="size",
+        allow_quirks=not logical,
+        spec=spec % size,
+        animation_value_type="Size",
+        flags="GETCS_NEEDS_LAYOUT_FLUSH",
+        servo_restyle_damage="reflow",
+    )}
+    // min-width, min-height, min-block-size, min-inline-size
+    ${helpers.predefined_type(
+        "min-%s" % size,
+        "Size",
+        "computed::Size::auto()",
+        logical=logical,
+        logical_group="min-size",
+        allow_quirks=not logical,
+        spec=spec % size,
+        animation_value_type="Size",
+        servo_restyle_damage="reflow",
+    )}
     ${helpers.predefined_type(
         "max-%s" % size,
-        "MaxLength",
-        "computed::MaxLength::none()",
+        "MaxSize",
+        "computed::MaxSize::none()",
         logical=logical,
         logical_group="max-size",
         allow_quirks=not logical,
         spec=spec % size,
-        animation_value_type="MaxLength",
+        animation_value_type="MaxSize",
         servo_restyle_damage="reflow",
     )}
 % endfor
 
 ${helpers.single_keyword(
     "box-sizing",
     "content-box border-box",
     extra_prefixes="moz:layout.css.prefixes.box-sizing webkit",
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -3011,56 +3011,56 @@ impl ComputedValuesInner {
     /// Whether the current style is multicolumn.
     #[inline]
     pub fn is_multicol(&self) -> bool {
         self.get_column().is_multicol()
     }
 
     /// Get the logical computed inline size.
     #[inline]
-    pub fn content_inline_size(&self) -> computed::NonNegativeLengthPercentageOrAuto {
+    pub fn content_inline_size(&self) -> computed::Size {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() {
             position_style.height
         } else {
             position_style.width
         }
     }
 
     /// Get the logical computed block size.
     #[inline]
-    pub fn content_block_size(&self) -> computed::NonNegativeLengthPercentageOrAuto {
+    pub fn content_block_size(&self) -> computed::Size {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() { position_style.width } else { position_style.height }
     }
 
     /// Get the logical computed min inline size.
     #[inline]
-    pub fn min_inline_size(&self) -> computed::NonNegativeLengthPercentage {
+    pub fn min_inline_size(&self) -> computed::Size {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() { position_style.min_height } else { position_style.min_width }
     }
 
     /// Get the logical computed min block size.
     #[inline]
-    pub fn min_block_size(&self) -> computed::NonNegativeLengthPercentage {
+    pub fn min_block_size(&self) -> computed::Size {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() { position_style.min_width } else { position_style.min_height }
     }
 
     /// Get the logical computed max inline size.
     #[inline]
-    pub fn max_inline_size(&self) -> computed::MaxLength {
+    pub fn max_inline_size(&self) -> computed::MaxSize {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() { position_style.max_height } else { position_style.max_width }
     }
 
     /// Get the logical computed max block size.
     #[inline]
-    pub fn max_block_size(&self) -> computed::MaxLength {
+    pub fn max_block_size(&self) -> computed::MaxSize {
         let position_style = self.get_position();
         if self.writing_mode.is_vertical() { position_style.max_width } else { position_style.max_height }
     }
 
     /// Get the logical computed padding for this writing mode.
     #[inline]
     pub fn logical_padding(&self) -> LogicalMargin<computed::LengthPercentage> {
         let padding_style = self.get_padding();
--- a/servo/components/style/values/computed/flex.rs
+++ b/servo/components/style/values/computed/flex.rs
@@ -1,26 +1,19 @@
 /* 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 https://mozilla.org/MPL/2.0/. */
 
 //! Computed types for CSS values related to flexbox.
 
+use crate::values::computed::Size;
 use crate::values::generics::flex::FlexBasis as GenericFlexBasis;
 
-/// The `width` value type.
-#[cfg(feature = "servo")]
-pub type Width = crate::values::computed::NonNegativeLengthPercentageOrAuto;
-
-/// The `width` value type.
-#[cfg(feature = "gecko")]
-pub type Width = crate::values::computed::MozLength;
-
 /// A computed value for the `flex-basis` property.
-pub type FlexBasis = GenericFlexBasis<Width>;
+pub type FlexBasis = GenericFlexBasis<Size>;
 
 impl FlexBasis {
     /// `auto`
     #[inline]
     pub fn auto() -> Self {
-        GenericFlexBasis::Width(Width::auto())
+        GenericFlexBasis::Width(Size::auto())
     }
 }
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -3,19 +3,17 @@
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 //! `<length>` computed values, and related ones.
 
 use super::{Context, Number, Percentage, ToComputedValue};
 use crate::values::animated::ToAnimatedValue;
 use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
 use crate::values::generics::length as generics;
-use crate::values::generics::length::{
-    MaxLength as GenericMaxLength, MozLength as GenericMozLength,
-};
+use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize};
 use crate::values::generics::transform::IsZeroLength;
 use crate::values::generics::NonNegative;
 use crate::values::specified::length::ViewportPercentageLength;
 use crate::values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength};
 use crate::values::{specified, Auto, CSSFloat, Either, Normal};
 use app_units::Au;
 use ordered_float::NotNan;
 use std::fmt::{self, Write};
@@ -575,22 +573,46 @@ impl NonNegativeLengthPercentage {
     #[inline]
     pub fn maybe_to_used_value(&self, containing_length: Option<Au>) -> Option<Au> {
         let resolved = self.0.maybe_to_used_value(containing_length)?;
         Some(::std::cmp::max(resolved, Au(0)))
     }
 }
 
 #[cfg(feature = "servo")]
-impl MaxLength {
+impl MaxSize {
     /// Convert the computed value into used value.
+    #[inline]
     pub fn to_used_value(&self, percentage_basis: Au) -> Option<Au> {
         match *self {
-            GenericMaxLength::None => None,
-            GenericMaxLength::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)),
+            GenericMaxSize::None => None,
+            GenericMaxSize::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)),
+        }
+    }
+}
+
+impl Size {
+    /// Convert the computed value into used value.
+    #[inline]
+    #[cfg(feature = "servo")]
+    pub fn to_used_value(&self, percentage_basis: Au) -> Option<Au> {
+        match *self {
+            GenericSize::Auto => None,
+            GenericSize::LengthPercentage(ref lp) => Some(lp.to_used_value(percentage_basis)),
+        }
+    }
+
+    /// Returns true if the computed value is absolute 0 or 0%.
+    #[inline]
+    pub fn is_definitely_zero(&self) -> bool {
+        match *self {
+            GenericSize::Auto => false,
+            GenericSize::LengthPercentage(ref lp) => lp.is_definitely_zero(),
+            #[cfg(feature = "gecko")]
+            GenericSize::ExtremumLength(..) => false,
         }
     }
 }
 
 /// The computed `<length>` value.
 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
 #[derive(
     Animate,
@@ -816,12 +838,12 @@ pub enum ExtremumLength {
     MaxContent,
     #[parse(aliases = "-moz-min-content")]
     MinContent,
     MozFitContent,
     MozAvailable,
 }
 
 /// A computed value for `min-width`, `min-height`, `width` or `height` property.
-pub type MozLength = GenericMozLength<NonNegativeLengthPercentage>;
+pub type Size = GenericSize<NonNegativeLengthPercentage>;
 
 /// A computed value for `max-width` or `min-height` property.
-pub type MaxLength = GenericMaxLength<NonNegativeLengthPercentage>;
+pub type MaxSize = GenericMaxSize<NonNegativeLengthPercentage>;
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -57,17 +57,17 @@ pub use self::font::{FontSize, FontSizeA
 pub use self::font::{FontVariantAlternates, FontWeight};
 pub use self::font::{FontVariantEastAsian, FontVariationSettings};
 pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
 #[cfg(feature = "gecko")]
 pub use self::gecko::ScrollSnapPoint;
 pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection, MozImageRect};
 pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength};
 pub use self::length::{Length, LengthOrNumber, LengthPercentage};
-pub use self::length::{LengthPercentageOrAuto, MaxLength, MozLength};
+pub use self::length::{LengthPercentageOrAuto, MaxSize, Size};
 pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto};
 #[cfg(feature = "gecko")]
 pub use self::list::ListStyleType;
 pub use self::list::{QuotePair, Quotes};
 pub use self::motion::OffsetPath;
 pub use self::outline::OutlineStyle;
 pub use self::percentage::{NonNegativePercentage, Percentage};
 pub use self::position::{GridAutoFlow, GridTemplateAreas, Position, ZIndex};
--- a/servo/components/style/values/generics/length.rs
+++ b/servo/components/style/values/generics/length.rs
@@ -1,15 +1,16 @@
 /* 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 https://mozilla.org/MPL/2.0/. */
 
 //! Generic types for CSS values related to length.
 
 use crate::parser::{Parse, ParserContext};
+#[cfg(feature = "gecko")]
 use crate::values::computed::ExtremumLength;
 use cssparser::Parser;
 use style_traits::ParseError;
 
 /// A `<length-percentage> | auto` value.
 #[allow(missing_docs)]
 #[derive(
     Animate,
@@ -71,17 +72,17 @@ impl<LengthPercentage: Parse> Parse for 
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
         Self::parse_with(context, input, LengthPercentage::parse)
     }
 }
 
 /// 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`,
+/// Unlike `max-width` or `max-height` properties, a Size can be `auto`,
 /// and cannot be `none`.
 ///
 /// Note that it only accepts non-negative values.
 #[allow(missing_docs)]
 #[derive(
     Animate,
     Clone,
     ComputeSquaredDistance,
@@ -90,28 +91,35 @@ impl<LengthPercentage: Parse> Parse for 
     MallocSizeOf,
     PartialEq,
     SpecifiedValueInfo,
     ToAnimatedValue,
     ToAnimatedZero,
     ToComputedValue,
     ToCss,
 )]
-pub enum MozLength<LengthPercentage> {
+pub enum Size<LengthPercentage> {
     LengthPercentage(LengthPercentage),
     Auto,
+    #[cfg(feature = "gecko")]
     #[animation(error)]
     ExtremumLength(ExtremumLength),
 }
 
-impl<LengthPercentage> MozLength<LengthPercentage> {
+impl<LengthPercentage> Size<LengthPercentage> {
     /// `auto` value.
     #[inline]
     pub fn auto() -> Self {
-        MozLength::Auto
+        Size::Auto
+    }
+
+    /// Returns whether we're the auto value.
+    #[inline]
+    pub fn is_auto(&self) -> bool {
+        matches!(*self, Size::Auto)
     }
 }
 
 /// A generic value for the `max-width` or `max-height` property.
 #[allow(missing_docs)]
 #[cfg_attr(feature = "servo", derive(MallocSizeOf))]
 #[derive(
     Animate,
@@ -121,23 +129,23 @@ impl<LengthPercentage> MozLength<LengthP
     Debug,
     PartialEq,
     SpecifiedValueInfo,
     ToAnimatedValue,
     ToAnimatedZero,
     ToComputedValue,
     ToCss,
 )]
-pub enum MaxLength<LengthPercentage> {
+pub enum MaxSize<LengthPercentage> {
     LengthPercentage(LengthPercentage),
     None,
     #[cfg(feature = "gecko")]
     #[animation(error)]
     ExtremumLength(ExtremumLength),
 }
 
-impl<LengthPercentage> MaxLength<LengthPercentage> {
+impl<LengthPercentage> MaxSize<LengthPercentage> {
     /// `none` value.
     #[inline]
     pub fn none() -> Self {
-        MaxLength::None
+        MaxSize::None
     }
 }
--- a/servo/components/style/values/specified/flex.rs
+++ b/servo/components/style/values/specified/flex.rs
@@ -1,49 +1,42 @@
 /* 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 https://mozilla.org/MPL/2.0/. */
 
 //! Specified types for CSS values related to flexbox.
 
 use crate::parser::{Parse, ParserContext};
 use crate::values::generics::flex::FlexBasis as GenericFlexBasis;
+use crate::values::specified::Size;
 use cssparser::Parser;
 use style_traits::ParseError;
 
-/// The `width` value type.
-#[cfg(feature = "servo")]
-pub type Width = crate::values::specified::NonNegativeLengthPercentageOrAuto;
-
-/// The `width` value type.
-#[cfg(feature = "gecko")]
-pub type Width = crate::values::specified::MozLength;
-
 /// A specified value for the `flex-basis` property.
-pub type FlexBasis = GenericFlexBasis<Width>;
+pub type FlexBasis = GenericFlexBasis<Size>;
 
 impl Parse for FlexBasis {
     fn parse<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
-        if let Ok(width) = input.try(|i| Width::parse(context, i)) {
+        if let Ok(width) = input.try(|i| Size::parse(context, i)) {
             return Ok(GenericFlexBasis::Width(width));
         }
         try_match_ident_ignore_ascii_case! { input,
             "content" => Ok(GenericFlexBasis::Content),
         }
     }
 }
 
 impl FlexBasis {
     /// `auto`
     #[inline]
     pub fn auto() -> Self {
-        GenericFlexBasis::Width(Width::auto())
+        GenericFlexBasis::Width(Size::auto())
     }
 
     /// `0%`
     #[inline]
     pub fn zero_percent() -> Self {
-        GenericFlexBasis::Width(Width::zero_percent())
+        GenericFlexBasis::Width(Size::zero_percent())
     }
 }
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -4,21 +4,19 @@
 
 //! [Length values][length].
 //!
 //! [length]: https://drafts.csswg.org/css-values/#lengths
 
 use super::{AllowQuirks, Number, Percentage, ToComputedValue};
 use crate::font_metrics::FontMetricsQueryResult;
 use crate::parser::{Parse, ParserContext};
-use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength};
+use crate::values::computed::{self, CSSPixelLength, Context};
 use crate::values::generics::length as generics;
-use crate::values::generics::length::{
-    MaxLength as GenericMaxLength, MozLength as GenericMozLength,
-};
+use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize};
 use crate::values::generics::transform::IsZeroLength;
 use crate::values::generics::NonNegative;
 use crate::values::specified::calc::CalcNode;
 use crate::values::{Auto, CSSFloat, Either, Normal};
 use app_units::Au;
 use cssparser::{Parser, Token};
 use euclid::Size2D;
 use std::cmp;
@@ -1046,79 +1044,82 @@ impl LengthOrNumber {
     /// Returns `0`.
     #[inline]
     pub fn zero() -> Self {
         Either::Second(Number::new(0.))
     }
 }
 
 /// A specified value for `min-width`, `min-height`, `width` or `height` property.
-pub type MozLength = GenericMozLength<NonNegativeLengthPercentage>;
+pub type Size = GenericSize<NonNegativeLengthPercentage>;
 
-impl Parse for MozLength {
+impl Parse for Size {
     fn parse<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
     ) -> Result<Self, ParseError<'i>> {
-        MozLength::parse_quirky(context, input, AllowQuirks::No)
+        Size::parse_quirky(context, input, AllowQuirks::No)
     }
 }
 
-impl MozLength {
-    /// 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(GenericMozLength::ExtremumLength(l));
-        }
-
-        if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
-            return Ok(GenericMozLength::Auto);
-        }
-
-        let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
-        Ok(GenericMozLength::LengthPercentage(length))
-    }
-
-    /// Returns `0%`.
-    #[inline]
-    pub fn zero_percent() -> Self {
-        GenericMozLength::LengthPercentage(NonNegativeLengthPercentage::zero_percent())
-    }
-}
-
-/// A specified value for `max-width` or `max-height` property.
-pub type MaxLength = GenericMaxLength<NonNegativeLengthPercentage>;
-
-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)
-    }
-}
-
-impl MaxLength {
+impl Size {
     /// Parses, with quirks.
     pub fn parse_quirky<'i, 't>(
         context: &ParserContext,
         input: &mut Parser<'i, 't>,
         allow_quirks: AllowQuirks,
     ) -> Result<Self, ParseError<'i>> {
         #[cfg(feature = "gecko")]
         {
-            if let Ok(l) = input.try(ExtremumLength::parse) {
-                return Ok(GenericMaxLength::ExtremumLength(l));
+            if let Ok(l) = input.try(computed::ExtremumLength::parse) {
+                return Ok(GenericSize::ExtremumLength(l));
+            }
+        }
+
+        if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
+            return Ok(GenericSize::Auto);
+        }
+
+        let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
+        Ok(GenericSize::LengthPercentage(length))
+    }
+
+    /// Returns `0%`.
+    #[inline]
+    pub fn zero_percent() -> Self {
+        GenericSize::LengthPercentage(NonNegativeLengthPercentage::zero_percent())
+    }
+}
+
+/// A specified value for `max-width` or `max-height` property.
+pub type MaxSize = GenericMaxSize<NonNegativeLengthPercentage>;
+
+impl Parse for MaxSize {
+    fn parse<'i, 't>(
+        context: &ParserContext,
+        input: &mut Parser<'i, 't>,
+    ) -> Result<Self, ParseError<'i>> {
+        MaxSize::parse_quirky(context, input, AllowQuirks::No)
+    }
+}
+
+impl MaxSize {
+    /// Parses, with quirks.
+    pub fn parse_quirky<'i, 't>(
+        context: &ParserContext,
+        input: &mut Parser<'i, 't>,
+        allow_quirks: AllowQuirks,
+    ) -> Result<Self, ParseError<'i>> {
+        #[cfg(feature = "gecko")]
+        {
+            if let Ok(l) = input.try(computed::ExtremumLength::parse) {
+                return Ok(GenericMaxSize::ExtremumLength(l));
             }
         }
 
         if input.try(|i| i.expect_ident_matching("none")).is_ok() {
-            return Ok(GenericMaxLength::None);
+            return Ok(GenericMaxSize::None);
         }
 
         let length = NonNegativeLengthPercentage::parse_quirky(context, input, allow_quirks)?;
-        Ok(GenericMaxLength::LengthPercentage(length))
+        Ok(GenericMaxSize::LengthPercentage(length))
     }
 }
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -54,17 +54,17 @@ pub use self::font::{FontVariantEastAsia
 pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
 #[cfg(feature = "gecko")]
 pub use self::gecko::ScrollSnapPoint;
 pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
 pub use self::image::{GradientItem, GradientKind, Image, ImageLayer, MozImageRect};
 pub use self::length::{AbsoluteLength, CalcLengthPercentage, CharacterWidth};
 pub use self::length::{FontRelativeLength, Length, LengthOrNumber};
 pub use self::length::{LengthPercentage, LengthPercentageOrAuto};
-pub use self::length::{MaxLength, MozLength};
+pub use self::length::{MaxSize, Size};
 pub use self::length::{NoCalcLength, ViewportPercentageLength};
 pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto};
 #[cfg(feature = "gecko")]
 pub use self::list::ListStyleType;
 pub use self::list::{QuotePair, Quotes};
 pub use self::motion::OffsetPath;
 pub use self::outline::OutlineStyle;
 pub use self::percentage::Percentage;
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -4429,31 +4429,31 @@ pub extern "C" fn Servo_DeclarationBlock
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32,
 ) {
     use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing;
     use style::properties::{LonghandId, PropertyDeclaration};
-    use style::values::generics::length::MozLength;
+    use style::values::generics::length::Size;
     use style::values::generics::NonNegative;
     use style::values::generics::length::LengthPercentageOrAuto;
     use style::values::specified::length::NonNegativeLengthPercentage;
     use style::values::specified::length::{LengthPercentage};
     use style::values::specified::length::{NoCalcLength, NonNegativeLength};
     use style::values::specified::{BorderCornerRadius, BorderSideWidth};
 
     let long = get_longhand_from_id!(property);
     let nocalc = NoCalcLength::from_px(value);
     let lp = LengthPercentage::Length(nocalc);
     let lp_or_auto = LengthPercentageOrAuto::LengthPercentage(lp.clone());
     let prop = match_wrap_declared! { long,
-        Height => MozLength::LengthPercentage(NonNegative(lp)),
-        Width => MozLength::LengthPercentage(NonNegative(lp)),
+        Height => Size::LengthPercentage(NonNegative(lp)),
+        Width => Size::LengthPercentage(NonNegative(lp)),
         BorderTopWidth => BorderSideWidth::Length(nocalc.into()),
         BorderRightWidth => BorderSideWidth::Length(nocalc.into()),
         BorderBottomWidth => BorderSideWidth::Length(nocalc.into()),
         BorderLeftWidth => BorderSideWidth::Length(nocalc.into()),
         MarginTop => lp_or_auto,
         MarginRight => lp_or_auto,
         MarginBottom => lp_or_auto,
         MarginLeft => lp_or_auto,
@@ -4492,17 +4492,17 @@ pub extern "C" fn Servo_DeclarationBlock
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32,
     unit: structs::nsCSSUnit,
 ) {
     use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
     use style::properties::{LonghandId, PropertyDeclaration};
     use style::values::generics::NonNegative;
-    use style::values::generics::length::MozLength;
+    use style::values::generics::length::Size;
     use style::values::specified::length::NoCalcLength;
     use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
     use style::values::specified::length::LengthPercentage;
 
     let long = get_longhand_from_id!(property);
     let nocalc = match unit {
         structs::nsCSSUnit::eCSSUnit_EM => {
             NoCalcLength::FontRelative(FontRelativeLength::Em(value))
@@ -4520,17 +4520,17 @@ pub extern "C" fn Servo_DeclarationBlock
         },
         structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
         structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
         structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
         _ => unreachable!("Unknown unit passed to SetLengthValue"),
     };
 
     let prop = match_wrap_declared! { long,
-        Width => MozLength::LengthPercentage(NonNegative(LengthPercentage::Length(nocalc))),
+        Width => Size::LengthPercentage(NonNegative(LengthPercentage::Length(nocalc))),
         FontSize => LengthPercentage::from(nocalc).into(),
         MozScriptMinSize => MozScriptMinSize(nocalc),
     };
     write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
         decls.push(prop, Importance::Normal);
     })
 }
 
@@ -4560,27 +4560,27 @@ pub extern "C" fn Servo_DeclarationBlock
 pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
     value: f32,
 ) {
     use style::properties::{LonghandId, PropertyDeclaration};
     use style::values::computed::Percentage;
     use style::values::generics::NonNegative;
-    use style::values::generics::length::{MozLength, LengthPercentageOrAuto};
+    use style::values::generics::length::{Size, LengthPercentageOrAuto};
     use style::values::specified::length::LengthPercentage;
 
     let long = get_longhand_from_id!(property);
     let pc = Percentage(value);
     let lp = LengthPercentage::Percentage(pc);
     let lp_or_auto = LengthPercentageOrAuto::LengthPercentage(lp.clone());
 
     let prop = match_wrap_declared! { long,
-        Height => MozLength::LengthPercentage(NonNegative(lp)),
-        Width => MozLength::LengthPercentage(NonNegative(lp)),
+        Height => Size::LengthPercentage(NonNegative(lp)),
+        Width => Size::LengthPercentage(NonNegative(lp)),
         MarginTop => lp_or_auto,
         MarginRight => lp_or_auto,
         MarginBottom => lp_or_auto,
         MarginLeft => lp_or_auto,
         FontSize => LengthPercentage::from(pc).into(),
     };
     write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
         decls.push(prop, Importance::Normal);
@@ -4588,24 +4588,24 @@ pub extern "C" fn Servo_DeclarationBlock
 }
 
 #[no_mangle]
 pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(
     declarations: RawServoDeclarationBlockBorrowed,
     property: nsCSSPropertyID,
 ) {
     use style::properties::{LonghandId, PropertyDeclaration};
-    use style::values::generics::length::{LengthPercentageOrAuto, MozLength};
+    use style::values::generics::length::{LengthPercentageOrAuto, Size};
 
     let long = get_longhand_from_id!(property);
     let auto = LengthPercentageOrAuto::Auto;
 
     let prop = match_wrap_declared! { long,
-        Height => MozLength::auto(),
-        Width => MozLength::auto(),
+        Height => Size::auto(),
+        Width => Size::auto(),
         MarginTop => auto,
         MarginRight => auto,
         MarginBottom => auto,
         MarginLeft => auto,
     };
     write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
         decls.push(prop, Importance::Normal);
     })