Bug 1468269: Derive Animate for ComplexColorRatios. r?kamidphish draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 11 Jun 2018 16:54:27 -0700
changeset 806797 18b9d24a871eabdbd3f02f6d249cb3aefe52faf9
parent 806794 ff024044b5108e081bd756b88759589ad0a23722
push id112961
push userbmo:emilio@crisal.io
push dateTue, 12 Jun 2018 00:14:56 +0000
reviewerskamidphish
bugs1468269
milestone62.0a1
Bug 1468269: Derive Animate for ComplexColorRatios. r?kamidphish It'd generate the same implementation. MozReview-Commit-ID: Afpv0sjeWdj
servo/components/style/values/animated/color.rs
servo/components/style/values/generics/color.rs
--- a/servo/components/style/values/animated/color.rs
+++ b/servo/components/style/values/animated/color.rs
@@ -87,26 +87,16 @@ impl ComputeSquaredDistance for RGBA {
         start
             .iter()
             .zip(&end)
             .map(|(this, other)| this.compute_squared_distance(other))
             .sum()
     }
 }
 
-impl Animate for ComplexColorRatios {
-    #[inline]
-    fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
-        let bg = self.bg.animate(&other.bg, procedure)?;
-        let fg = self.fg.animate(&other.fg, procedure)?;
-
-        Ok(ComplexColorRatios { bg, fg })
-    }
-}
-
 /// An animated value for `<color>`.
 pub type Color = GenericColor<RGBA>;
 
 impl Color {
     fn effective_intermediate_rgba(&self) -> RGBA {
         match *self {
             GenericColor::Numeric(color) => color,
             GenericColor::Foreground => RGBA::transparent(),
--- a/servo/components/style/values/generics/color.rs
+++ b/servo/components/style/values/generics/color.rs
@@ -1,17 +1,17 @@
 /* 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 http://mozilla.org/MPL/2.0/. */
 
 //! Generic types for color properties.
 
 /// Ratios representing the contribution of color and currentcolor to
 /// the final color value.
-#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue)]
+#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue)]
 pub struct ComplexColorRatios {
     /// Numeric color contribution.
     pub bg: f32,
     /// Foreground color, aka currentcolor, contribution.
     pub fg: f32,
 }
 
 impl ComplexColorRatios {