mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +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
|
@ -211,7 +211,7 @@ class Longhand(object):
|
|||
self.animatable = False
|
||||
self.transitionable = False
|
||||
self.animation_type = None
|
||||
# NB: Animatable implies clone because a property animation requires a
|
||||
# NB: Animate implies clone because a property animation requires a
|
||||
# copy of the computed value.
|
||||
#
|
||||
# See components/style/helpers/animated_properties.mako.rs.
|
||||
|
|
|
@ -133,17 +133,12 @@
|
|||
);
|
||||
|
||||
% if need_animatable or animation_value_type == "ComputedValue":
|
||||
use properties::animated_properties::Animatable;
|
||||
use values::animated::ToAnimatedZero;
|
||||
use values::animated::{Animate, Procedure, ToAnimatedZero};
|
||||
|
||||
impl Animatable for T {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
-> Result<Self, ()> {
|
||||
self.0.add_weighted(&other.0, self_portion, other_portion).map(T)
|
||||
}
|
||||
|
||||
fn add(&self, other: &Self) -> Result<Self, ()> {
|
||||
self.0.add(&other.0).map(T)
|
||||
impl Animate for T {
|
||||
#[inline]
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
Ok(T(self.0.animate(&other.0, procedure)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1115,9 +1115,8 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use properties::animated_properties::Animatable;
|
||||
use values::CSSFloat;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -1137,12 +1136,12 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
}
|
||||
}
|
||||
|
||||
impl Animatable for T {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
-> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(T::Number(ref number), T::Number(ref other)) =>
|
||||
Ok(T::Number(number.add_weighted(other, self_portion, other_portion)?)),
|
||||
impl Animate for T {
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
match (self, other) {
|
||||
(&T::Number(ref number), &T::Number(ref other)) => {
|
||||
Ok(T::Number(number.animate(other, procedure)?))
|
||||
},
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
use values::specified::length::NonNegativeLength;
|
||||
|
||||
pub mod computed_value {
|
||||
use properties::animated_properties::Animatable;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use values::computed::NonNegativeAu;
|
||||
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
@ -38,15 +37,12 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
|||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
|
||||
impl Animatable for T {
|
||||
impl Animate for T {
|
||||
#[inline]
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
-> Result<Self, ()> {
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
Ok(T {
|
||||
horizontal: self.horizontal.add_weighted(&other.horizontal,
|
||||
self_portion, other_portion)?,
|
||||
vertical: self.vertical.add_weighted(&other.vertical,
|
||||
self_portion, other_portion)?,
|
||||
horizontal: self.horizontal.animate(&other.horizontal, procedure)?,
|
||||
vertical: self.vertical.animate(&other.vertical, procedure)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue