Bug 1391145 - stylo: Preserve the variant of scale() values in computed transforms ; r?hiro draft
authorManish Goregaokar <manishearth@gmail.com>
Mon, 18 Sep 2017 17:11:35 -0700
changeset 667199 b1b77889c1ffd3157986487861d2422becca854c
parent 667198 5f4d6b516bdeddd5ff52e71f83f882a4f1bd2c95
child 667200 39a0d5d56ad0f3f9ae63973f3e5bcbc1f0f0b7fb
push id80648
push userbmo:manishearth@gmail.com
push dateTue, 19 Sep 2017 20:49:18 +0000
reviewershiro
bugs1391145
milestone57.0a1
Bug 1391145 - stylo: Preserve the variant of scale() values in computed transforms ; r?hiro MozReview-Commit-ID: FjSQH9DyCOe
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/helpers/animated_properties.mako.rs
servo/components/style/properties/longhand/box.mako.rs
servo/components/style/values/computed/transform.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -2984,16 +2984,19 @@ fn static_assert() {
                 ${transform_function_arm("Matrix", "matrix3d", ["number"] * 16)}
                 ${transform_function_arm("MatrixWithPercents", "matrix3d", ["number"] * 12 + ["lop"] * 2
                                          + ["length"] + ["number"])}
                 ${transform_function_arm("Skew", "skew", ["angle"] * 2)}
                 ${transform_function_arm("TranslateX", "translatex", ["lop"])}
                 ${transform_function_arm("TranslateY", "translatey", ["lop"])}
                 ${transform_function_arm("TranslateZ", "translatez", ["length"])}
                 ${transform_function_arm("Translate", "translate3d", ["lop", "lop", "length"])}
+                ${transform_function_arm("ScaleX", "scalex", ["number"])}
+                ${transform_function_arm("ScaleY", "scaley", ["number"])}
+                ${transform_function_arm("ScaleZ", "scalez", ["number"])}
                 ${transform_function_arm("Scale", "scale3d", ["number"] * 3)}
                 ${transform_function_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
                 ${transform_function_arm("Perspective", "perspective", ["length"])}
                 ${transform_function_arm("InterpolateMatrix", "interpolatematrix",
                                          ["list"] * 2 + ["percentage"])}
                 ${transform_function_arm("AccumulateMatrix", "accumulatematrix",
                                          ["list"] * 2 + ["integer_to_percentage"])}
             }
@@ -3108,16 +3111,19 @@ fn static_assert() {
             match transform_function {
                 ${computed_operation_arm("Matrix", "matrix3d", ["number"] * 16)}
                 ${computed_operation_arm("Skew", "skew", ["angle"] * 2)}
 
                 ${computed_operation_arm("TranslateX", "translatex", ["lop"])}
                 ${computed_operation_arm("TranslateY", "translatey", ["lop"])}
                 ${computed_operation_arm("TranslateZ", "translatez", ["length"])}
                 ${computed_operation_arm("Translate", "translate3d", ["lop", "lop", "length"])}
+                ${computed_operation_arm("ScaleX", "scalex", ["number"])}
+                ${computed_operation_arm("ScaleY", "scaley", ["number"])}
+                ${computed_operation_arm("ScaleZ", "scalez", ["number"])}
                 ${computed_operation_arm("Scale", "scale3d", ["number"] * 3)}
                 ${computed_operation_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
                 ${computed_operation_arm("Perspective", "perspective", ["length"])}
                 ${computed_operation_arm("InterpolateMatrix", "interpolatematrix",
                                          ["list"] * 2 + ["percentage"])}
                 ${computed_operation_arm("AccumulateMatrix", "accumulatematrix",
                                          ["list"] * 2 + ["percentage_to_integer"])}
                 _ => panic!("We shouldn't set any other transform function types"),
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -1193,16 +1193,19 @@ impl ToAnimatedZero for TransformOperati
                     tx.to_animated_zero()?,
                     ty.to_animated_zero()?,
                     tz.to_animated_zero()?,
                 ))
             },
             TransformOperation::Scale(..) => {
                 Ok(TransformOperation::Scale(1.0, 1.0, 1.0))
             },
+            TransformOperation::ScaleX(_) => Ok(TransformOperation::ScaleX(1.)),
+            TransformOperation::ScaleY(_) => Ok(TransformOperation::ScaleY(1.)),
+            TransformOperation::ScaleZ(_) => Ok(TransformOperation::ScaleZ(1.)),
             TransformOperation::Rotate(x, y, z, a) => {
                 let (x, y, z, _) = TransformList::get_normalized_vector_and_angle(x, y, z, a);
                 Ok(TransformOperation::Rotate(x, y, z, Angle::zero()))
             },
             TransformOperation::Perspective(..) |
             TransformOperation::AccumulateMatrix { .. } |
             TransformOperation::InterpolateMatrix { .. } => {
                 // Perspective: We convert a perspective function into an equivalent
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -715,16 +715,19 @@
             MatrixWithPercents(ComputedMatrixWithPercents),
             Skew(computed::Angle, computed::Angle),
             TranslateX(LengthOrPercentage),
             TranslateY(LengthOrPercentage),
             TranslateZ(Length),
             Translate(computed::LengthOrPercentage,
                       computed::LengthOrPercentage,
                       computed::Length),
+            ScaleX(CSSFloat),
+            ScaleY(CSSFloat),
+            ScaleZ(CSSFloat),
             Scale(CSSFloat, CSSFloat, CSSFloat),
             Rotate(CSSFloat, CSSFloat, CSSFloat, computed::Angle),
             Perspective(computed::Length),
             // For mismatched transform lists.
             // A vector of |ComputedOperation| could contain an |InterpolateMatrix| and other
             // |ComputedOperation|s, and multiple nested |InterpolateMatrix|s is acceptable.
             // e.g.
             // [ InterpolateMatrix { from_list: [ InterpolateMatrix { ... },
@@ -1321,25 +1324,25 @@
                     }
                     SpecifiedOperation::Scale(sx, Some(sy)) => {
                         let sx = sx.to_computed_value(context);
                         let sy = sy.to_computed_value(context);
                         result.push(computed_value::ComputedOperation::Scale(sx, sy, 1.0));
                     }
                     SpecifiedOperation::ScaleX(sx) => {
                         let sx = sx.to_computed_value(context);
-                        result.push(computed_value::ComputedOperation::Scale(sx, 1.0, 1.0));
+                        result.push(computed_value::ComputedOperation::ScaleX(sx));
                     }
                     SpecifiedOperation::ScaleY(sy) => {
                         let sy = sy.to_computed_value(context);
-                        result.push(computed_value::ComputedOperation::Scale(1.0, sy, 1.0));
+                        result.push(computed_value::ComputedOperation::ScaleY(sy));
                     }
                     SpecifiedOperation::ScaleZ(sz) => {
                         let sz = sz.to_computed_value(context);
-                        result.push(computed_value::ComputedOperation::Scale(1.0, 1.0, sz));
+                        result.push(computed_value::ComputedOperation::ScaleZ(sz));
                     }
                     SpecifiedOperation::Scale3D(sx, sy, sz) => {
                         let sx = sx.to_computed_value(context);
                         let sy = sy.to_computed_value(context);
                         let sz = sz.to_computed_value(context);
                         result.push(computed_value::ComputedOperation::Scale(sx, sy, sz));
                     }
                     SpecifiedOperation::Rotate(theta) => {
@@ -1464,16 +1467,28 @@
                                               ToComputedValue::from_computed_value(tz)));
                         }
                         computed_value::ComputedOperation::Translate(ref tx, ref ty, ref tz) => {
                             result.push(SpecifiedOperation::Translate3D(
                                               ToComputedValue::from_computed_value(tx),
                                               ToComputedValue::from_computed_value(ty),
                                               ToComputedValue::from_computed_value(tz)));
                         }
