servo: Merge #17299 - Revert "Derive ToCss for MozImageRect" (from servo:derive-all-the-things); r=emilio
authorAnthony Ramine <n.oxyde@gmail.com>
Tue, 13 Jun 2017 09:31:19 -0700
changeset 363804 c59001b282b1a3302da2bb29c1b8dc82ba55699a
parent 363803 a755c216c3ea00008faf48d9e080f23abcf28d3f
child 363805 31ee46d1814d5b1cb068c5881d6ca29a9fe28eb6
push id91413
push userkwierso@gmail.com
push dateWed, 14 Jun 2017 01:36:16 +0000
treeherdermozilla-inbound@1561522b1179 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone56.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
servo: Merge #17299 - Revert "Derive ToCss for MozImageRect" (from servo:derive-all-the-things); r=emilio This reverts commit fe19c3810cd20a2a48dd054386f95462a3513e4c. Source-Repo: https://github.com/servo/servo Source-Revision: fe573c1ce9a7cbacf69a846ad966c429faa61703
servo/components/style/values/computed/image.rs
servo/components/style/values/computed/mod.rs
servo/components/style/values/generics/image.rs
servo/components/style/values/specified/image.rs
servo/components/style/values/specified/mod.rs
--- a/servo/components/style/values/computed/image.rs
+++ b/servo/components/style/values/computed/image.rs
@@ -12,26 +12,26 @@ use std::f32::consts::PI;
 use std::fmt;
 use style_traits::ToCss;
 use values::{Either, None_};
 use values::computed::{Angle, Context, Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
 use values::computed::position::Position;
 use values::generics::image::{CompatMode, ColorStop as GenericColorStop, EndingShape as GenericEndingShape};
 use values::generics::image::{Gradient as GenericGradient, GradientItem as GenericGradientItem};
 use values::generics::image::{Image as GenericImage, GradientKind as GenericGradientKind};
-use values::generics::image::{LineDirection as GenericLineDirection, MozImageRect as GenericMozImageRect};
+use values::generics::image::{ImageRect as GenericImageRect, LineDirection as GenericLineDirection};
 use values::specified::image::LineDirection as SpecifiedLineDirection;
 use values::specified::position::{X, Y};
 
 /// A computed image layer.
 pub type ImageLayer = Either<None_, Image>;
 
 /// Computed values for an image according to CSS-IMAGES.
 /// https://drafts.csswg.org/css-images/#image-values
-pub type Image = GenericImage<Gradient, MozImageRect>;
+pub type Image = GenericImage<Gradient, ImageRect>;
 
 /// Computed values for a CSS gradient.
 /// https://drafts.csswg.org/css-images/#gradients
 pub type Gradient = GenericGradient<
     LineDirection,
     Length,
     LengthOrPercentage,
     Position,
@@ -60,18 +60,18 @@ pub enum LineDirection {
 pub type EndingShape = GenericEndingShape<Length, LengthOrPercentage>;
 
 /// A computed gradient item.
 pub type GradientItem = GenericGradientItem<RGBA, LengthOrPercentage>;
 
 /// A computed color stop.
 pub type ColorStop = GenericColorStop<RGBA, LengthOrPercentage>;
 
-/// Computed values for MozImageRect.
-pub type MozImageRect = GenericMozImageRect<NumberOrPercentage>;
+/// Computed values for ImageRect.
+pub type ImageRect = GenericImageRect<NumberOrPercentage>;
 
 impl GenericLineDirection for LineDirection {
     fn points_downwards(&self) -> bool {
         match *self {
             LineDirection::Angle(angle) => angle.radians() == PI,
             LineDirection::Corner(..) => false,
         }
     }
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -23,17 +23,17 @@ use super::generics::grid::TrackList as 
 use super::specified;
 
 pub use app_units::Au;
 pub use properties::animated_properties::TransitionProperty;
 pub use self::background::BackgroundSize;
 pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
 pub use self::border::{BorderRadius, BorderCornerRadius};
 pub use self::color::{Color, RGBAColor};
-pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, MozImageRect};
+pub use self::image::{Gradient, GradientItem, ImageLayer, LineDirection, Image, ImageRect};
 #[cfg(feature = "gecko")]
 pub use self::gecko::ScrollSnapPoint;
 pub use self::rect::LengthOrNumberRect;
 pub use super::{Auto, Either, None_};
 #[cfg(feature = "gecko")]
 pub use super::specified::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
 pub use super::specified::{BorderStyle, Percentage, UrlOrNone};
 pub use super::generics::grid::GridLine;
--- a/servo/components/style/values/generics/image.rs
+++ b/servo/components/style/values/generics/image.rs
@@ -13,23 +13,23 @@ use style_traits::{HasViewportPercentage
 use values::computed::ComputedValueAsSpecified;
 use values::specified::url::SpecifiedUrl;
 
 /// An [image].
 ///
 /// [image]: https://drafts.csswg.org/css-images/#image-values
 #[derive(Clone, PartialEq, ToComputedValue)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
-pub enum Image<Gradient, MozImageRect> {
+pub enum Image<Gradient, ImageRect> {
     /// A `<url()>` image.
     Url(SpecifiedUrl),
     /// A `<gradient>` image.
     Gradient(Gradient),
     /// A `-moz-image-rect` image
-    Rect(MozImageRect),
+    Rect(ImageRect),
     /// A `-moz-element(# <element-id>)`
     Element(Atom),
     /// A paint worklet image.
     /// https://drafts.css-houdini.org/css-paint-api/
     #[cfg(feature = "servo")]
     PaintWorklet(PaintWorklet),
 }
 
@@ -146,22 +146,21 @@ impl ToCss for PaintWorklet {
         dest.write_str("paint(")?;
         serialize_identifier(&*self.name.to_string(), dest)?;
         dest.write_str(")")
     }
 }
 
 /// Values for `moz-image-rect`.
 ///
-/// `-moz-image-rect(<uri>, top, right, bottom, left)`
-#[allow(missing_docs)]
+/// `-moz-image-rect(<uri>, top, right, bottom, left);`
+#[derive(Clone, Debug, PartialEq, ToComputedValue)]
 #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
-#[css(function)]
-#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
-pub struct MozImageRect<NumberOrPercentage> {
+#[allow(missing_docs)]
+pub struct ImageRect<NumberOrPercentage> {
     pub url: SpecifiedUrl,
     pub top: NumberOrPercentage,
     pub bottom: NumberOrPercentage,
     pub right: NumberOrPercentage,
     pub left: NumberOrPercentage,
 }
 
 impl<G, R> fmt::Debug for Image<G, R>
@@ -329,8 +328,26 @@ impl<C, L> ToCss for ColorStop<C, L>
         self.color.to_css(dest)?;
         if let Some(ref position) = self.position {
             dest.write_str(" ")?;
             position.to_css(dest)?;
         }
         Ok(())
     }
 }
+
+impl<C> ToCss for ImageRect<C>
+    where C: ToCss,
+{
+    fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
+        dest.write_str("-moz-image-rect(")?;
+        self.url.to_css(dest)?;
+        dest.write_str(", ")?;
+        self.top.to_css(dest)?;
+        dest.write_str(", ")?;
+        self.right.to_css(dest)?;
+        dest.write_str(", ")?;
+        self.bottom.to_css(dest)?;
+        dest.write_str(", ")?;
+        self.left.to_css(dest)?;
+        dest.write_str(")")
+    }
+}
--- a/servo/components/style/values/specified/image.rs
+++ b/servo/components/style/values/specified/image.rs
@@ -16,30 +16,31 @@ use servo_url::ServoUrl;
 use std::cmp::Ordering;
 use std::f32::consts::PI;
 use std::fmt;
 use style_traits::{ToCss, ParseError, StyleParseError};
 use values::{Either, None_};
 use values::generics::image::{Circle, CompatMode, Ellipse, ColorStop as GenericColorStop};
 use values::generics::image::{EndingShape as GenericEndingShape, Gradient as GenericGradient};
 use values::generics::image::{GradientItem as GenericGradientItem, GradientKind as GenericGradientKind};
-use values::generics::image::{Image as GenericImage, LineDirection as GenericsLineDirection};
-use values::generics::image::{MozImageRect as GenericMozImageRect, PaintWorklet, ShapeExtent};
+use values::generics::image::{Image as GenericImage, ImageRect as GenericImageRect};
+use values::generics::image::{LineDirection as GenericsLineDirection, ShapeExtent};
+use values::generics::image::PaintWorklet;
 use values::generics::position::Position as GenericPosition;
 use values::specified::{Angle, Color, Length, LengthOrPercentage};
 use values::specified::{Number, NumberOrPercentage, Percentage, RGBAColor};
 use values::specified::position::{Position, PositionComponent, Side, X, Y};
 use values::specified::url::SpecifiedUrl;
 
 /// A specified image layer.
 pub type ImageLayer = Either<None_, Image>;
 
 /// Specified values for an image according to CSS-IMAGES.
 /// https://drafts.csswg.org/css-images/#image-values
-pub type Image = GenericImage<Gradient, MozImageRect>;
+pub type Image = GenericImage<Gradient, ImageRect>;
 
 /// Specified values for a CSS gradient.
 /// https://drafts.csswg.org/css-images/#gradients
 pub type Gradient = GenericGradient<
     LineDirection,
     Length,
     LengthOrPercentage,
     Position,
@@ -74,17 +75,17 @@ pub type EndingShape = GenericEndingShap
 /// A specified gradient item.
 pub type GradientItem = GenericGradientItem<RGBAColor, LengthOrPercentage>;
 
 /// A computed color stop.
 pub type ColorStop = GenericColorStop<RGBAColor, LengthOrPercentage>;
 
 /// Specified values for `moz-image-rect`
 /// -moz-image-rect(<uri>, top, right, bottom, left);
-pub type MozImageRect = GenericMozImageRect<NumberOrPercentage>;
+pub type ImageRect = GenericImageRect<NumberOrPercentage>;
 
 impl Parse for Image {
     fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Image, ParseError<'i>> {
         #[cfg(feature = "gecko")]
         {
           if let Ok(mut url) = input.try(|input| SpecifiedUrl::parse(context, input)) {
               url.build_image_value();
               return Ok(GenericImage::Url(url));
@@ -102,24 +103,24 @@ impl Parse for Image {
         #[cfg(feature = "servo")]
         {
             if let Ok(paint_worklet) = input.try(|i| PaintWorklet::parse(context, i)) {
                 return Ok(GenericImage::PaintWorklet(paint_worklet));
             }
         }
         #[cfg(feature = "gecko")]
         {
-            if let Ok(mut image_rect) = input.try(|input| MozImageRect::parse(context, input)) {
+            if let Ok(mut image_rect) = input.try(|input| ImageRect::parse(context, input)) {
                 image_rect.url.build_image_value();
                 return Ok(GenericImage::Rect(image_rect));
             }
         }
         #[cfg(feature = "servo")]
         {
-            if let Ok(image_rect) = input.try(|input| MozImageRect::parse(context, input)) {
+            if let Ok(image_rect) = input.try(|input| ImageRect::parse(context, input)) {
                 return Ok(GenericImage::Rect(image_rect));
             }
         }
 
         Ok(GenericImage::Element(Image::parse_element(input)?))
     }
 }
 
@@ -699,32 +700,32 @@ impl Parse for PaintWorklet {
             let name = i.expect_ident()?;
             Ok(PaintWorklet {
                 name: Atom::from(name),
             })
         })
     }
 }
 
-impl Parse for MozImageRect {
+impl Parse for ImageRect {
     fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
         input.try(|i| i.expect_function_matching("-moz-image-rect"))?;
         input.parse_nested_block(|i| {
             let string = i.expect_url_or_string()?;
             let url = SpecifiedUrl::parse_from_string(string, context)?;
             i.expect_comma()?;
             let top = NumberOrPercentage::parse_non_negative(context, i)?;
             i.expect_comma()?;
             let right = NumberOrPercentage::parse_non_negative(context, i)?;
             i.expect_comma()?;
             let bottom = NumberOrPercentage::parse_non_negative(context, i)?;
             i.expect_comma()?;
             let left = NumberOrPercentage::parse_non_negative(context, i)?;
 
-            Ok(MozImageRect {
+            Ok(ImageRect {
                 url: url,
                 top: top,
                 right: right,
                 bottom: bottom,
                 left: left,
             })
         })
     }
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -31,17 +31,17 @@ pub use self::align::{AlignItems, AlignJ
 pub use self::background::BackgroundSize;
 pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
 pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth};
 pub use self::color::{Color, RGBAColor};
 pub use self::rect::LengthOrNumberRect;
 #[cfg(feature = "gecko")]
 pub use self::gecko::ScrollSnapPoint;
 pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
-pub use self::image::{GradientItem, GradientKind, Image, MozImageRect, ImageLayer};
+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, MozLength};
 pub use self::position::{Position, PositionComponent};
 pub use self::text::{InitialLetter, LetterSpacing, LineHeight, WordSpacing};
 pub use self::transform::{TimingFunction, TransformOrigin};