mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Introduce #[animation]
For now, only #[animation(error)] is supported on variants and it makes both #[derive(Animate)] and #[derive(ComputeSquaredDistance)] ignore this particular variant.
This commit is contained in:
parent
17d97cf87b
commit
ff67fc751d
5 changed files with 31 additions and 45 deletions
|
@ -787,40 +787,6 @@ impl ToAnimatedZero for Visibility {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-length
|
||||
impl Animate for VerticalAlign {
|
||||
#[inline]
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
match (self, other) {
|
||||
(
|
||||
&VerticalAlign::LengthOrPercentage(ref this),
|
||||
&VerticalAlign::LengthOrPercentage(ref other),
|
||||
) => {
|
||||
Ok(VerticalAlign::LengthOrPercentage(
|
||||
this.animate(other, procedure)?
|
||||
))
|
||||
},
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputeSquaredDistance for VerticalAlign {
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
match (self, other) {
|
||||
(&VerticalAlign::LengthOrPercentage(ref this), &VerticalAlign::LengthOrPercentage(ref other)) => {
|
||||
this.compute_squared_distance(other)
|
||||
},
|
||||
_ => {
|
||||
// FIXME(nox): Should this return `Ok(SquaredDistance::Value(0.))`
|
||||
// if `self` and `other` are the same keyword value?
|
||||
Err(())
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedZero for VerticalAlign {
|
||||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
||||
|
|
|
@ -370,11 +370,12 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
|
|||
/// The keywords are the same, and the `LengthOrPercentage` is computed
|
||||
/// here.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)]
|
||||
pub enum T {
|
||||
% for keyword in vertical_align_keywords:
|
||||
${to_rust_ident(keyword)},
|
||||
#[animation(error)] // only animatable as a length
|
||||
${to_rust_ident(keyword)},
|
||||
% endfor
|
||||
LengthOrPercentage(computed::LengthOrPercentage),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue