diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 91eda7df3e4..458814ba17f 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -2384,27 +2384,6 @@ pub type IntermediateSVGPaint = SVGPaint; /// Animated SVGPaintKind pub type IntermediateSVGPaintKind = SVGPaintKind; -impl Animate for IntermediateSVGPaint { - #[inline] - fn animate(&self, other: &Self, procedure: Procedure) -> Result { - Ok(IntermediateSVGPaint { - kind: self.kind.animate(&other.kind, procedure)?, - fallback: self.fallback.animate(&other.fallback, procedure)?, - }) - } -} - -impl ComputeSquaredDistance for IntermediateSVGPaint { - #[inline] - fn compute_squared_distance(&self, other: &Self) -> Result { - // FIXME(nox): This should be derived. - Ok( - self.kind.compute_squared_distance(&other.kind)? + - self.fallback.compute_squared_distance(&other.fallback)?, - ) - } -} - impl ToAnimatedZero for IntermediateSVGPaint { #[inline] fn to_animated_zero(&self) -> Result { @@ -2415,56 +2394,6 @@ impl ToAnimatedZero for IntermediateSVGPaint { } } -impl Animate for IntermediateSVGPaintKind { - #[inline] - fn animate(&self, other: &Self, procedure: Procedure) -> Result { - match (self, other) { - (&SVGPaintKind::Color(ref this), &SVGPaintKind::Color(ref other)) => { - Ok(SVGPaintKind::Color(this.animate(other, procedure)?)) - }, - (&SVGPaintKind::ContextFill, &SVGPaintKind::ContextFill) => Ok(SVGPaintKind::ContextFill), - (&SVGPaintKind::ContextStroke, &SVGPaintKind::ContextStroke) => Ok(SVGPaintKind::ContextStroke), - _ => { - // FIXME: Context values should be interpolable with colors, - // Gecko doesn't implement this behavior either. - Err(()) - } - } - } -} - -impl ComputeSquaredDistance for IntermediateSVGPaintKind { - #[inline] - fn compute_squared_distance(&self, other: &Self) -> Result { - match (self, other) { - (&SVGPaintKind::Color(ref this), &SVGPaintKind::Color(ref other)) => { - this.compute_squared_distance(other) - } - (&SVGPaintKind::None, &SVGPaintKind::None) | - (&SVGPaintKind::ContextFill, &SVGPaintKind::ContextFill) | - (&SVGPaintKind::ContextStroke, &SVGPaintKind::ContextStroke) => { - Ok(SquaredDistance::Value(0.)) - }, - _ => Err(()) - } - } -} - -impl ToAnimatedZero for IntermediateSVGPaintKind { - #[inline] - fn to_animated_zero(&self) -> Result { - match *self { - SVGPaintKind::Color(ref color) => { - Ok(SVGPaintKind::Color(color.to_animated_zero()?)) - }, - SVGPaintKind::None | - SVGPaintKind::ContextFill | - SVGPaintKind::ContextStroke => Ok(self.clone()), - _ => Err(()), - } - } -} - impl From for NumberOrPercentage { fn from(lop: NonNegativeLengthOrPercentage) -> NumberOrPercentage { lop.0.into() diff --git a/components/style/values/generics/svg.rs b/components/style/values/generics/svg.rs index bc3cb5fda18..87b0a74bc23 100644 --- a/components/style/values/generics/svg.rs +++ b/components/style/values/generics/svg.rs @@ -16,7 +16,8 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// /// https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, PartialEq)] +#[derive(ToAnimatedValue, ToComputedValue, ToCss)] pub struct SVGPaint { /// The paint source pub kind: SVGPaintKind, @@ -30,13 +31,15 @@ pub struct SVGPaint { /// to have a fallback, Gecko lets the context /// properties have a fallback as well. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, PartialEq)] +#[derive(ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] pub enum SVGPaintKind { /// `none` None, /// `` Color(ColorType), /// `url(...)` + #[animation(error)] PaintServer(UrlPaintServer), /// `context-fill` ContextFill,