From 3f453dfcd46a200fa295fc155deb0807b18addcb Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Wed, 30 Aug 2017 23:21:49 -0500 Subject: [PATCH] servo: Merge #18210 - Skip adding/accumulating ClipRect values which corresponding rect offset is auto (from mantaroh:clip-interpolation-fix); r=nox This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1390352 This patch will skip adding/accumulating the values which corresponding rect offset is auto, and make Servo_AnimationValues_ComputeDistance return negative value instead of 0.0 when the function fails to distinguish its failure. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors There are already these tests in dom/smil/tests of gecko, this PR will enable these tests. For detail, see https://bugzilla.mozilla.org/show_bug.cgi?id=1390352. Source-Repo: https://github.com/servo/servo Source-Revision: 5624c0e3f16e0057bb228627eaf9018ef88e7786 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : b387ca2a23f2e20f5344e409ec0f14f9e8457163 --- .../helpers/animated_properties.mako.rs | 21 +++++++++++++++++++ servo/components/style/values/computed/mod.rs | 2 +- servo/ports/geckolib/glue.rs | 4 +++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/servo/components/style/properties/helpers/animated_properties.mako.rs b/servo/components/style/properties/helpers/animated_properties.mako.rs index 25cc6b47e35c..8358b1e2db12 100644 --- a/servo/components/style/properties/helpers/animated_properties.mako.rs +++ b/servo/components/style/properties/helpers/animated_properties.mako.rs @@ -924,6 +924,27 @@ impl Into for f64 { impl RepeatableListAnimatable for generic_position::Position where H: RepeatableListAnimatable, V: RepeatableListAnimatable {} +/// https://drafts.csswg.org/css-transitions/#animtype-rect +impl Animate for ClipRect { + #[inline] + fn animate(&self, other: &Self, procedure: Procedure) -> Result { + let animate_component = |this: &Option, other: &Option| { + match (this.animate(other, procedure)?, procedure) { + (None, Procedure::Interpolate { .. }) => Ok(None), + (None, _) => Err(()), + (result, _) => Ok(result), + } + }; + + Ok(ClipRect { + top: animate_component(&self.top, &other.top)?, + right: animate_component(&self.right, &other.right)?, + bottom: animate_component(&self.bottom, &other.bottom)?, + left: animate_component(&self.left, &other.left)?, + }) + } +} + impl ToAnimatedZero for ClipRect { #[inline] fn to_animated_zero(&self) -> Result { Err(()) } diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index 86aaf29b1c54..4d75b7c89546 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -445,7 +445,7 @@ pub type NonNegativeLengthOrPercentageOrNumber = Either, diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index a35be024a33e..354bd3c194a9 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -379,7 +379,9 @@ pub extern "C" fn Servo_AnimationValues_ComputeDistance(from: RawServoAnimationV -> f64 { let from_value = AnimationValue::as_arc(&from); let to_value = AnimationValue::as_arc(&to); - from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(0.0) + // If compute_squared_distance() failed, this function will return negative value + // in order to check whether we support the specified paced animation values. + from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(-1.0) } #[no_mangle]