Bug 1458715: Fix perspective interpolation. r?hiro draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 03 May 2018 10:15:15 +0200
changeset 790973 8e8f71c3f3dbdd1e24667c89e7749fa6b5a9780d
parent 790972 4ab387befcc025db977e81bdbb52a53bd10985b4
push id108657
push userbmo:emilio@crisal.io
push dateThu, 03 May 2018 08:18:33 +0000
reviewershiro
bugs1458715
milestone61.0a1
Bug 1458715: Fix perspective interpolation. r?hiro It's not sound to insert random matrices in random positions in the transform operation list. I cannot make any sense of what the old code was trying to do. MozReview-Commit-ID: 5BtCiueEPlR
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/values/computed/transform.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -1286,26 +1286,18 @@ impl Animate for ComputedTransformOperat
                 Ok(TransformOperation::Rotate(
                     fa.animate(&ta, procedure)?
                 ))
             },
             (
                 &TransformOperation::Perspective(ref fd),
                 &TransformOperation::Perspective(ref td),
             ) => {
-                let mut fd_matrix = Matrix3D::identity();
-                let mut td_matrix = Matrix3D::identity();
-                if fd.px() > 0. {
-                    fd_matrix.m34 = -1. / fd.px();
-                }
-                if td.px() > 0. {
-                    td_matrix.m34 = -1. / td.px();
-                }
-                Ok(TransformOperation::Matrix3D(
-                    fd_matrix.animate(&td_matrix, procedure)?,
+                Ok(TransformOperation::Perspective(
+                    fd.animate(td, procedure)?
                 ))
             },
             _ if self.is_translate() && other.is_translate() => {
                 self.to_translate_3d().animate(&other.to_translate_3d(), procedure)
             }
             _ if self.is_scale() && other.is_scale() => {
                 self.to_scale_3d().animate(&other.to_scale_3d(), procedure)
             }
--- a/servo/components/style/values/computed/transform.rs
+++ b/servo/components/style/values/computed/transform.rs
@@ -246,21 +246,21 @@ impl ToAnimatedZero for TransformOperati
                 Ok(generic::TransformOperation::RotateY(Angle::zero()))
             },
             generic::TransformOperation::RotateZ(_) => {
                 Ok(generic::TransformOperation::RotateZ(Angle::zero()))
             },
             generic::TransformOperation::Rotate(_) => {
                 Ok(generic::TransformOperation::Rotate(Angle::zero()))
             },
-            generic::TransformOperation::Perspective(..) |
+            generic::TransformOperation::Perspective(ref l) => {
+                Ok(generic::TransformOperation::Perspective(l.to_animated_zero()?))
+            },
             generic::TransformOperation::AccumulateMatrix { .. } |
             generic::TransformOperation::InterpolateMatrix { .. } => {
-                // Perspective: We convert a perspective function into an equivalent
-                //     ComputedMatrix, and then decompose/interpolate/recompose these matrices.
                 // AccumulateMatrix/InterpolateMatrix: We do interpolation on
                 //     AccumulateMatrix/InterpolateMatrix by reading it as a ComputedMatrix
                 //     (with layout information), and then do matrix interpolation.
                 //
                 // Therefore, we use an identity matrix to represent the identity transform list.
                 // http://dev.w3.org/csswg/css-transforms/#identity-transform-function
                 Ok(generic::TransformOperation::Matrix3D(Matrix3D::identity()))
             },