From ae2cd2accd593948c58e15e29cdfd4f551304183 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Fri, 21 Sep 2018 18:39:41 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- .../test_distance_of_path_function.html | 3 +- .../test/test_transitions_per_property.html | 10 ++--- .../style/values/specified/svg_path.rs | 32 +++++++++++++-- .../offset-path-interpolation-002.html.ini | 40 ------------------- .../offset-path-interpolation-004.html.ini | 20 ---------- 5 files changed, 36 insertions(+), 69 deletions(-) delete mode 100644 testing/web-platform/meta/css/motion/animation/offset-path-interpolation-002.html.ini delete mode 100644 testing/web-platform/meta/css/motion/animation/offset-path-interpolation-004.html.ini diff --git a/dom/animation/test/mozilla/test_distance_of_path_function.html b/dom/animation/test/mozilla/test_distance_of_path_function.html index 30b32f76a329..af6592c89245 100644 --- a/dom/animation/test/mozilla/test_distance_of_path_function.html +++ b/dom/animation/test/mozilla/test_distance_of_path_function.html @@ -111,11 +111,12 @@ test(function(t) { 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")'); diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index c510eb4c5760..a6aa741dd785 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -835,11 +835,6 @@ const pathFunctionTests = [ 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')", @@ -886,6 +881,11 @@ const pathFunctionTests = [ 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')", diff --git a/servo/components/style/values/specified/svg_path.rs b/servo/components/style/values/specified/svg_path.rs index 5d397558d258..3f1fdc39d97d 100644 --- a/servo/components/style/values/specified/svg_path.rs +++ b/servo/components/style/values/specified/svg_path.rs @@ -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.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 { + (self.0 as i32).compute_squared_distance(&(other.0 as i32)) + } +} + +impl ToAnimatedZero for ArcFlag { + #[inline] + fn to_animated_zero(&self) -> Result { + // 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>>, diff --git a/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-002.html.ini b/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-002.html.ini deleted file mode 100644 index 21e0cea00e1d..000000000000 --- 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 diff --git a/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-004.html.ini b/testing/web-platform/meta/css/motion/animation/offset-path-interpolation-004.html.ini deleted file mode 100644 index aacc8d04b39f..000000000000 --- 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