Bug 1458715: Fix perspective interpolation. r?hiro
It's not sound to insert random matrices in random positions in the transform
operation list.
I cannot make any sense of what the old code was trying to do.
MozReview-Commit-ID: 5BtCiueEPlR
--- a/servo/components/style/properties/helpers/animated_properties.mako.rs
+++ b/servo/components/style/properties/helpers/animated_properties.mako.rs
@@ -1286,26 +1286,18 @@ impl Animate for ComputedTransformOperat
Ok(TransformOperation::Rotate(
fa.animate(&ta, procedure)?
))
},
(
&TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td),
) => {
- let mut fd_matrix = Matrix3D::identity();
- let mut td_matrix = Matrix3D::identity();
- if fd.px() > 0. {
- fd_matrix.m34 = -1. / fd.px();
- }
- if td.px() > 0. {
- td_matrix.m34 = -1. / td.px();
- }
- Ok(TransformOperation::Matrix3D(
- fd_matrix.animate(&td_matrix, procedure)?,
+ Ok(TransformOperation::Perspective(
+ fd.animate(td, procedure)?
))
},
_ if self.is_translate() && other.is_translate() => {
self.to_translate_3d().animate(&other.to_translate_3d(), procedure)
}
_ if self.is_scale() && other.is_scale() => {
self.to_scale_3d().animate(&other.to_scale_3d(), procedure)
}
--- a/servo/components/style/values/computed/transform.rs
+++ b/servo/components/style/values/computed/transform.rs
@@ -246,21 +246,21 @@ impl ToAnimatedZero for TransformOperati
Ok(generic::TransformOperation::RotateY(Angle::zero()))
},
generic::TransformOperation::RotateZ(_) => {
Ok(generic::TransformOperation::RotateZ(Angle::zero()))
},
generic::TransformOperation::Rotate(_) => {
Ok(generic::TransformOperation::Rotate(Angle::zero()))
},
- generic::TransformOperation::Perspective(..) |
+ generic::TransformOperation::Perspective(ref l) => {
+ Ok(generic::TransformOperation::Perspective(l.to_animated_zero()?))
+ },
generic::TransformOperation::AccumulateMatrix { .. } |
generic::TransformOperation::InterpolateMatrix { .. } => {
- // Perspective: We convert a perspective function into an equivalent
- // ComputedMatrix, and then decompose/interpolate/recompose these matrices.
// AccumulateMatrix/InterpolateMatrix: We do interpolation on
// AccumulateMatrix/InterpolateMatrix by reading it as a ComputedMatrix
// (with layout information), and then do matrix interpolation.
//
// Therefore, we use an identity matrix to represent the identity transform list.
// http://dev.w3.org/csswg/css-transforms/#identity-transform-function
Ok(generic::TransformOperation::Matrix3D(Matrix3D::identity()))
},