Skip to content

Commit

Permalink
stylo: Preserve the variant of rotate() values in computed transforms
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: Dmw7P21I6FN
  • Loading branch information
Manishearth committed Sep 15, 2017
1 parent e74d04c commit 0630099
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
6 changes: 6 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -3077,6 +3077,9 @@ fn static_assert() {
${transform_function_arm("ScaleY", "scaley", ["number"])}
${transform_function_arm("ScaleZ", "scalez", ["number"])}
${transform_function_arm("Scale", "scale3d", ["number"] * 3)}
${transform_function_arm("RotateX", "rotatex", ["angle"])}
${transform_function_arm("RotateY", "rotatey", ["angle"])}
${transform_function_arm("RotateZ", "rotatez", ["angle"])}
${transform_function_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
${transform_function_arm("Perspective", "perspective", ["length"])}
${transform_function_arm("InterpolateMatrix", "interpolatematrix",
Expand Down Expand Up @@ -3204,6 +3207,9 @@ fn static_assert() {
${computed_operation_arm("ScaleY", "scaley", ["number"])}
${computed_operation_arm("ScaleZ", "scalez", ["number"])}
${computed_operation_arm("Scale", "scale3d", ["number"] * 3)}
${computed_operation_arm("RotateX", "rotatex", ["angle"])}
${computed_operation_arm("RotateY", "rotatey", ["angle"])}
${computed_operation_arm("RotateZ", "rotatez", ["angle"])}
${computed_operation_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
${computed_operation_arm("Perspective", "perspective", ["length"])}
${computed_operation_arm("InterpolateMatrix", "interpolatematrix",
Expand Down
Expand Up @@ -1163,6 +1163,9 @@ impl ToAnimatedZero for TransformOperation {
TransformOperation::ScaleX(_) => Ok(TransformOperation::ScaleX(1.)),
TransformOperation::ScaleY(_) => Ok(TransformOperation::ScaleY(1.)),
TransformOperation::ScaleZ(_) => Ok(TransformOperation::ScaleZ(1.)),
TransformOperation::RotateX(_) => Ok(TransformOperation::RotateX(Angle::zero())),
TransformOperation::RotateY(_) => Ok(TransformOperation::RotateY(Angle::zero())),
TransformOperation::RotateZ(_) => Ok(TransformOperation::RotateZ(Angle::zero())),
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 @@ -693,6 +693,9 @@ ${helpers.predefined_type(
ScaleY(CSSFloat),
ScaleZ(CSSFloat),
Scale(CSSFloat, CSSFloat, CSSFloat),
RotateX(computed::Angle),
RotateY(computed::Angle),
RotateZ(computed::Angle),
Rotate(CSSFloat, CSSFloat, CSSFloat, computed::Angle),
Perspective(computed::Length),
// For mismatched transform lists.
Expand Down Expand Up @@ -1317,15 +1320,15 @@ ${helpers.predefined_type(
}
SpecifiedOperation::RotateX(theta) => {
let theta = theta.to_computed_value(context);
result.push(computed_value::ComputedOperation::Rotate(1.0, 0.0, 0.0, theta));
result.push(computed_value::ComputedOperation::RotateX(theta));
}
SpecifiedOperation::RotateY(theta) => {
let theta = theta.to_computed_value(context);
result.push(computed_value::ComputedOperation::Rotate(0.0, 1.0, 0.0, theta));
result.push(computed_value::ComputedOperation::RotateY(theta));
}
SpecifiedOperation::RotateZ(theta) => {
let theta = theta.to_computed_value(context);
result.push(computed_value::ComputedOperation::Rotate(0.0, 0.0, 1.0, theta));
result.push(computed_value::ComputedOperation::RotateZ(theta));
}
SpecifiedOperation::Rotate3D(ax, ay, az, theta) => {
let ax = ax.to_computed_value(context);
Expand Down Expand Up @@ -1456,6 +1459,18 @@ ${helpers.predefined_type(
Number::from_computed_value(sy),
Number::from_computed_value(sz)));
}
computed_value::ComputedOperation::RotateX(ref rx) => {
result.push(SpecifiedOperation::RotateX(
ToComputedValue::from_computed_value(rx)));
}
computed_value::ComputedOperation::RotateY(ref ry) => {
result.push(SpecifiedOperation::RotateY(
ToComputedValue::from_computed_value(ry)));
}
computed_value::ComputedOperation::RotateZ(ref rz) => {
result.push(SpecifiedOperation::RotateZ(
ToComputedValue::from_computed_value(rz)));
}
computed_value::ComputedOperation::Rotate(ref ax, ref ay, ref az, ref theta) => {
result.push(SpecifiedOperation::Rotate3D(
Number::from_computed_value(ax),
Expand Down
12 changes: 12 additions & 0 deletions components/style/values/computed/transform.rs
Expand Up @@ -80,6 +80,18 @@ impl TransformList {

for operation in list {
let matrix = match *operation {
ComputedOperation::RotateX(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(1., 0., 0., theta.into())
}
ComputedOperation::RotateY(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(0., 1., 0., theta.into())
}
ComputedOperation::RotateZ(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(0., 0., 1., theta.into())
}
ComputedOperation::Rotate(ax, ay, az, theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
let (ax, ay, az, theta) =
Expand Down

0 comments on commit 0630099

Please sign in to comment.