Bug 1391145 - stylo: Fix TransformOperation.animate() implementation ; r?hiro draft
authorManish Goregaokar <manishearth@gmail.com>
Mon, 18 Sep 2017 17:12:40 -0700
changeset 667201 b312140f85e378381a50b4825a2ea404410706f6
parent 667200 39a0d5d56ad0f3f9ae63973f3e5bcbc1f0f0b7fb
child 732327 2eaa827b022ec5b75a8937ac334f57426f012cfc
push id80648
push userbmo:manishearth@gmail.com
push dateTue, 19 Sep 2017 20:49:18 +0000
reviewershiro
bugs1391145
milestone57.0a1
Bug 1391145 - stylo: Fix TransformOperation.animate() implementation ; r?hiro MozReview-Commit-ID: FJZroAPORMf
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
@@ -1264,26 +1264,92 @@ impl Animate for TransformOperation {
             ) => {
                 Ok(TransformOperation::Translate(
                     fx.animate(tx, procedure)?,
                     fy.animate(ty, procedure)?,
                     fz.animate(tz, procedure)?,
                 ))
             },
             (
+                &TransformOperation::TranslateX(ref from),
+                &TransformOperation::TranslateX(ref to),
+            ) => {
+                Ok(TransformOperation::TranslateX(
+                    from.animate(to, procedure)?,
+                ))
+            },
+            (
+                &TransformOperation::TranslateY(ref from),
+                &TransformOperation::TranslateY(ref to),
+            ) => {
+                Ok(TransformOperation::TranslateY(
+                    from.animate(to, procedure)?,
+                ))
+            },
+            (
+                &TransformOperation::TranslateZ(ref from),
+                &TransformOperation::TranslateZ(ref to),
+            ) => {
+                Ok(TransformOperation::TranslateZ(
+                    from.animate(to, procedure)?,
+                ))
+            },
+            (
                 &TransformOperation::Scale(ref fx, ref fy, ref fz),
                 &TransformOperation::Scale(ref tx, ref ty, ref tz),
             ) => {
                 Ok(TransformOperation::Scale(
                     animate_multiplicative_factor(*fx, *tx, procedure)?,
                     animate_multiplicative_factor(*fy, *ty, procedure)?,
                     animate_multiplicative_factor(*fz, *tz, procedure)?,
                 ))
             },
             (
+                &TransformOperation::ScaleX(ref from),
+                &TransformOperation::ScaleX(ref to),
+            ) => {
+                Ok(TransformOperation::ScaleX(
+                    animate_multiplicative_factor(*from, *to, procedure)?,
+                ))
+            },
+            (
+                &TransformOperation::ScaleY(ref from),
+                &TransformOperation::ScaleY(ref to),
+            ) => {
+                Ok(TransformOperation::ScaleY(
+                    animate_multiplicative_factor(*from, *to, procedure)?,
+                ))
+            },
+            (
+                &TransformOperation::ScaleZ(ref from),
+                &TransformOperation::ScaleZ(ref to),
+            ) => {
+                Ok(TransformOperation::ScaleZ(
+                    animate_multiplicative_factor(*from, *to, procedure)?,
+                ))
+            },
+            (
+                &TransformOperation::RotateX(ref from),
+                &TransformOperation::RotateX(ref to),
+            ) => {
+                Ok(TransformOperation::RotateX(from.animate(to, procedure)?))
+            },
+            (
+                &TransformOperation::RotateY(ref from),
+                &TransformOperation::RotateY(ref to),
+            ) => {
+                Ok(TransformOperation::RotateY(from.animate(to, procedure)?))
+            },
+            (
+                &TransformOperation::RotateZ(ref from),
+                &TransformOperation::RotateZ(ref to),
+            ) => {
+                Ok(TransformOperation::RotateZ(from.animate(to, procedure)?))
+            },
+            (
                 &TransformOperation::Rotate(fx, fy, fz, fa),
                 &TransformOperation::Rotate(tx, ty, tz, ta),
             ) => {
                 let (fx, fy, fz, fa) =
                     TransformList::get_normalized_vector_and_angle(fx, fy, fz, fa);
                 let (tx, ty, tz, ta) =
                     TransformList::get_normalized_vector_and_angle(tx, ty, tz, ta);
                 if (fx, fy, fz) == (tx, ty, tz) {
--- a/servo/components/style/values/computed/transform.rs
+++ b/servo/components/style/values/computed/transform.rs
@@ -123,17 +123,17 @@ impl TransformList {
                 ComputedOperation::TranslateY(ty) => {
                     let ty =  match reference_box {
                         Some(relative_border_box) => ty.to_used_value(relative_border_box.size.height).to_f32_px(),
                         None => extract_pixel_length(&ty),
                     };
                     Transform3D::create_translation(0., ty, 0.)
                 }
                 ComputedOperation::TranslateZ(tz) => {
-                    Transform3D::create_translation(0., 0., tz.to_f32_px())
+                    Transform3D::create_translation(0., 0., tz.px())
                 }
                 ComputedOperation::Translate(tx, ty, tz) => {
                     let (tx, ty) = match reference_box {
                         Some(relative_border_box) => {
                             (tx.to_pixel_length(relative_border_box.size.width).px(),
                              ty.to_pixel_length(relative_border_box.size.height).px())
                         },
                         None => {