stylo: Preserve the variant of rotate() values in computed transforms

MozReview-Commit-ID: Dmw7P21I6FN
This commit is contained in:
Manish Goregaokar 2017-09-11 17:16:07 -07:00 committed by Manish Goregaokar
parent e74d04c040
commit 06300999e9
4 changed files with 39 additions and 3 deletions

View file

@ -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",
@ -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",

View file

@ -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()))

View file

@ -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.
@ -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);
@ -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),

View file

@ -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) =