Bug 1355402 - Rename MinLength to MozLength. r?manishearth draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 17 May 2017 12:57:40 +0900
changeset 579243 f4fb8567c2777007b5230e440df9c9594c5652dd
parent 579242 90ae402234ac8d6f8d64fc93a69b17383fe0f625
child 579244 0be5bf275f8909f3f3dd07bd6df1b2d52b364984
push id59173
push userhikezoe@mozilla.com
push dateWed, 17 May 2017 04:47:54 +0000
reviewersmanishearth
bugs1355402
milestone55.0a1
Bug 1355402 - Rename MinLength to MozLength. r?manishearth So that we can reuse this for non-min-prefixed properties (e.g. width). MozReview-Commit-ID: 86IJypHp3cW
servo/components/style/gecko/values.rs
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/longhand/position.mako.rs
servo/components/style/values/computed/length.rs
servo/components/style/values/computed/mod.rs
servo/components/style/values/specified/length.rs
servo/components/style/values/specified/mod.rs
--- a/servo/components/style/gecko/values.rs
+++ b/servo/components/style/gecko/values.rs
@@ -9,17 +9,17 @@
 use app_units::Au;
 use cssparser::RGBA;
 use gecko_bindings::structs::{nsStyleCoord, StyleGridTrackBreadth, StyleShapeRadius};
 use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
 use std::cmp::max;
 use values::{Auto, Either, ExtremumLength, None_, Normal};
 use values::computed::{Angle, LengthOrPercentage, LengthOrPercentageOrAuto};
 use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
-use values::computed::{MaxLength, MinLength};
+use values::computed::{MaxLength, MozLength};
 use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
 use values::generics::basic_shape::ShapeRadius;
 use values::specified::Percentage;
 use values::specified::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`.
@@ -330,27 +330,27 @@ impl GeckoStyleCoordConvertible for Extr
             CoordDataValue::Enumerated(NS_STYLE_WIDTH_FIT_CONTENT) =>
                 Some(ExtremumLength::FitContent),
             CoordDataValue::Enumerated(NS_STYLE_WIDTH_AVAILABLE) => Some(ExtremumLength::FillAvailable),
             _ => None,
         }
     }
 }
 
-impl GeckoStyleCoordConvertible for MinLength {
+impl GeckoStyleCoordConvertible for MozLength {
     fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
         match *self {
-            MinLength::LengthOrPercentageOrAuto(ref lopoa) => lopoa.to_gecko_style_coord(coord),
-            MinLength::ExtremumLength(ref e) => e.to_gecko_style_coord(coord),
+            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(MinLength::LengthOrPercentageOrAuto)
-            .or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MinLength::ExtremumLength))
+        LengthOrPercentageOrAuto::from_gecko_style_coord(coord).map(MozLength::LengthOrPercentageOrAuto)
+            .or_else(|| ExtremumLength::from_gecko_style_coord(coord).map(MozLength::ExtremumLength))
     }
 }
 
 impl GeckoStyleCoordConvertible for MaxLength {
     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),
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -652,17 +652,17 @@ impl Debug for ${style_struct.gecko_stru
         "Length": impl_absolute_length,
         "Position": impl_position,
         "LengthOrPercentage": impl_style_coord,
         "LengthOrPercentageOrAuto": impl_style_coord,
         "LengthOrPercentageOrNone": impl_style_coord,
         "LengthOrNone": impl_style_coord,
         "LengthOrNormal": impl_style_coord,
         "MaxLength": impl_style_coord,
-        "MinLength": impl_style_coord,
+        "MozLength": impl_style_coord,
         "Number": impl_simple,
         "Integer": impl_simple,
         "Opacity": impl_simple,
         "CSSColor": impl_color,
         "SVGPaint": impl_svg_paint,
         "UrlOrNone": impl_css_url,
     }
 
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -35,17 +35,17 @@ use std::cmp;
 use std::fmt;
 use style_traits::ToCss;
 use super::ComputedValues;
 use values::CSSFloat;
 use values::{Auto, Either, generics};
 use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
 use values::computed::{BorderRadiusSize, ClipRect};
 use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
-use values::computed::{MaxLength, MinLength};
+use values::computed::{MaxLength, MozLength};
 use values::computed::ToComputedValue;
 use values::generics::position as generic_position;
 
 
 /// A given transition property, that is either `All`, or an animatable
 /// property.
 // NB: This needs to be here because it needs all the longhands generated
 // beforehand.
@@ -1233,34 +1233,34 @@ impl Animatable for LengthOrPercentageOr
                 this.compute_distance(other)
             },
             _ => Err(())
         }
     }
 }
 
 /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
-impl Animatable for MinLength {
+impl Animatable for MozLength {
     #[inline]
     fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
         match (*self, *other) {
-            (MinLength::LengthOrPercentageOrAuto(ref this),
-             MinLength::LengthOrPercentageOrAuto(ref other)) => {
+            (MozLength::LengthOrPercentageOrAuto(ref this),
+             MozLength::LengthOrPercentageOrAuto(ref other)) => {
                 this.add_weighted(other, self_portion, other_portion)
-                    .map(MinLength::LengthOrPercentageOrAuto)
+                    .map(MozLength::LengthOrPercentageOrAuto)
             }
             _ => Err(()),
         }
     }
 
     #[inline]
     fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
         match (*self, *other) {
-            (MinLength::LengthOrPercentageOrAuto(ref this),
-             MinLength::LengthOrPercentageOrAuto(ref other)) => {
+            (MozLength::LengthOrPercentageOrAuto(ref this),
+             MozLength::LengthOrPercentageOrAuto(ref other)) => {
                 this.compute_distance(other)
             },
             _ => Err(()),
         }
     }
 }
 
 /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
--- a/servo/components/style/properties/longhand/position.mako.rs
+++ b/servo/components/style/properties/longhand/position.mako.rs
@@ -158,90 +158,90 @@
                               "computed::LengthOrPercentageOrAuto::Auto",
                               "parse_non_negative",
                               spec=spec % size,
                               allow_quirks=not logical,
                               animation_value_type="ComputedValue", logical = logical)}
     % if product == "gecko":
         % for min_max in ["min", "max"]:
             <%
-                MinMax = min_max.title()
+                LengthType = "MaxLength" if "max" == min_max else "MozLength"
                 initial = "none()" if "max" == min_max else "auto()"
             %>
 
             // min-width, min-height, min-block-size, min-inline-size,
             // max-width, max-height, max-block-size, max-inline-size
             //
             // Keyword values are only valid in the inline direction; they must
             // be replaced with auto/none in block.
             <%helpers:longhand name="${min_max}-${size}" spec="${spec % ('%s-%s' % (min_max, size))}"
                                animation_value_type="ComputedValue"
-                               logical="${logical}" predefined_type="${MinMax}Length">
+                               logical="${logical}" predefined_type="${LengthType}">
 
                 use std::fmt;
                 use style_traits::ToCss;
                 use values::HasViewportPercentage;
-                use values::specified::{AllowQuirks, ${MinMax}Length};
+                use values::specified::{AllowQuirks, ${LengthType}};
 
                 impl HasViewportPercentage for SpecifiedValue {
                     fn has_viewport_percentage(&self) -> bool {
                         self.0.has_viewport_percentage()
                     }
                 }
 
                 pub mod computed_value {
-                    pub type T = ::values::computed::${MinMax}Length;
+                    pub type T = ::values::computed::${LengthType};
                 }
 
                 #[derive(PartialEq, Clone, Debug)]
                 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
-                pub struct SpecifiedValue(${MinMax}Length);
+                pub struct SpecifiedValue(${LengthType});
 
                 #[inline]
                 pub fn get_initial_value() -> computed_value::T {
-                    use values::computed::${MinMax}Length;
-                    ${MinMax}Length::${initial}
+                    use values::computed::${LengthType};
+                    ${LengthType}::${initial}
                 }
                 fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
                     % if logical:
-                    let ret = ${MinMax}Length::parse(context, input);
+                    let ret = ${LengthType}::parse(context, input);
                     % else:
-                    let ret = ${MinMax}Length::parse_quirky(context, input, AllowQuirks::Yes);
+                    let ret = ${LengthType}::parse_quirky(context, input, AllowQuirks::Yes);
                     % endif
                     // Keyword values don't make sense in the block direction; don't parse them
                     % if "block" in size:
-                        if let Ok(${MinMax}Length::ExtremumLength(..)) = ret {
+                        if let Ok(${LengthType}::ExtremumLength(..)) = ret {
                             return Err(())
                         }
                     % endif
                     ret.map(SpecifiedValue)
                 }
 
                 impl ToCss for SpecifiedValue {
                     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
                         self.0.to_css(dest)
                     }
                 }
 
                 impl ToComputedValue for SpecifiedValue {
                     type ComputedValue = computed_value::T;
                     #[inline]
                     fn to_computed_value(&self, context: &Context) -> computed_value::T {
-                        use values::computed::${MinMax}Length;
+                        use values::computed::${LengthType};
                         let computed = self.0.to_computed_value(context);
 
                         // filter out keyword values in the block direction
                         % if logical:
                             % if "block" in size:
-                                if let ${MinMax}Length::ExtremumLength(..) = computed {
+                                if let ${LengthType}::ExtremumLength(..) = computed {
                                     return get_initial_value()
                                 }
                             % endif
                         % else:
-                            if let ${MinMax}Length::ExtremumLength(..) = computed {
+                            if let ${LengthType}::ExtremumLength(..) = computed {
                                 <% is_height = "true" if "height" in size else "false" %>
                                 if ${is_height} != context.style().writing_mode.is_vertical() {
                                     return get_initial_value()
                                 }
                             }
                         % endif
                         computed
                     }
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -561,61 +561,61 @@ pub type LengthOrNumber = Either<Length,
 /// Either a computed `<length>` or the `normal` keyword.
 pub type LengthOrNormal = Either<Length, Normal>;
 
 /// A value suitable for a `min-width` or `min-height` property.
 /// See specified/values/length.rs for more details.
 #[derive(Debug, Copy, Clone, PartialEq)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 #[allow(missing_docs)]
-pub enum MinLength {
+pub enum MozLength {
     LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
     ExtremumLength(ExtremumLength),
 }
 
-impl MinLength {
+impl MozLength {
     /// Returns the `auto` value.
     pub fn auto() -> Self {
-        MinLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
+        MozLength::LengthOrPercentageOrAuto(LengthOrPercentageOrAuto::Auto)
     }
 }
 
-impl ToComputedValue for specified::MinLength {
-    type ComputedValue = MinLength;
+impl ToComputedValue for specified::MozLength {
+    type ComputedValue = MozLength;
 
     #[inline]
-    fn to_computed_value(&self, context: &Context) -> MinLength {
+    fn to_computed_value(&self, context: &Context) -> MozLength {
         match *self {
-            specified::MinLength::LengthOrPercentageOrAuto(ref lopoa) => {
-                MinLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
+            specified::MozLength::LengthOrPercentageOrAuto(ref lopoa) => {
+                MozLength::LengthOrPercentageOrAuto(lopoa.to_computed_value(context))
             }
-            specified::MinLength::ExtremumLength(ref ext) => {
-                MinLength::ExtremumLength(ext.clone())
+            specified::MozLength::ExtremumLength(ref ext) => {
+                MozLength::ExtremumLength(ext.clone())
             }
         }
     }
 
     #[inline]
-    fn from_computed_value(computed: &MinLength) -> Self {
+    fn from_computed_value(computed: &MozLength) -> Self {
         match *computed {
-            MinLength::LengthOrPercentageOrAuto(ref lopoa) =>
-                specified::MinLength::LengthOrPercentageOrAuto(
+            MozLength::LengthOrPercentageOrAuto(ref lopoa) =>
+                specified::MozLength::LengthOrPercentageOrAuto(
                     specified::LengthOrPercentageOrAuto::from_computed_value(&lopoa)),
-            MinLength::ExtremumLength(ref ext) =>
-                specified::MinLength::ExtremumLength(ext.clone()),
+            MozLength::ExtremumLength(ref ext) =>
+                specified::MozLength::ExtremumLength(ext.clone()),
         }
     }
 }
 
-impl ToCss for MinLength {
+impl ToCss for MozLength {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
         match *self {
-            MinLength::LengthOrPercentageOrAuto(lopoa) =>
+            MozLength::LengthOrPercentageOrAuto(lopoa) =>
                 lopoa.to_css(dest),
-            MinLength::ExtremumLength(ext) =>
+            MozLength::ExtremumLength(ext) =>
                 ext.to_css(dest),
         }
     }
 }
 
 /// A value suitable for a `max-width` or `max-height` property.
 /// See specified/values/length.rs for more details.
 #[derive(Debug, Copy, Clone, PartialEq)]
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -25,17 +25,17 @@ pub use cssparser::Color as CSSColor;
 pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, ImageRect};
 pub use super::{Auto, Either, None_};
 #[cfg(feature = "gecko")]
 pub use super::specified::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
 pub use super::specified::{BorderStyle, GridLine, Percentage, UrlOrNone};
 pub use super::specified::url::SpecifiedUrl;
 pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
 pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone};
-pub use self::length::{MaxLength, MinLength};
+pub use self::length::{MaxLength, MozLength};
 pub use self::position::Position;
 
 pub mod basic_shape;
 pub mod image;
 pub mod length;
 pub mod position;
 
 /// A `Context` is all the data a specified value could ever need to compute
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -1223,60 +1223,60 @@ impl LengthOrNumber {
             return Ok(Either::Second(v))
         }
 
         Length::parse_non_negative(context, input).map(Either::First)
     }
 }
 
 /// A value suitable for a `min-width` or `min-height` property.
-/// Unlike `max-width` or `max-height` properties, a MinLength can be
+/// Unlike `max-width` or `max-height` properties, a MozLength can be
 /// `auto`, and cannot be `none`.
 #[derive(Debug, Clone, PartialEq)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 #[allow(missing_docs)]
-pub enum MinLength {
+pub enum MozLength {
     LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
     ExtremumLength(ExtremumLength),
 }
 
-impl HasViewportPercentage for MinLength {
+impl HasViewportPercentage for MozLength {
     fn has_viewport_percentage(&self) -> bool {
         match *self {
-            MinLength::LengthOrPercentageOrAuto(ref lopoa) => lopoa.has_viewport_percentage(),
+            MozLength::LengthOrPercentageOrAuto(ref lopoa) => lopoa.has_viewport_percentage(),
             _ => false
         }
     }
 }
 
-impl ToCss for MinLength {
+impl ToCss for MozLength {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
         match *self {
-            MinLength::LengthOrPercentageOrAuto(ref lopoa) =>
+            MozLength::LengthOrPercentageOrAuto(ref lopoa) =>
                 lopoa.to_css(dest),
-            MinLength::ExtremumLength(ref ext) =>
+            MozLength::ExtremumLength(ref ext) =>
                 ext.to_css(dest),
         }
     }
 }
 
-impl Parse for MinLength {
+impl Parse for MozLength {
     fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
-        MinLength::parse_quirky(context, input, AllowQuirks::No)
+        MozLength::parse_quirky(context, input, AllowQuirks::No)
     }
 }
 
-impl MinLength {
+impl MozLength {
     /// Parses, with quirks.
     pub fn parse_quirky(context: &ParserContext,
                         input: &mut Parser,
                         allow_quirks: AllowQuirks) -> Result<Self, ()> {
-        input.try(ExtremumLength::parse).map(MinLength::ExtremumLength)
+        input.try(ExtremumLength::parse).map(MozLength::ExtremumLength)
             .or_else(|()| input.try(|i| LengthOrPercentageOrAuto::parse_non_negative_quirky(context, i, allow_quirks))
-                               .map(MinLength::LengthOrPercentageOrAuto))
+                               .map(MozLength::LengthOrPercentageOrAuto))
     }
 }
 
 /// A value suitable for a `max-width` or `max-height` property.
 #[derive(Debug, Clone, PartialEq)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
 #[allow(missing_docs)]
 pub enum MaxLength {
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -29,17 +29,17 @@ pub use self::align::{AlignItems, AlignJ
 pub use self::color::Color;
 pub use self::grid::{GridLine, TrackKeyword};
 pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
 pub use self::image::{GradientItem, GradientKind, Image, ImageRect, ImageLayer};
 pub use self::length::AbsoluteLength;
 pub use self::length::{FontRelativeLength, ViewportPercentageLength, CharacterWidth, Length, CalcLengthOrPercentage};
 pub use self::length::{Percentage, LengthOrNone, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
 pub use self::length::{LengthOrPercentageOrNone, LengthOrPercentageOrAutoOrContent, NoCalcLength};
-pub use self::length::{MaxLength, MinLength};
+pub use self::length::{MaxLength, MozLength};
 pub use self::position::{Position, PositionComponent};
 
 #[cfg(feature = "gecko")]
 pub mod align;
 pub mod basic_shape;
 pub mod calc;
 pub mod color;
 pub mod grid;