Bug 1353202 - Define accumulate method on Animatable trait draft
authorBrian Birtles <birtles@gmail.com>
Mon, 22 May 2017 09:40:28 +0900
changeset 582188 5407f21e149395b22ea8bc09a5a23f1641c92d63
parent 582186 50a715ac36c2293fad61d84a39c3712c02c1e3f7
child 582189 ecc8b37a0daaec6edad859e92857da9fb1715333
push id59996
push userbbirtles@mozilla.com
push dateMon, 22 May 2017 01:51:27 +0000
bugs1353202
milestone55.0a1
Bug 1353202 - Define accumulate method on Animatable trait MozReview-Commit-ID: 4WdjAdtI0Mw
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -675,16 +675,25 @@ pub trait Animatable: Sized {
 
     /// Returns the [sum][animation-addition] of this value and |other|.
     ///
     /// [animation-addition]: https://w3c.github.io/web-animations/#animation-addition
     fn add(&self, other: &Self) -> Result<Self, ()> {
         self.add_weighted(other, 1.0, 1.0)
     }
 
+    /// [Accumulates][animation-accumulation] this value onto itself (|count| - 1) times then
+    /// accumulates |other| onto the result.
+    /// If |count| is zero, the result will be |other|.
+    ///
+    /// [animation-accumulation]: https://w3c.github.io/web-animations/#animation-accumulation
+    fn accumulate(&self, other: &Self, count: u64) -> Result<Self, ()> {
+        self.add_weighted(other, count as f64, 1.0)
+    }
+
     /// Compute distance between a value and another for a given property.
     fn compute_distance(&self, _other: &Self) -> Result<f64, ()>  { Err(()) }
 
     /// In order to compute the Euclidean distance of a list or property value with multiple
     /// components, we need to compute squared distance for each element, so the vector can sum it
     /// and then get its squared root as the distance.
     fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
         self.compute_distance(other).map(|d| d * d)