mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Minor clean-up to transform interpolation code
Differential Revision: https://phabricator.services.mozilla.com/D167616
This commit is contained in:
parent
fffb3c0830
commit
863716a0a1
1 changed files with 15 additions and 23 deletions
|
@ -257,22 +257,18 @@ impl Animate for Matrix {
|
||||||
let other = Matrix3D::from(*other);
|
let other = Matrix3D::from(*other);
|
||||||
let this = MatrixDecomposed2D::from(this);
|
let this = MatrixDecomposed2D::from(this);
|
||||||
let other = MatrixDecomposed2D::from(other);
|
let other = MatrixDecomposed2D::from(other);
|
||||||
Ok(Matrix3D::from(this.animate(&other, procedure)?).into_2d()?)
|
Matrix3D::from(this.animate(&other, procedure)?).into_2d()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
// Gecko doesn't exactly follow the spec here; we use a different procedure
|
// Gecko doesn't exactly follow the spec here; we use a different procedure
|
||||||
// to match it
|
// to match it
|
||||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
let from = decompose_2d_matrix(&(*self).into());
|
let this = Matrix3D::from(*self);
|
||||||
let to = decompose_2d_matrix(&(*other).into());
|
let other = Matrix3D::from(*other);
|
||||||
match (from, to) {
|
let from = decompose_2d_matrix(&this)?;
|
||||||
(Ok(from), Ok(to)) => Matrix3D::from(from.animate(&to, procedure)?).into_2d(),
|
let to = decompose_2d_matrix(&other)?;
|
||||||
// Matrices can be undecomposable due to couple reasons, e.g.,
|
Matrix3D::from(from.animate(&to, procedure)?).into_2d()
|
||||||
// non-invertible matrices. In this case, we should report Err here,
|
|
||||||
// and let the caller do the fallback procedure.
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,17 +776,14 @@ impl Animate for Matrix3D {
|
||||||
// to match it
|
// to match it
|
||||||
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
let (from, to) = if self.is_3d() || other.is_3d() {
|
let (from, to) = if self.is_3d() || other.is_3d() {
|
||||||
(decompose_3d_matrix(*self), decompose_3d_matrix(*other))
|
(decompose_3d_matrix(*self)?, decompose_3d_matrix(*other)?)
|
||||||
} else {
|
} else {
|
||||||
(decompose_2d_matrix(self), decompose_2d_matrix(other))
|
(decompose_2d_matrix(self)?, decompose_2d_matrix(other)?)
|
||||||
};
|
};
|
||||||
match (from, to) {
|
// Matrices can be undecomposable due to couple reasons, e.g.,
|
||||||
(Ok(from), Ok(to)) => Ok(Matrix3D::from(from.animate(&to, procedure)?)),
|
// non-invertible matrices. In this case, we should report Err here,
|
||||||
// Matrices can be undecomposable due to couple reasons, e.g.,
|
// and let the caller do the fallback procedure.
|
||||||
// non-invertible matrices. In this case, we should report Err here,
|
Ok(Matrix3D::from(from.animate(&to, procedure)?))
|
||||||
// and let the caller do the fallback procedure.
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,10 +1117,9 @@ impl ComputedTransformOperation {
|
||||||
) -> Result<Self, ()> {
|
) -> Result<Self, ()> {
|
||||||
let (left, _left_3d) = Transform::components_to_transform_3d_matrix(left, None)?;
|
let (left, _left_3d) = Transform::components_to_transform_3d_matrix(left, None)?;
|
||||||
let (right, _right_3d) = Transform::components_to_transform_3d_matrix(right, None)?;
|
let (right, _right_3d) = Transform::components_to_transform_3d_matrix(right, None)?;
|
||||||
ComputedTransformOperation::Matrix3D(left.into()).animate(
|
Ok(Self::Matrix3D(
|
||||||
&ComputedTransformOperation::Matrix3D(right.into()),
|
Matrix3D::from(left).animate(&Matrix3D::from(right), procedure)?,
|
||||||
procedure,
|
))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn animate_mismatched_transforms(
|
fn animate_mismatched_transforms(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue