style: Flip boolean half way for path interpolation.

According to the new svg 2 spec update (#543), we flip the flag half way for
path interpolation.

Differential Revision: https://phabricator.services.mozilla.com/D6192
This commit is contained in:
Boris Chiou 2018-09-21 18:39:41 +00:00 committed by Emilio Cobos Álvarez
parent b55bfc49fb
commit e5f8155d6c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -13,7 +13,7 @@ use std::slice;
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use style_traits::values::SequenceWriter;
use values::CSSFloat;
use values::animated::{Animate, Procedure};
use values::animated::{Animate, Procedure, ToAnimatedZero};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
/// The SVG path data.
@ -198,9 +198,7 @@ pub enum PathCommand {
rx: CSSFloat,
ry: CSSFloat,
angle: CSSFloat,
#[animation(constant)]
large_arc_flag: ArcFlag,
#[animation(constant)]
sweep_flag: ArcFlag,
point: CoordPair,
absolute: IsAbsolute,
@ -538,6 +536,34 @@ impl ToCss for ArcFlag {
}
}
impl Animate for ArcFlag {
#[inline]
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
(self.0 as i32)
.animate(&(other.0 as i32), procedure)
.map(|v| ArcFlag(v > 0))
}
}
impl ComputeSquaredDistance for ArcFlag {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
(self.0 as i32).compute_squared_distance(&(other.0 as i32))
}
}
impl ToAnimatedZero for ArcFlag {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
// The 2 ArcFlags in EllipticalArc determine which one of the 4 different arcs will be
// used. (i.e. From 4 combinations). In other words, if we change the flag, we get a
// different arc. Therefore, we return *self.
// https://svgwg.org/svg2-draft/paths.html#PathDataEllipticalArcCommands
Ok(*self)
}
}
/// SVG Path parser.
struct PathParser<'a> {
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,