Derive Animate for ComplexColorRatios. draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 11 Jun 2018 16:54:27 -0700
changeset 806795 991c57323224845ce335b98d14dd4fbe66ebaf82
parent 806794 ff024044b5108e081bd756b88759589ad0a23722
push id112959
push userbmo:emilio@crisal.io
push dateTue, 12 Jun 2018 00:01:42 +0000
bugs1468269
milestone62.0a1
Derive Animate for ComplexColorRatios. Summary: It'd generate the same implementation Test Plan: N/A Reviewers: Bug #: 1468269 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 {