Bug 1506746 - Update the expected direction vector of rotate property in wpt. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 18 Nov 2019 20:47:01 +0000
changeset 502507 3c5118f00c7caf321cfbee83e3abe5aa9b75e80c
parent 502506 dfb29951d8b0be208d83f5c3e81b5cff84549cc6
child 502508 3779e7b766fd91688914046f1efee1a3812f69b0
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1506746
milestone72.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 1506746 - Update the expected direction vector of rotate property in wpt. r=birtles For interpolations with the primitive rotate3d(), the direction vectors of the transform functions get normalized first. This should also be applied to rotate property. https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions Differential Revision: https://phabricator.services.mozilla.com/D52944
servo/components/style/values/animated/transform.rs
testing/web-platform/meta/css/css-transforms/animation/rotate-interpolation.html.ini
testing/web-platform/tests/css/css-transforms/animation/rotate-interpolation.html
--- a/servo/components/style/values/animated/transform.rs
+++ b/servo/components/style/values/animated/transform.rs
@@ -1244,26 +1244,31 @@ impl ComputedRotate {
 }
 
 impl Animate for ComputedRotate {
     #[inline]
     fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
         match (self, other) {
             (&Rotate::None, &Rotate::None) => Ok(Rotate::None),
             (&Rotate::Rotate3D(fx, fy, fz, fa), &Rotate::None) => {
-                // No need to normalize `none`, so animate angle directly.
+                // We always normalize direction vector for rotate3d() first, so we should also
+                // apply the same rule for rotate property. In other words, we promote none into
+                // a 3d rotate, and normalize both direction vector first, and then do
+                // interpolation.
+                let (fx, fy, fz, fa) = transform::get_normalized_vector_and_angle(fx, fy, fz, fa);
                 Ok(Rotate::Rotate3D(
                     fx,
                     fy,
                     fz,
                     fa.animate(&Angle::zero(), procedure)?,
                 ))
             }
             (&Rotate::None, &Rotate::Rotate3D(tx, ty, tz, ta)) => {
-                // No need to normalize `none`, so animate angle directly.
+                // Normalize direction vector first.
+                let (tx, ty, tz, ta) = transform::get_normalized_vector_and_angle(tx, ty, tz, ta);
                 Ok(Rotate::Rotate3D(
                     tx,
                     ty,
                     tz,
                     Angle::zero().animate(&ta, procedure)?,
                 ))
             }
             (&Rotate::Rotate3D(_, ..), _) | (_, &Rotate::Rotate3D(_, ..)) => {
--- a/testing/web-platform/meta/css/css-transforms/animation/rotate-interpolation.html.ini
+++ b/testing/web-platform/meta/css/css-transforms/animation/rotate-interpolation.html.ini
@@ -1,81 +1,9 @@
 [rotate-interpolation.html]
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.75) should be [1 -2.5 3.64 -50deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (-1) should be [1 -2.5 3.64 300deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.25) should be [1 -2.5 3.64 50deg\]]
-    expected: FAIL
-
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0) should be [1 -2.5 3.64 100deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0) should be [1 -2.5 3.64 100deg\]]
-    expected: FAIL
-
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (2) should be [1 -2.5 3.64 -300deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (-1) should be [1 -2.5 3.64 300deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (1) should be [1 -2.5 3.64 -100deg\]]
-    expected: FAIL
-
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.25) should be [1 -2.5 3.64 50deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (2) should be [1 -2.5 3.64 -300deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (1) should be [1 -2.5 3.64 -100deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.25) should be [1 -2.5 3.64 50deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (-1) should be [1 -2.5 3.64 300deg\]]
-    expected: FAIL
-
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (-1) should be [1 -2.5 3.64 300deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.75) should be [1 -2.5 3.64 -50deg\]]
-    expected: FAIL
-
-  [CSS Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (1) should be [1 -2.5 3.64 -100deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0) should be [1 -2.5 3.64 100deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0) should be [1 -2.5 3.64 100deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.75) should be [1 -2.5 3.64 -50deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.25) should be [1 -2.5 3.64 50deg\]]
-    expected: FAIL
-
-  [Web Animations: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (0.75) should be [1 -2.5 3.64 -50deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (1) should be [1 -2.5 3.64 -100deg\]]
-    expected: FAIL
-
-  [CSS Transitions: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (2) should be [1 -2.5 3.64 -300deg\]]
-    expected: FAIL
-
-  [CSS Transitions with transition: all: property <rotate> from [1 -2.5 3.64 100deg\] to [1 -2.5 3.64 -100deg\] at (2) should be [1 -2.5 3.64 -300deg\]]
-    expected: FAIL
-
   [CSS Animations: property <rotate> from [1 1 0 90deg\] to [0 1 1 135deg\] at (2) should be [0.52 -0.29 -0.81 151.04deg\]]
     expected: FAIL
 
   [CSS Transitions with transition: all: property <rotate> from [1 1 0 90deg\] to [0 1 1 135deg\] at (2) should be [0.52 -0.29 -0.81 151.04deg\]]
     expected: FAIL
 
   [CSS Transitions: property <rotate> from [1 1 0 90deg\] to [0 1 1 135deg\] at (2) should be [0.52 -0.29 -0.81 151.04deg\]]
     expected: FAIL
--- a/testing/web-platform/tests/css/css-transforms/animation/rotate-interpolation.html
+++ b/testing/web-platform/tests/css/css-transforms/animation/rotate-interpolation.html
@@ -62,22 +62,22 @@ test_interpolation({
   {at: 2, expect: '-0.637897 0.637897 -0.431479 124.975deg'}
 ]);
 
 test_interpolation({
   property: 'rotate',
   from: 'none',
   to: '7 -8 9 400grad',
 }, [
-  {at: -1, expect: '7 -8 9 -400grad'},
-  {at: 0, expect: '7 -8 9 0deg'},
-  {at: 0.125, expect: '7 -8 9 50grad'},
-  {at: 0.875, expect: '7 -8 9 350grad'},
-  {at: 1, expect: '7 -8 9 400grad'},
-  {at: 2, expect: '7 -8 9 800grad'}
+  {at: -1, expect: '0.5 -0.57 0.65 -400grad'},
+  {at: 0, expect: '0.5 -0.57 0.65 0deg'},
+  {at: 0.125, expect: '0.5 -0.57 0.65 50grad'},
+  {at: 0.875, expect: '0.5 -0.57 0.65 350grad'},
+  {at: 1, expect: '0.5 -0.57 0.65 400grad'},
+  {at: 2, expect: '0.5 -0.57 0.65 800grad'}
 ]);
 
 test_interpolation({
   property: 'rotate',
   from: 'none',
   to: 'none',
 }, [
   {at: -1, expect: 'none'},
@@ -166,22 +166,22 @@ test_interpolation({
   {at: 2, expect: '0 1 0 -300deg'},
 ]);
 
 test_interpolation({
   property: 'rotate',
   from: '1 -2.5 3.64 100deg',
   to: '1 -2.5 3.64 -100deg',
 }, [
-  {at: -1, expect: '1 -2.5 3.64 300deg'},
-  {at: 0, expect: '1 -2.5 3.64 100deg'},
-  {at: 0.25, expect: '1 -2.5 3.64 50deg'},
-  {at: 0.75, expect: '1 -2.5 3.64 -50deg'},
-  {at: 1, expect: '1 -2.5 3.64 -100deg'},
-  {at: 2, expect: '1 -2.5 3.64 -300deg'},
+  {at: -1, expect: '0.22 -0.55 0.8 300deg'},
+  {at: 0, expect: '0.22 -0.55 0.8 100deg'},
+  {at: 0.25, expect: '0.22 -0.55 0.8 50deg'},
+  {at: 0.75, expect: '0.22 -0.55 0.8 -50deg'},
+  {at: 1, expect: '0.22 -0.55 0.8 -100deg'},
+  {at: 2, expect: '0.22 -0.55 0.8 -300deg'},
 ]);
 
 // The rotation angle gets interpolated numerically and the rotation vector
 // of the non-zero angle is used or (0, 0, 1) if both angles are zero.
 // So, we have to convert "1 0 0 0deg" into "0 1 0 0deg", and apply the same
 // concept for other test cases.
 // https://drafts.csswg.org/css-transforms-2/#interpolation-of-transform-functions
 test_interpolation({