mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Introduce values::animated::Animate
This replaces the Animatable trait and merges its three former methods into a single one.
This commit is contained in:
parent
0cceeb9d5c
commit
aea0cd7ec7
23 changed files with 876 additions and 937 deletions
|
@ -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)?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue