Introduce values::animated::Animate

This replaces the Animatable trait and merges its three former methods into a single one.
This commit is contained in:
Anthony Ramine 2017-08-17 16:38:08 +02:00
parent 0cceeb9d5c
commit aea0cd7ec7
23 changed files with 876 additions and 937 deletions

View file

@ -6,9 +6,9 @@
use cssparser::Parser;
use parser::{Parse, ParserContext};
use properties::animated_properties::Animatable;
use std::fmt;
use style_traits::{ToCss, ParseError};
use values::animated::{Animate, Procedure};
/// A CSS value made of four components, where its `ToCss` impl will try to
/// serialize as few components as possible, like for example in `border-width`.
@ -52,21 +52,17 @@ impl<T> Rect<T>
}
}
impl<L> Animatable for Rect<L>
impl<L> Animate for Rect<L>
where
L: Animatable,
L: Animate,
{
fn add_weighted(
&self,
other: &Self,
self_portion: f64,
other_portion: f64,
) -> Result<Self, ()> {
let first = self.0.add_weighted(&other.0, self_portion, other_portion)?;
let second = self.1.add_weighted(&other.1, self_portion, other_portion)?;
let third = self.2.add_weighted(&other.2, self_portion, other_portion)?;
let fourth = self.3.add_weighted(&other.3, self_portion, other_portion)?;
Ok(Rect(first, second, third, fourth))
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
Ok(Rect(
self.0.animate(&other.0, procedure)?,
self.1.animate(&other.1, procedure)?,
self.2.animate(&other.2, procedure)?,
self.3.animate(&other.3, procedure)?,
))
}
}