servo: Merge #19604 - bug 1424798: stylo: Correctly handle interpolation where optional second argument for translate(), skew(), scale() exists in one but not the other (from Manishearth:animate-second); r=emilio a=gchang
authorManish Goregaokar <manishearth@gmail.com>
Mon, 18 Dec 2017 20:46:31 -0600
changeset 445424 3f246dbf4bc3893b2e9bb36fc2722e194a6c4b0b
parent 445423 e3fc217044d7d8bec8d8ce316bc33d2a86b716e9
child 445425 8240bb64efb787014749a46d3a8e3781242be89e
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, gchang
bugs1424798
milestone58.0
servo: Merge #19604 - bug 1424798: stylo: Correctly handle interpolation where optional second argument for translate(), skew(), scale() exists in one but not the other (from Manishearth:animate-second); r=emilio a=gchang r=emilio https://bugzilla.mozilla.org/show_bug.cgi?id=1424798 Source-Repo: https://github.com/servo/servo Source-Revision: 861ceb10eadcd8e73c54a85336d081432813b2b1
servo/components/style/properties/helpers/animated_properties.mako.rs
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -7,16 +7,17 @@
 <% from data import to_idl_name, SYSTEM_FONT_LONGHANDS %>
 
 use cssparser::Parser;
 #[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
 #[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
 #[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
 #[cfg(feature = "gecko")] use gecko_bindings::sugar::ownership::{HasFFI, HasSimpleFFI};
 use itertools::{EitherOrBoth, Itertools};
+use num_traits::Zero;
 use properties::{CSSWideKeyword, PropertyDeclaration};
 use properties::longhands;
 use properties::longhands::font_weight::computed_value::T as FontWeight;
 use properties::longhands::font_stretch::computed_value::T as FontStretch;
 #[cfg(feature = "gecko")]
 use properties::longhands::font_variation_settings::computed_value::T as FontVariationSettings;
 use properties::longhands::visibility::computed_value::T as Visibility;
 #[cfg(feature = "gecko")]
@@ -1037,22 +1038,31 @@ impl Animate for ComputedTransformOperat
                 &TransformOperation::Matrix(ref this),
                 &TransformOperation::Matrix(ref other),
             ) => {
                 Ok(TransformOperation::Matrix(
                     this.animate(other, procedure)?,
                 ))
             },
             (
+                &TransformOperation::Skew(ref fx, None),
+                &TransformOperation::Skew(ref tx, None),
+            ) => {
+                Ok(TransformOperation::Skew(
+                    fx.animate(tx, procedure)?,
+                    None,
+                ))
+            },
+            (
                 &TransformOperation::Skew(ref fx, ref fy),
                 &TransformOperation::Skew(ref tx, ref ty),
             ) => {
                 Ok(TransformOperation::Skew(
                     fx.animate(tx, procedure)?,
-                    fy.animate(ty, procedure)?,
+                    Some(fy.unwrap_or(Angle::zero()).animate(&ty.unwrap_or(Angle::zero()), procedure)?)
                 ))
             },
             (
                 &TransformOperation::SkewX(ref f),
                 &TransformOperation::SkewX(ref t),
             ) => {
                 Ok(TransformOperation::SkewX(
                     f.animate(t, procedure)?,
@@ -1072,22 +1082,31 @@ impl Animate for ComputedTransformOperat
             ) => {
                 Ok(TransformOperation::Translate3D(
                     fx.animate(tx, procedure)?,
                     fy.animate(ty, procedure)?,
                     fz.animate(tz, procedure)?,
                 ))
             },
             (
+                &TransformOperation::Translate(ref fx, None),
+                &TransformOperation::Translate(ref tx, None),
+            ) => {
+                Ok(TransformOperation::Translate(
+                    fx.animate(tx, procedure)?,
+                    None
+                ))
+            },
+            (
                 &TransformOperation::Translate(ref fx, ref fy),
                 &TransformOperation::Translate(ref tx, ref ty),
             ) => {
                 Ok(TransformOperation::Translate(
                     fx.animate(tx, procedure)?,
-                    fy.animate(ty, procedure)?
+                    Some(fy.unwrap_or(*fx).animate(&ty.unwrap_or(*tx), procedure)?)
                 ))
             },
             (
                 &TransformOperation::TranslateX(ref f),
                 &TransformOperation::TranslateX(ref t),
             ) => {
                 Ok(TransformOperation::TranslateX(
                     f.animate(t, procedure)?
@@ -1139,16 +1158,34 @@ impl Animate for ComputedTransformOperat
                 &TransformOperation::ScaleZ(ref f),
                 &TransformOperation::ScaleZ(ref t),
             ) => {
                 Ok(TransformOperation::ScaleZ(
                     animate_multiplicative_factor(*f, *t, procedure)?
                 ))
             },
             (
+                &TransformOperation::Scale(ref f, None),
+                &TransformOperation::Scale(ref t, None),
+            ) => {
+                Ok(TransformOperation::Scale(
+                    animate_multiplicative_factor(*f, *t, procedure)?,
+                    None
+                ))
+            },
+            (
+                &TransformOperation::Scale(ref fx, ref fy),
+                &TransformOperation::Scale(ref tx, ref ty),
+            ) => {
+                Ok(TransformOperation::Scale(
+                    animate_multiplicative_factor(*fx, *tx, procedure)?,
+                    Some(animate_multiplicative_factor(fy.unwrap_or(*fx), ty.unwrap_or(*tx), procedure)?),
+                ))
+            },
+            (
                 &TransformOperation::Rotate3D(fx, fy, fz, fa),
                 &TransformOperation::Rotate3D(tx, ty, tz, ta),
             ) => {
                 let (fx, fy, fz, fa) =
                     ComputedTransform::get_normalized_vector_and_angle(fx, fy, fz, fa);
                 let (tx, ty, tz, ta) =
                     ComputedTransform::get_normalized_vector_and_angle(tx, ty, tz, ta);
                 if (fx, fy, fz) == (tx, ty, tz) {