Bug 1353202 - Define accumulate method on Animatable trait
MozReview-Commit-ID: AYZx9X5WxDf
--- 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)