Skip to content

Commit

Permalink
stylo: Preserve the variant of scale() values in computed transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 15, 2017
1 parent 83e3394 commit e74d04c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -3073,6 +3073,9 @@ fn static_assert() {
${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"])}
Expand Down Expand Up @@ -3197,6 +3200,9 @@ fn static_assert() {
${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"])}
Expand Down
Expand Up @@ -1160,6 +1160,9 @@ impl ToAnimatedZero for TransformOperation {
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()))
Expand Down
21 changes: 18 additions & 3 deletions components/style/properties/longhand/box.mako.rs
Expand Up @@ -689,6 +689,9 @@ ${helpers.predefined_type(
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),
Expand Down Expand Up @@ -1292,15 +1295,15 @@ ${helpers.predefined_type(
}
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);
Expand Down Expand Up @@ -1435,6 +1438,18 @@ ${helpers.predefined_type(
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),
Expand Down
9 changes: 9 additions & 0 deletions components/style/values/computed/transform.rs
Expand Up @@ -89,6 +89,15 @@ impl TransformList {
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)
}
Expand Down

0 comments on commit e74d04c

Please sign in to comment.