Rename the Interpolate trait to Animatable

This commit is contained in:
Brian Birtles 2017-05-10 13:38:06 +09:00
parent e029a42653
commit 4d25e87ac6
11 changed files with 89 additions and 88 deletions

View file

@ -111,8 +111,8 @@
pub struct T(pub SmallVec<[single_value::T; 1]>); pub struct T(pub SmallVec<[single_value::T; 1]>);
% if delegate_animate: % if delegate_animate:
use properties::animated_properties::Interpolate; use properties::animated_properties::Animatable;
impl Interpolate for T { impl Animatable for T {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
self.0.interpolate(&other.0, progress).map(T) self.0.interpolate(&other.0, progress).map(T)
} }
@ -974,10 +974,10 @@
%> %>
</%def> </%def>
/// Macro for defining Interpolate trait for tuple struct which has Option<T>, /// Macro for defining Animatable trait for tuple struct which has Option<T>,
/// e.g. struct T(pub Option<Au>). /// e.g. struct T(pub Option<Au>).
<%def name="impl_interpolate_for_option_tuple(value_for_none)"> <%def name="impl_animatable_for_option_tuple(value_for_none)">
impl Interpolate for T { impl Animatable for T {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (self, other) { match (self, other) {

View file

@ -581,7 +581,7 @@ impl AnimationValue {
} }
} }
impl Interpolate for AnimationValue { impl Animatable for AnimationValue {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (self, other) { match (self, other) {
% for prop in data.longhands: % for prop in data.longhands:
@ -613,17 +613,17 @@ impl Interpolate for AnimationValue {
/// A trait used to implement [interpolation][interpolated-types]. /// A trait used to implement [interpolation][interpolated-types].
/// ///
/// [interpolated-types]: https://drafts.csswg.org/css-transitions/#interpolated-types /// [interpolated-types]: https://drafts.csswg.org/css-transitions/#interpolated-types
pub trait Interpolate: Sized { pub trait Animatable: Sized {
/// Interpolate a value with another for a given property. /// Interpolate a value with another for a given property.
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()>; fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()>;
} }
/// https://drafts.csswg.org/css-transitions/#animtype-repeatable-list /// https://drafts.csswg.org/css-transitions/#animtype-repeatable-list
pub trait RepeatableListInterpolate: Interpolate {} pub trait RepeatableListAnimatable: Animatable {}
impl RepeatableListInterpolate for Either<f32, LengthOrPercentage> {} impl RepeatableListAnimatable for Either<f32, LengthOrPercentage> {}
impl<T: RepeatableListInterpolate> Interpolate for SmallVec<[T; 1]> { impl<T: RepeatableListAnimatable> Animatable for SmallVec<[T; 1]> {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
use num_integer::lcm; use num_integer::lcm;
let len = lcm(self.len(), other.len()); let len = lcm(self.len(), other.len());
@ -634,15 +634,15 @@ impl<T: RepeatableListInterpolate> Interpolate for SmallVec<[T; 1]> {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-number /// https://drafts.csswg.org/css-transitions/#animtype-number
impl Interpolate for Au { impl Animatable for Au {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Au((self.0 as f64 + (other.0 as f64 - self.0 as f64) * progress).round() as i32)) Ok(Au((self.0 as f64 + (other.0 as f64 - self.0 as f64) * progress).round() as i32))
} }
} }
impl <T> Interpolate for Option<T> impl <T> Animatable for Option<T>
where T: Interpolate, where T: Animatable,
{ {
#[inline] #[inline]
fn interpolate(&self, other: &Option<T>, progress: f64) -> Result<Option<T>, ()> { fn interpolate(&self, other: &Option<T>, progress: f64) -> Result<Option<T>, ()> {
@ -656,7 +656,7 @@ impl <T> Interpolate for Option<T>
} }
/// https://drafts.csswg.org/css-transitions/#animtype-number /// https://drafts.csswg.org/css-transitions/#animtype-number
impl Interpolate for f32 { impl Animatable for f32 {
#[inline] #[inline]
fn interpolate(&self, other: &f32, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &f32, progress: f64) -> Result<Self, ()> {
Ok(((*self as f64) + ((*other as f64) - (*self as f64)) * progress) as f32) Ok(((*self as f64) + ((*other as f64) - (*self as f64)) * progress) as f32)
@ -664,7 +664,7 @@ impl Interpolate for f32 {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-number /// https://drafts.csswg.org/css-transitions/#animtype-number
impl Interpolate for f64 { impl Animatable for f64 {
#[inline] #[inline]
fn interpolate(&self, other: &f64, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &f64, progress: f64) -> Result<Self, ()> {
Ok(*self + (*other - *self) * progress) Ok(*self + (*other - *self) * progress)
@ -672,7 +672,7 @@ impl Interpolate for f64 {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-integer /// https://drafts.csswg.org/css-transitions/#animtype-integer
impl Interpolate for i32 { impl Animatable for i32 {
#[inline] #[inline]
fn interpolate(&self, other: &i32, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &i32, progress: f64) -> Result<Self, ()> {
let a = *self as f64; let a = *self as f64;
@ -682,7 +682,7 @@ impl Interpolate for i32 {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-number /// https://drafts.csswg.org/css-transitions/#animtype-number
impl Interpolate for Angle { impl Animatable for Angle {
#[inline] #[inline]
fn interpolate(&self, other: &Angle, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Angle, progress: f64) -> Result<Self, ()> {
self.radians().interpolate(&other.radians(), progress).map(Angle::from_radians) self.radians().interpolate(&other.radians(), progress).map(Angle::from_radians)
@ -690,7 +690,7 @@ impl Interpolate for Angle {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-visibility /// https://drafts.csswg.org/css-transitions/#animtype-visibility
impl Interpolate for Visibility { impl Animatable for Visibility {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -708,7 +708,7 @@ impl Interpolate for Visibility {
} }
} }
impl<T: Interpolate + Copy> Interpolate for Size2D<T> { impl<T: Animatable + Copy> Animatable for Size2D<T> {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
let width = try!(self.width.interpolate(&other.width, progress)); let width = try!(self.width.interpolate(&other.width, progress));
@ -718,7 +718,7 @@ impl<T: Interpolate + Copy> Interpolate for Size2D<T> {
} }
} }
impl<T: Interpolate + Copy> Interpolate for Point2D<T> { impl<T: Animatable + Copy> Animatable for Point2D<T> {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
let x = try!(self.x.interpolate(&other.x, progress)); let x = try!(self.x.interpolate(&other.x, progress));
@ -728,7 +728,7 @@ impl<T: Interpolate + Copy> Interpolate for Point2D<T> {
} }
} }
impl Interpolate for BorderRadiusSize { impl Animatable for BorderRadiusSize {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
self.0.interpolate(&other.0, progress).map(generics::BorderRadiusSize) self.0.interpolate(&other.0, progress).map(generics::BorderRadiusSize)
@ -736,7 +736,7 @@ impl Interpolate for BorderRadiusSize {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-length /// https://drafts.csswg.org/css-transitions/#animtype-length
impl Interpolate for VerticalAlign { impl Animatable for VerticalAlign {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -751,7 +751,7 @@ impl Interpolate for VerticalAlign {
} }
} }
impl Interpolate for BackgroundSizeList { impl Animatable for BackgroundSizeList {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
self.0.interpolate(&other.0, progress).map(BackgroundSizeList) self.0.interpolate(&other.0, progress).map(BackgroundSizeList)
@ -759,7 +759,7 @@ impl Interpolate for BackgroundSizeList {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-color /// https://drafts.csswg.org/css-transitions/#animtype-color
impl Interpolate for RGBA { impl Animatable for RGBA {
#[inline] #[inline]
fn interpolate(&self, other: &RGBA, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &RGBA, progress: f64) -> Result<Self, ()> {
fn clamp(val: f32) -> f32 { fn clamp(val: f32) -> f32 {
@ -786,7 +786,7 @@ impl Interpolate for RGBA {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-color /// https://drafts.csswg.org/css-transitions/#animtype-color
impl Interpolate for CSSParserColor { impl Animatable for CSSParserColor {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -799,14 +799,14 @@ impl Interpolate for CSSParserColor {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for CalcLengthOrPercentage { impl Animatable for CalcLengthOrPercentage {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
fn interpolate_half<T>(this: Option<T>, fn interpolate_half<T>(this: Option<T>,
other: Option<T>, other: Option<T>,
progress: f64) progress: f64)
-> Result<Option<T>, ()> -> Result<Option<T>, ()>
where T: Default + Interpolate, where T: Default + Animatable,
{ {
match (this, other) { match (this, other) {
(None, None) => Ok(None), (None, None) => Ok(None),
@ -826,7 +826,7 @@ impl Interpolate for CalcLengthOrPercentage {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for LengthOrPercentage { impl Animatable for LengthOrPercentage {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -849,7 +849,7 @@ impl Interpolate for LengthOrPercentage {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for LengthOrPercentageOrAuto { impl Animatable for LengthOrPercentageOrAuto {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -877,7 +877,7 @@ impl Interpolate for LengthOrPercentageOrAuto {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for LengthOrPercentageOrNone { impl Animatable for LengthOrPercentageOrNone {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -898,7 +898,7 @@ impl Interpolate for LengthOrPercentageOrNone {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for MinLength { impl Animatable for MinLength {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -912,7 +912,7 @@ impl Interpolate for MinLength {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc /// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for MaxLength { impl Animatable for MaxLength {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -927,7 +927,7 @@ impl Interpolate for MaxLength {
/// https://drafts.csswg.org/css-transitions/#animtype-number /// https://drafts.csswg.org/css-transitions/#animtype-number
/// https://drafts.csswg.org/css-transitions/#animtype-length /// https://drafts.csswg.org/css-transitions/#animtype-length
impl Interpolate for LineHeight { impl Animatable for LineHeight {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -948,7 +948,7 @@ impl Interpolate for LineHeight {
} }
/// http://dev.w3.org/csswg/css-transitions/#animtype-font-weight /// http://dev.w3.org/csswg/css-transitions/#animtype-font-weight
impl Interpolate for FontWeight { impl Animatable for FontWeight {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
let a = (*self as u32) as f64; let a = (*self as u32) as f64;
@ -977,7 +977,7 @@ impl Interpolate for FontWeight {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list /// https://drafts.csswg.org/css-transitions/#animtype-simple-list
impl<H: Interpolate, V: Interpolate> Interpolate for generic_position::Position<H, V> { impl<H: Animatable, V: Animatable> Animatable for generic_position::Position<H, V> {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(generic_position::Position { Ok(generic_position::Position {
@ -987,31 +987,31 @@ impl<H: Interpolate, V: Interpolate> Interpolate for generic_position::Position<
} }
} }
impl<H, V> RepeatableListInterpolate for generic_position::Position<H, V> impl<H, V> RepeatableListAnimatable for generic_position::Position<H, V>
where H: RepeatableListInterpolate, V: RepeatableListInterpolate {} where H: RepeatableListAnimatable, V: RepeatableListAnimatable {}
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list /// https://drafts.csswg.org/css-transitions/#animtype-simple-list
impl Interpolate for HorizontalPosition { impl Animatable for HorizontalPosition {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
self.0.interpolate(&other.0, progress).map(generic_position::HorizontalPosition) self.0.interpolate(&other.0, progress).map(generic_position::HorizontalPosition)
} }
} }
impl RepeatableListInterpolate for HorizontalPosition {} impl RepeatableListAnimatable for HorizontalPosition {}
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list /// https://drafts.csswg.org/css-transitions/#animtype-simple-list
impl Interpolate for VerticalPosition { impl Animatable for VerticalPosition {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
self.0.interpolate(&other.0, progress).map(generic_position::VerticalPosition) self.0.interpolate(&other.0, progress).map(generic_position::VerticalPosition)
} }
} }
impl RepeatableListInterpolate for VerticalPosition {} impl RepeatableListAnimatable for VerticalPosition {}
/// https://drafts.csswg.org/css-transitions/#animtype-rect /// https://drafts.csswg.org/css-transitions/#animtype-rect
impl Interpolate for ClipRect { impl Animatable for ClipRect {
#[inline] #[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(ClipRect { Ok(ClipRect {
@ -1023,8 +1023,8 @@ impl Interpolate for ClipRect {
} }
} }
<%def name="impl_interpolate_for_shadow(item, transparent_color)"> <%def name="impl_animatable_for_shadow(item, transparent_color)">
impl Interpolate for ${item} { impl Animatable for ${item} {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
% if "Box" in item: % if "Box" in item:
@ -1056,7 +1056,7 @@ impl Interpolate for ClipRect {
} }
/// https://drafts.csswg.org/css-transitions/#animtype-shadow-list /// https://drafts.csswg.org/css-transitions/#animtype-shadow-list
impl Interpolate for ${item}List { impl Animatable for ${item}List {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
// The inset value must change // The inset value must change
@ -1109,8 +1109,8 @@ impl Interpolate for ClipRect {
} }
</%def> </%def>
${impl_interpolate_for_shadow('BoxShadow', 'CSSParserColor::RGBA(RGBA::transparent())',)} ${impl_animatable_for_shadow('BoxShadow', 'CSSParserColor::RGBA(RGBA::transparent())',)}
${impl_interpolate_for_shadow('TextShadow', 'CSSParserColor::RGBA(RGBA::transparent())',)} ${impl_animatable_for_shadow('TextShadow', 'CSSParserColor::RGBA(RGBA::transparent())',)}
/// Check if it's possible to do a direct numerical interpolation /// Check if it's possible to do a direct numerical interpolation
/// between these two transform lists. /// between these two transform lists.
@ -1321,7 +1321,7 @@ pub struct MatrixDecomposed2D {
pub matrix: InnerMatrix2D, pub matrix: InnerMatrix2D,
} }
impl Interpolate for InnerMatrix2D { impl Animatable for InnerMatrix2D {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(InnerMatrix2D { Ok(InnerMatrix2D {
m11: try!(self.m11.interpolate(&other.m11, progress)), m11: try!(self.m11.interpolate(&other.m11, progress)),
@ -1332,7 +1332,7 @@ impl Interpolate for InnerMatrix2D {
} }
} }
impl Interpolate for Translate2D { impl Animatable for Translate2D {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Translate2D( Ok(Translate2D(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1341,7 +1341,7 @@ impl Interpolate for Translate2D {
} }
} }
impl Interpolate for Scale2D { impl Animatable for Scale2D {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Scale2D( Ok(Scale2D(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1350,7 +1350,7 @@ impl Interpolate for Scale2D {
} }
} }
impl Interpolate for MatrixDecomposed2D { impl Animatable for MatrixDecomposed2D {
/// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-2d-matrix-values /// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-2d-matrix-values
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
// If x-axis of one is flipped, and y-axis of the other, // If x-axis of one is flipped, and y-axis of the other,
@ -1396,7 +1396,7 @@ impl Interpolate for MatrixDecomposed2D {
} }
} }
impl Interpolate for ComputedMatrix { impl Animatable for ComputedMatrix {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
if self.is_3d() || other.is_3d() { if self.is_3d() || other.is_3d() {
let decomposed_from = decompose_3d_matrix(*self); let decomposed_from = decompose_3d_matrix(*self);
@ -1730,7 +1730,7 @@ fn cross(row1: [f32; 3], row2: [f32; 3]) -> [f32; 3] {
] ]
} }
impl Interpolate for Translate3D { impl Animatable for Translate3D {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Translate3D( Ok(Translate3D(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1740,7 +1740,7 @@ impl Interpolate for Translate3D {
} }
} }
impl Interpolate for Scale3D { impl Animatable for Scale3D {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Scale3D( Ok(Scale3D(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1750,7 +1750,7 @@ impl Interpolate for Scale3D {
} }
} }
impl Interpolate for Skew { impl Animatable for Skew {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Skew( Ok(Skew(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1760,7 +1760,7 @@ impl Interpolate for Skew {
} }
} }
impl Interpolate for Perspective { impl Animatable for Perspective {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(Perspective( Ok(Perspective(
try!(self.0.interpolate(&other.0, progress)), try!(self.0.interpolate(&other.0, progress)),
@ -1771,7 +1771,7 @@ impl Interpolate for Perspective {
} }
} }
impl Interpolate for MatrixDecomposed3D { impl Animatable for MatrixDecomposed3D {
/// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-3d-matrix-values /// https://drafts.csswg.org/css-transforms/#interpolation-of-decomposed-3d-matrix-values
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
let mut interpolated = *self; let mut interpolated = *self;
@ -2009,7 +2009,7 @@ impl ComputedMatrix {
} }
/// https://drafts.csswg.org/css-transforms/#interpolation-of-transforms /// https://drafts.csswg.org/css-transforms/#interpolation-of-transforms
impl Interpolate for TransformList { impl Animatable for TransformList {
#[inline] #[inline]
fn interpolate(&self, other: &TransformList, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &TransformList, progress: f64) -> Result<Self, ()> {
// http://dev.w3.org/csswg/css-transforms/#interpolation-of-transforms // http://dev.w3.org/csswg/css-transforms/#interpolation-of-transforms
@ -2038,8 +2038,8 @@ impl Interpolate for TransformList {
} }
} }
impl<T, U> Interpolate for Either<T, U> impl<T, U> Animatable for Either<T, U>
where T: Interpolate + Copy, U: Interpolate + Copy, where T: Animatable + Copy, U: Animatable + Copy,
{ {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
@ -2105,8 +2105,8 @@ impl IntermediateRGBA {
} }
} }
/// Unlike Interpolate for RGBA we don't clamp any component values. /// Unlike Animatable for RGBA we don't clamp any component values.
impl Interpolate for IntermediateRGBA { impl Animatable for IntermediateRGBA {
#[inline] #[inline]
fn interpolate(&self, other: &IntermediateRGBA, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &IntermediateRGBA, progress: f64) -> Result<Self, ()> {
let alpha = try!(self.alpha.interpolate(&other.alpha, progress)); let alpha = try!(self.alpha.interpolate(&other.alpha, progress));
@ -2803,7 +2803,7 @@ pub enum IntermediateColor {
IntermediateRGBA(IntermediateRGBA), IntermediateRGBA(IntermediateRGBA),
} }
impl Interpolate for IntermediateColor { impl Animatable for IntermediateColor {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
@ -2907,8 +2907,8 @@ impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
} }
} }
} }
${impl_interpolate_for_shadow('Intermediate%sShadow' % type, ${impl_animatable_for_shadow('Intermediate%sShadow' % type,
'IntermediateColor::IntermediateRGBA(IntermediateRGBA::transparent())')} 'IntermediateColor::IntermediateRGBA(IntermediateRGBA::transparent())')}
</%def> </%def>
${impl_intermediate_type_for_shadow('Box')} ${impl_intermediate_type_for_shadow('Box')}

View file

@ -195,7 +195,8 @@ ${helpers.single_keyword("background-origin",
#[allow(missing_docs)] #[allow(missing_docs)]
pub mod computed_value { pub mod computed_value {
use values::computed::LengthOrPercentageOrAuto; use values::computed::LengthOrPercentageOrAuto;
use properties::animated_properties::{ComputeDistance, Interpolate, RepeatableListInterpolate}; use properties::animated_properties::{Animatable, ComputeDistance,
RepeatableListAnimatable};
#[derive(PartialEq, Clone, Debug)] #[derive(PartialEq, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -212,9 +213,9 @@ ${helpers.single_keyword("background-origin",
Contain, Contain,
} }
impl RepeatableListInterpolate for T {} impl RepeatableListAnimatable for T {}
impl Interpolate for T { impl Animatable for T {
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
use properties::longhands::background_size::single_value::computed_value::ExplicitSize; use properties::longhands::background_size::single_value::computed_value::ExplicitSize;
match (self, other) { match (self, other) {

View file

@ -2181,7 +2181,7 @@ ${helpers.single_keyword("transform-style",
use values::specified::{NoCalcLength, LengthOrPercentage, Percentage}; use values::specified::{NoCalcLength, LengthOrPercentage, Percentage};
pub mod computed_value { pub mod computed_value {
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{Animatable, ComputeDistance};
use values::computed::{Length, LengthOrPercentage}; use values::computed::{Length, LengthOrPercentage};
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
@ -2192,7 +2192,7 @@ ${helpers.single_keyword("transform-style",
pub depth: Length, pub depth: Length,
} }
impl Interpolate for T { impl Animatable for T {
#[inline] #[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(T { Ok(T {

View file

@ -1022,7 +1022,7 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
pub mod computed_value { pub mod computed_value {
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{Animatable, ComputeDistance};
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::CSSFloat; use values::CSSFloat;
@ -1054,7 +1054,7 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
} }
impl Interpolate for T { impl Animatable for T {
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
match (*self, *other) { match (*self, *other) {
(T::Number(ref number), T::Number(ref other)) => (T::Number(ref number), T::Number(ref other)) =>

View file

@ -30,7 +30,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{Animatable, ComputeDistance};
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -40,7 +40,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
} }
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list /// https://drafts.csswg.org/css-transitions/#animtype-simple-list
impl Interpolate for T { impl Animatable for T {
#[inline] #[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(T { Ok(T {

View file

@ -441,13 +441,13 @@ ${helpers.single_keyword("text-align-last",
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{Animatable, ComputeDistance};
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<Au>); pub struct T(pub Option<Au>);
${helpers.impl_interpolate_for_option_tuple('Au(0)')} ${helpers.impl_animatable_for_option_tuple('Au(0)')}
${helpers.impl_compute_distance_for_option_tuple('Au(0)')} ${helpers.impl_compute_distance_for_option_tuple('Au(0)')}
} }
@ -527,13 +527,13 @@ ${helpers.single_keyword("text-align-last",
} }
pub mod computed_value { pub mod computed_value {
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{ComputeDistance, Animatable};
use values::computed::LengthOrPercentage; use values::computed::LengthOrPercentage;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<LengthOrPercentage>); pub struct T(pub Option<LengthOrPercentage>);
${helpers.impl_interpolate_for_option_tuple('LengthOrPercentage::zero()')} ${helpers.impl_animatable_for_option_tuple('LengthOrPercentage::zero()')}
${helpers.impl_compute_distance_for_option_tuple('LengthOrPercentage::zero()')} ${helpers.impl_compute_distance_for_option_tuple('LengthOrPercentage::zero()')}
} }

View file

@ -99,17 +99,17 @@ ${helpers.single_keyword("mask-mode",
pub use properties::longhands::background_position_x::single_value::parse; pub use properties::longhands::background_position_x::single_value::parse;
pub use properties::longhands::background_position_x::single_value::SpecifiedValue; pub use properties::longhands::background_position_x::single_value::SpecifiedValue;
pub use properties::longhands::background_position_x::single_value::computed_value; pub use properties::longhands::background_position_x::single_value::computed_value;
use properties::animated_properties::{ComputeDistance, Interpolate, RepeatableListInterpolate}; use properties::animated_properties::{Animatable, ComputeDistance, RepeatableListAnimatable};
use properties::longhands::mask_position_x::computed_value::T as MaskPositionX; use properties::longhands::mask_position_x::computed_value::T as MaskPositionX;
impl Interpolate for MaskPositionX { impl Animatable for MaskPositionX {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(MaskPositionX(try!(self.0.interpolate(&other.0, progress)))) Ok(MaskPositionX(try!(self.0.interpolate(&other.0, progress))))
} }
} }
impl RepeatableListInterpolate for MaskPositionX {} impl RepeatableListAnimatable for MaskPositionX {}
impl ComputeDistance for MaskPositionX { impl ComputeDistance for MaskPositionX {
#[inline] #[inline]
@ -128,17 +128,17 @@ ${helpers.single_keyword("mask-mode",
pub use properties::longhands::background_position_y::single_value::parse; pub use properties::longhands::background_position_y::single_value::parse;
pub use properties::longhands::background_position_y::single_value::SpecifiedValue; pub use properties::longhands::background_position_y::single_value::SpecifiedValue;
pub use properties::longhands::background_position_y::single_value::computed_value; pub use properties::longhands::background_position_y::single_value::computed_value;
use properties::animated_properties::{ComputeDistance, Interpolate, RepeatableListInterpolate}; use properties::animated_properties::{Animatable, ComputeDistance, RepeatableListAnimatable};
use properties::longhands::mask_position_y::computed_value::T as MaskPositionY; use properties::longhands::mask_position_y::computed_value::T as MaskPositionY;
impl Interpolate for MaskPositionY { impl Animatable for MaskPositionY {
#[inline] #[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> { fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
Ok(MaskPositionY(try!(self.0.interpolate(&other.0, progress)))) Ok(MaskPositionY(try!(self.0.interpolate(&other.0, progress))))
} }
} }
impl RepeatableListInterpolate for MaskPositionY {} impl RepeatableListAnimatable for MaskPositionY {}
impl ComputeDistance for MaskPositionY { impl ComputeDistance for MaskPositionY {
#[inline] #[inline]

View file

@ -11,7 +11,7 @@
use Atom; use Atom;
pub use cssparser::{RGBA, Token, Parser, serialize_identifier, serialize_string}; pub use cssparser::{RGBA, Token, Parser, serialize_identifier, serialize_string};
use parser::{Parse, ParserContext}; use parser::{Parse, ParserContext};
use properties::animated_properties::{ComputeDistance, Interpolate}; use properties::animated_properties::{Animatable, ComputeDistance};
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
@ -127,7 +127,7 @@ macro_rules! define_keyword_type {
} }
} }
impl Interpolate for $name { impl Animatable for $name {
#[inline] #[inline]
fn interpolate(&self, _other: &Self, _progress: f64) -> Result<Self, ()> { fn interpolate(&self, _other: &Self, _progress: f64) -> Result<Self, ()> {
Ok($name) Ok($name)

View file

@ -75,7 +75,7 @@ use style::parser::{LengthParsingMode, ParserContext};
use style::properties::{CascadeFlags, ComputedValues, Importance, ParsedDeclaration, StyleBuilder}; use style::properties::{CascadeFlags, ComputedValues, Importance, ParsedDeclaration, StyleBuilder};
use style::properties::{PropertyDeclarationBlock, PropertyId}; use style::properties::{PropertyDeclarationBlock, PropertyId};
use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP; use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
use style::properties::animated_properties::{AnimationValue, ComputeDistance, Interpolate, TransitionProperty}; use style::properties::animated_properties::{Animatable, AnimationValue, ComputeDistance, TransitionProperty};
use style::properties::parse_one_declaration; use style::properties::parse_one_declaration;
use style::restyle_hints::{self, RestyleHint}; use style::restyle_hints::{self, RestyleHint};
use style::rule_tree::{StrongRuleNode, StyleSource}; use style::rule_tree::{StrongRuleNode, StyleSource};

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Color, RGBA}; use cssparser::{Color, RGBA};
use style::properties::animated_properties::Interpolate; use style::properties::animated_properties::Animatable;
#[test] #[test]
fn test_rgba_color_interepolation_preserves_transparent() { fn test_rgba_color_interepolation_preserves_transparent() {