mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Match rotate ops.
Per bug 1322189 we really should. I've copied the setup we have already for translate / scale, but we should really clean this up a bit more I'd think. In any case, probably skew should be matched as well... Bug: 1464615 Reviewed-by: hiro MozReview-Commit-ID: Jky5k8HVfuH
This commit is contained in:
parent
01f805af9f
commit
2e500d70ef
3 changed files with 46 additions and 1 deletions
|
@ -1289,7 +1289,11 @@ impl Animate for ComputedTransformOperation {
|
||||||
) => {
|
) => {
|
||||||
Ok(TransformOperation::Scale(
|
Ok(TransformOperation::Scale(
|
||||||
animate_multiplicative_factor(*fx, *tx, procedure)?,
|
animate_multiplicative_factor(*fx, *tx, procedure)?,
|
||||||
Some(animate_multiplicative_factor(fy.unwrap_or(*fx), ty.unwrap_or(*tx), procedure)?),
|
Some(animate_multiplicative_factor(
|
||||||
|
fy.unwrap_or(*fx),
|
||||||
|
ty.unwrap_or(*tx),
|
||||||
|
procedure
|
||||||
|
)?),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
|
@ -1371,6 +1375,9 @@ impl Animate for ComputedTransformOperation {
|
||||||
_ if self.is_scale() && other.is_scale() => {
|
_ if self.is_scale() && other.is_scale() => {
|
||||||
self.to_scale_3d().animate(&other.to_scale_3d(), procedure)
|
self.to_scale_3d().animate(&other.to_scale_3d(), procedure)
|
||||||
}
|
}
|
||||||
|
_ if self.is_rotate() && other.is_rotate() => {
|
||||||
|
self.to_rotate_3d().animate(&other.to_rotate_3d(), procedure)
|
||||||
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1403,6 +1410,7 @@ fn is_matched_operation(first: &ComputedTransformOperation, second: &ComputedTra
|
||||||
// we animate scale and translate operations against each other
|
// we animate scale and translate operations against each other
|
||||||
(a, b) if a.is_translate() && b.is_translate() => true,
|
(a, b) if a.is_translate() && b.is_translate() => true,
|
||||||
(a, b) if a.is_scale() && b.is_scale() => true,
|
(a, b) if a.is_scale() && b.is_scale() => true,
|
||||||
|
(a, b) if a.is_rotate() && b.is_rotate() => true,
|
||||||
// InterpolateMatrix and AccumulateMatrix are for mismatched transform.
|
// InterpolateMatrix and AccumulateMatrix are for mismatched transform.
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
@ -2734,6 +2742,9 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
|
||||||
_ if self.is_scale() && other.is_scale() => {
|
_ if self.is_scale() && other.is_scale() => {
|
||||||
self.to_scale_3d().compute_squared_distance(&other.to_scale_3d())
|
self.to_scale_3d().compute_squared_distance(&other.to_scale_3d())
|
||||||
}
|
}
|
||||||
|
_ if self.is_rotate() && other.is_rotate() => {
|
||||||
|
self.to_rotate_3d().compute_squared_distance(&other.to_rotate_3d())
|
||||||
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,27 @@ impl TransformOperation {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert to a Rotate3D.
|
||||||
|
///
|
||||||
|
/// Must be called on a Rotate function.
|
||||||
|
pub fn to_rotate_3d(&self) -> Self {
|
||||||
|
match *self {
|
||||||
|
generic::TransformOperation::Rotate3D(..) => self.clone(),
|
||||||
|
generic::TransformOperation::RotateZ(ref angle) |
|
||||||
|
generic::TransformOperation::Rotate(ref angle) => {
|
||||||
|
generic::TransformOperation::Rotate3D(0., 0., 1., angle.clone())
|
||||||
|
}
|
||||||
|
generic::TransformOperation::RotateX(ref angle) => {
|
||||||
|
generic::TransformOperation::Rotate3D(1., 0., 0., angle.clone())
|
||||||
|
}
|
||||||
|
generic::TransformOperation::RotateY(ref angle) => {
|
||||||
|
generic::TransformOperation::Rotate3D(0., 1., 0., angle.clone())
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert to a Scale3D.
|
/// Convert to a Scale3D.
|
||||||
///
|
///
|
||||||
/// Must be called on a Scale function
|
/// Must be called on a Scale function
|
||||||
|
|
|
@ -276,6 +276,19 @@ pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>);
|
||||||
impl<Angle, Number, Length, Integer, LengthOrPercentage>
|
impl<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||||
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||||
{
|
{
|
||||||
|
/// Check if it is any rotate function.
|
||||||
|
pub fn is_rotate(&self) -> bool {
|
||||||
|
use self::TransformOperation::*;
|
||||||
|
matches!(
|
||||||
|
*self,
|
||||||
|
Rotate(..) |
|
||||||
|
Rotate3D(..) |
|
||||||
|
RotateX(..) |
|
||||||
|
RotateY(..) |
|
||||||
|
RotateZ(..)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if it is any translate function
|
/// Check if it is any translate function
|
||||||
pub fn is_translate(&self) -> bool {
|
pub fn is_translate(&self) -> bool {
|
||||||
use self::TransformOperation::*;
|
use self::TransformOperation::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue