diff options
author | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-05-20 11:58:58 +0900 |
---|---|---|
committer | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-05-21 08:33:12 +0900 |
commit | 57c27e5d35e12b5d4822bc9f70a8b3da09f19d38 (patch) | |
tree | 8464aa283a92c8e31ed420256d353c0ccf90ea5f /components | |
parent | 95bda2dff961d642f97bc0de055882f6d3928f8a (diff) | |
download | servo-57c27e5d35e12b5d4822bc9f70a8b3da09f19d38.tar.gz servo-57c27e5d35e12b5d4822bc9f70a8b3da09f19d38.zip |
Rename MinLength to MozLength.
So that we can reuse this for non-min-prefixed properties (e.g. width).
Diffstat (limited to 'components')
-rw-r--r-- | components/style/gecko/values.rs | 12 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 2 | ||||
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 14 | ||||
-rw-r--r-- | components/style/properties/longhand/position.mako.rs | 27 | ||||
-rw-r--r-- | components/style/values/computed/length.rs | 38 | ||||
-rw-r--r-- | components/style/values/computed/mod.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/length.rs | 20 | ||||
-rw-r--r-- | components/style/values/specified/mod.rs | 2 |
8 files changed, 59 insertions, 58 deletions
diff --git a/components/style/gecko/values.rs b/components/style/gecko/values.rs index 040d4752849..63b035447a4 100644 --- a/components/style/gecko/values.rs +++ b/components/style/gecko/values.rs @@ -14,7 +14,7 @@ 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; @@ -335,17 +335,17 @@ impl GeckoStyleCoordConvertible for ExtremumLength { } } -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)) } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 0736d34e97e..f0d284e4d76 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -675,7 +675,7 @@ impl Debug for ${style_struct.gecko_struct_name} { "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, diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 402662d92ea..6ea63347b60 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -41,7 +41,7 @@ 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; @@ -1237,14 +1237,14 @@ impl Animatable for LengthOrPercentageOrNone { } /// 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(()), } @@ -1253,8 +1253,8 @@ impl Animatable for MinLength { #[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(()), diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 7fa4d3b2ba0..ab4646d0da4 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -163,7 +163,7 @@ ${helpers.predefined_type("flex-basis", % 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()" %> @@ -174,37 +174,38 @@ ${helpers.predefined_type("flex-basis", // 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; % if not logical: use values::specified::AllowQuirks; % endif - use values::specified::${MinMax}Length; + use values::specified::${LengthType}; + pub mod computed_value { - pub type T = ::values::computed::${MinMax}Length; + pub type T = ::values::computed::${LengthType}; } #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] #[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 @@ -222,19 +223,19 @@ ${helpers.predefined_type("flex-basis", #[inline] fn to_computed_value(&self, context: &Context) -> computed_value::T { % if not logical or "block" in size: - use values::computed::${MinMax}Length; + use values::computed::${LengthType}; % endif 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() diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 7b1ec1a288b..e2dac197652 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -606,56 +606,56 @@ pub type LengthOrNumber = Either<Length, Number>; /// 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. +/// A value suitable for a `min-width`, `min-height`, `width` or `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), } } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 8c537eb3694..9cf143d1f56 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -31,7 +31,7 @@ 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; diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 6481d0686ea..27f6f5d6f1f 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1176,41 +1176,41 @@ impl LengthOrNumber { } /// 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(Clone, Debug, HasViewportPercentage, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[allow(missing_docs)] -pub enum MinLength { +pub enum MozLength { LengthOrPercentageOrAuto(LengthOrPercentageOrAuto), ExtremumLength(ExtremumLength), } -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)) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index d687c4aaff9..88a44b50b3e 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -37,7 +37,7 @@ 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")] |