Bug 1491954 - Flip boolean half way for path interpolation r=emilio
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 21 Sep 2018 18:39:41 +0000
changeset 493489 fa6ae63a781a189453340ad6d3667e0ba211ba52
parent 493488 fb218472a84096406d16026ee8e9eebbeb789534
child 493490 caccc6d0cd9a5e5d83f474e7637fbf953ab449cd
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1491954
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1491954 - Flip boolean half way for path interpolation r=emilio 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
dom/animation/test/mozilla/test_distance_of_path_function.html
layout/style/test/test_transitions_per_property.html
servo/components/style/values/specified/svg_path.rs
testing/web-platform/meta/css/motion/animation/offset-path-interpolation-002.html.ini
testing/web-platform/meta/css/motion/animation/offset-path-interpolation-004.html.ini
--- a/dom/animation/test/mozilla/test_distance_of_path_function.html
+++ b/dom/animation/test/mozilla/test_distance_of_path_function.html
@@ -106,21 +106,22 @@ test(function(t) {
                 Math.sqrt(30 * 30 * 2),
                 'path("M 0 0 T 30 30") and ' +
                 'path("M 0 0 T 0 0")');
 }, 'The smooth quadratic cubic B├ęzier curve commands');
 
 test(function(t) {
   var target = addDiv(t);
   var dist = getDistance(target, 'offset-path',
-                         'path("M 0 0 A 5 5 10 0 0 30 30")',
+                         'path("M 0 0 A 5 5 10 0 1 30 30")',
                          'path("M 0 0 A 4 4 5 0 0 20 20")');
   assert_equals(dist,
                 Math.sqrt(1 * 1 * 2 + // radii
                           5 * 5 +     // angle
+                          1 * 1 +     // flag
                           10 * 10 * 2),
                 'path("M 0 0 A 5 5 10 0 1 30 30") and ' +
                 'path("M 0 0 A 4 4 5 0 0 20 20")');
 }, 'The elliptical arc curve commands');
 
 test(function(t) {
   var target = addDiv(t);
   var dist = getDistance(target, 'offset-path',
--- a/layout/style/test/test_transitions_per_property.html
+++ b/layout/style/test/test_transitions_per_property.html
@@ -830,21 +830,16 @@ const pathFunctionTests = [
     end: "path('M 0 0 H 500')",
     expected: ["path", '"M 0 0 H 500"']
   },
   {
     start: "path('M 0 0 V 100')",
     end: "path('M 0 0 H 500')",
     expected: ["path", '"M 0 0 H 500"']
   },
-  {
-    start: "path('M 10 10 A 10 20 30 1 0 140 450')",
-    end: "path('M 10 10 A 50 60 70 0 1 380 290')",
-    expected: ["path", '"M 10 10 A 50 60 70 0 1 380 290"']
-  },
   // match
   {
     start: "path('M 100 100')",
     end: "path('M 100 500')",
     expected: ["path", '"M 100 200"']
   },
   {
     start: "path('M 10 10 L 100 100')",
@@ -881,16 +876,21 @@ const pathFunctionTests = [
     end: "path('M 10 10 T 500 280')",
     expected: ["path", '"M 10 10 T 200 220"']
   },
   {
     start: "path('M 10 10 A 10 20 30 0 1 140 450')",
     end: "path('M 10 10 A 50 60 70 0 1 380 290')",
     expected: ["path", '"M 10 10 A 20 30 40 0 1 200 410"']
   },
+  {
+    start: "path('M 10 10 A 10 20 30 1 0 140 450')",
+    end: "path('M 10 10 A 50 60 70 0 1 380 290')",
+    expected: ["path", '"M 10 10 A 20 30 40 1 0 200 410"']
+  },
   // mix relative and absolute coordinates
   {
     start: "path('m 10 20 h 30 v 60 h 10 v -10 l 110 60')",
     // =="path('M  10  20 H  40 V  80 H  50 V  70 L 160 130')"
     end: "path('M 130 140 H 120 V 160 H 130 V 150 L 200 170')",
     expected: ["path", '"M 40 50 H 60 V 100 H 70 V 90 L 170 140"']
   },
 ];
--- a/servo/components/style/values/specified/svg_path.rs
+++ b/servo/components/style/values/specified/svg_path.rs
@@ -8,17 +8,17 @@ use cssparser::Parser;
 use parser::{Parse, ParserContext};
 use std::fmt::{self, Write};
 use std::iter::{Cloned, Peekable};
 use std::ops::AddAssign;
 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.
 ///
 /// https://www.w3.org/TR/SVG11/paths.html#PathData
 #[derive(
     Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToAnimatedZero, ToComputedValue,
 )]
@@ -193,19 +193,17 @@ pub enum PathCommand {
         point: CoordPair,
         absolute: IsAbsolute,
     },
     /// The elliptical arc curve command.
     EllipticalArc {
         rx: CSSFloat,
         ry: CSSFloat,
         angle: CSSFloat,
-        #[animation(constant)]
         large_arc_flag: ArcFlag,
-        #[animation(constant)]
         sweep_flag: ArcFlag,
         point: CoordPair,
         absolute: IsAbsolute,
     },
     /// The "closepath" command.
     ClosePath,
 }
 
@@ -533,16 +531,44 @@ impl ToCss for ArcFlag {
     fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
     where
         W: fmt::Write,
     {
         (self.0 as i32).to_css(dest)
     }
 }
 
+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>>>,
     path: Vec<PathCommand>,
 }
 
 macro_rules! parse_arguments {
     (
deleted file mode 100644
--- a/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-002.html.ini
+++ /dev/null
@@ -1,40 +0,0 @@
-[offset-path-interpolation-002.html]
-  [Animation between "path('M 100 400 A 10 20 30 1 0 140 450')" and "path('M 300 200 A 50 60 70 0 1 380 290')" at progress -1]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('M 100 400 A 10 20 30 1 0 140 450')" and "path('M 300 200 A 50 60 70 0 1 380 290')" at progress 0.125]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('M 100 400 A 10 20 30 1 0 140 450')" and "path('M 300 200 A 50 60 70 0 1 380 290')" at progress 0.875]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('M 100 400 A 10 20 30 1 0 140 450')" and "path('M 300 200 A 50 60 70 0 1 380 290')" at progress 2]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress -1]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress 0]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress 0.125]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress 0.875]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress 1]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 100 400 a 10 20 30 1 0 40 50')" and "path('m 300 200 a 50 60 70 0 1 80 90')" at progress 2]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
deleted file mode 100644
--- a/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-004.html.ini
+++ /dev/null
@@ -1,20 +0,0 @@
-[offset-path-interpolation-004.html]
-  [Animation between "path('m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50')" and "path('M 18 12 A 50 100 70 0 1 90 110 A 150 160 70 0 1 70 80')" at progress -1]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50')" and "path('M 18 12 A 50 100 70 0 1 90 110 A 150 160 70 0 1 70 80')" at progress 0]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50')" and "path('M 18 12 A 50 100 70 0 1 90 110 A 150 160 70 0 1 70 80')" at progress 0.125]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50')" and "path('M 18 12 A 50 100 70 0 1 90 110 A 150 160 70 0 1 70 80')" at progress 0.875]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928
-
-  [Animation between "path('m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50')" and "path('M 18 12 A 50 100 70 0 1 90 110 A 150 160 70 0 1 70 80')" at progress 2]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=653928