From 9c9a181f35280dabb5e089d9ae5df3fab1f6df1f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 30 Oct 2017 18:01:32 -0700 Subject: [PATCH] Allow cross interpolation between differing translate/scale functions See ToPrimitive() in StyleAnimationValue.cpp --- .../style/properties/helpers/animated_properties.mako.rs | 7 ++++++- components/style/values/computed/length.rs | 5 +++++ components/style/values/generics/transform.rs | 1 - components/style/values/specified/transform.rs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 7563dc3979e..5a8e766b7e2 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -1226,7 +1226,12 @@ impl Animate for ComputedTransformOperation { fd_matrix.animate(&td_matrix, procedure)?, )) }, - // XXXManishearth handle crossover between translate and scale functions + (ref f, ref t) if f.is_translate() && t.is_translate() => { + f.to_translate_3d().animate(&t.to_translate_3d(), procedure) + } + (ref f, ref t) if f.is_scale() && t.is_scale() => { + f.to_scale_3d().animate(&t.to_scale_3d(), procedure) + } _ => Err(()), } } diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 8cb69b65b17..ece797dd224 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -706,6 +706,11 @@ impl CSSPixelLength { pub fn abs(self) -> Self { CSSPixelLength::new(self.0.abs()) } + + /// Zero value + pub fn zero() -> Self { + CSSPixelLength::new(0.) + } } impl ToCss for CSSPixelLength { diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index b663babf279..2bbf641b834 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -249,7 +249,6 @@ pub struct Transform(pub Vec); impl TransformOperation { - /// Check if it is any translate function pub fn is_translate(&self) -> bool { use self::TransformOperation::*; diff --git a/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index b7e83cf4e3b..14bd00a1af5 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -10,8 +10,8 @@ use selectors::parser::SelectorParseErrorKind; use style_traits::{ParseError, StyleParseErrorKind}; use values::computed::{Context, LengthOrPercentage as ComputedLengthOrPercentage}; use values::computed::{Percentage as ComputedPercentage, ToComputedValue}; -use values::generics::transform::{Matrix3D, Transform as GenericTransform}; use values::computed::transform::TimingFunction as ComputedTimingFunction; +use values::generics::transform::{Matrix3D, Transform as GenericTransform}; use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction, Matrix}; use values::generics::transform::{TimingKeyword, TransformOrigin as GenericTransformOrigin}; use values::generics::transform::TransformOperation as GenericTransformOperation;