+                        computed_value::ComputedOperation::ScaleX(ref sx) => {
+                            result.push(SpecifiedOperation::ScaleX(
+                                              ToComputedValue::from_computed_value(sx)));
+                        }
+                        computed_value::ComputedOperation::ScaleY(ref sy) => {
+                            result.push(SpecifiedOperation::ScaleY(
+                                              ToComputedValue::from_computed_value(sy)));
+                        }
+                        computed_value::ComputedOperation::ScaleZ(ref sz) => {
+                            result.push(SpecifiedOperation::ScaleZ(
+                                              ToComputedValue::from_computed_value(sz)));
+                        }
                         computed_value::ComputedOperation::Scale(ref sx, ref sy, ref sz) => {
                             result.push(SpecifiedOperation::Scale3D(
                                     Number::from_computed_value(sx),
                                     Number::from_computed_value(sy),
                                     Number::from_computed_value(sz)));
                         }
                         computed_value::ComputedOperation::Rotate(ref ax, ref ay, ref az, ref theta) => {
                             result.push(SpecifiedOperation::Rotate3D(
--- a/servo/components/style/values/computed/transform.rs
+++ b/servo/components/style/values/computed/transform.rs
@@ -84,16 +84,25 @@ impl TransformList {
                     let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
                     let (ax, ay, az, theta) =
                         Self::get_normalized_vector_and_angle(ax, ay, az, theta);
                     Transform3D::create_rotation(ax, ay, az, theta.into())
                 }
                 ComputedOperation::Perspective(d) => {
                     Self::create_perspective_matrix(d.px())
                 }
+                ComputedOperation::ScaleX(sx) => {
+                    Transform3D::create_scale(sx, 1., 1.)
+                }
+                ComputedOperation::ScaleY(sy) => {
+                    Transform3D::create_scale(1., sy, 1.)
+                }
+                ComputedOperation::ScaleZ(sz) => {
+                    Transform3D::create_scale(1., 1., sz)
+                }
                 ComputedOperation::Scale(sx, sy, sz) => {
                     Transform3D::create_scale(sx, sy, sz)
                 }
                 ComputedOperation::TranslateX(tx) => {
                     let tx =  match reference_box {
                         Some(relative_border_box) => tx.to_used_value(relative_border_box.size.width).to_f32_px(),
                         None => extract_pixel_length(&tx),
                     };