mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Introduce #[animation(constant)] for the Animate trait
This allows us to handle fields that should be the same during animations.
This commit is contained in:
parent
e49dbc4dfa
commit
eaf2f1ec33
5 changed files with 59 additions and 52 deletions
|
@ -44,11 +44,18 @@ add_impls_for_keyword_enum!(ShapeBox);
|
|||
/// A shape source, for some reference box.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum ShapeSource<BasicShape, ReferenceBox, Url> {
|
||||
#[animation(error)]
|
||||
Url(Url),
|
||||
Shape(BasicShape, Option<ReferenceBox>),
|
||||
Shape(
|
||||
BasicShape,
|
||||
#[animation(constant)]
|
||||
Option<ReferenceBox>,
|
||||
),
|
||||
#[animation(error)]
|
||||
Box(ReferenceBox),
|
||||
#[animation(error)]
|
||||
None,
|
||||
}
|
||||
|
||||
|
@ -126,29 +133,6 @@ define_css_keyword_enum!(FillRule:
|
|||
);
|
||||
add_impls_for_keyword_enum!(FillRule);
|
||||
|
||||
// FIXME(nox): This should be derivable, but we need to implement Animate
|
||||
// on the T types.
|
||||
impl<B, T, U> Animate for ShapeSource<B, T, U>
|
||||
where
|
||||
B: Animate,
|
||||
T: Clone + PartialEq,
|
||||
{
|
||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||
match (self, other) {
|
||||
(
|
||||
&ShapeSource::Shape(ref this, ref this_box),
|
||||
&ShapeSource::Shape(ref other, ref other_box),
|
||||
) if this_box == other_box => {
|
||||
Ok(ShapeSource::Shape(
|
||||
this.animate(other, procedure)?,
|
||||
this_box.clone(),
|
||||
))
|
||||
},
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(nox): Implement ComputeSquaredDistance for T types and stop
|
||||
// using PartialEq here, this will let us derive this impl.
|
||||
impl<B, T, U> ComputeSquaredDistance for ShapeSource<B, T, U>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue