mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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:
parent
9c1c58a498
commit
14911b96e0
4 changed files with 175 additions and 4 deletions
|
@ -54,7 +54,6 @@ pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> {
|
|||
Shape(BasicShape, Option<ReferenceBox>),
|
||||
#[animation(error)]
|
||||
Box(ReferenceBox),
|
||||
#[animation(error)]
|
||||
#[css(function)]
|
||||
Path(Path),
|
||||
#[animation(error)]
|
||||
|
@ -152,10 +151,12 @@ pub enum FillRule {
|
|||
///
|
||||
/// https://drafts.csswg.org/css-shapes-2/#funcdef-path
|
||||
#[css(comma)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue, ToCss)]
|
||||
pub struct Path {
|
||||
/// The filling rule for the svg path.
|
||||
#[css(skip_if = "fill_is_default")]
|
||||
#[animation(constant)]
|
||||
pub fill: FillRule,
|
||||
/// The svg path data.
|
||||
pub path: SVGPathData,
|
||||
|
@ -177,6 +178,13 @@ where
|
|||
{
|
||||
this.compute_squared_distance(other)
|
||||
},
|
||||
(
|
||||
&ShapeSource::Path(ref this),
|
||||
&ShapeSource::Path(ref other),
|
||||
) if this.fill == other.fill =>
|
||||
{
|
||||
this.path.compute_squared_distance(&other.path)
|
||||
}
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue