style: Make SVGPathData and clip-path: path() animatable.

Implement Animate trait for SVGPathData.

The basic idea is: we normalize |this| and |other| svg paths, and then
do interpolation on the normalized svg paths. The normalization is to
convert relative coordinates into absolute coordinates, so we could do
real number interpolation on each path command directly.

In this patch, we also make |clip-path:path()| animatable.

Differential Revision: https://phabricator.services.mozilla.com/D4786
This commit is contained in:
Boris Chiou 2018-09-07 22:15:50 +00:00 committed by Emilio Cobos Álvarez
parent 9c1c58a498
commit 14911b96e0
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 175 additions and 4 deletions

View file

@ -141,6 +141,20 @@ impl Animate for f64 {
}
}
/// This is only used in SVG PATH. We return Err(()) if the flags are mismatched.
// FIXME: Bug 653928: If we want to do interpolation on the flags in Arc, we have to update this
// because `absolute`, `large_arc_flag`, and `sweep_flag` are using this implementation for now.
impl Animate for bool {
#[inline]
fn animate(&self, other: &Self, _procedure: Procedure) -> Result<Self, ()> {
if *self == *other {
Ok(*other)
} else {
Err(())
}
}
}
impl<T> Animate for Option<T>
where
T: Animate,