diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index c9a3ab8cb64..be4a26305ee 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -326,9 +326,25 @@ impl Interpolate for CSSParserColor { impl Interpolate for CalcLengthOrPercentage { #[inline] fn interpolate(&self, other: &Self, time: f64) -> Result { + fn interpolate_half(this: Option, + other: Option, + time: f64) + -> Result, ()> + where T: Default + Interpolate + { + match (this, other) { + (None, None) => Ok(None), + (this, other) => { + let this = this.unwrap_or(T::default()); + let other = other.unwrap_or(T::default()); + this.interpolate(&other, time).map(Some) + } + } + } + Ok(CalcLengthOrPercentage { - length: self.length.interpolate(&other.length, time).ok().and_then(|x|x), - percentage: self.percentage.interpolate(&other.percentage, time).ok().and_then(|x|x), + length: try!(interpolate_half(self.length, other.length, time)), + percentage: try!(interpolate_half(self.percentage, other.percentage, time)), }) } } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index d9d08e602d6..ee63e759d12 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6168,6 +6168,12 @@ "url": "/_mozilla/css/animations/basic-transition.html" } ], + "css/animations/mixed-units.html": [ + { + "path": "css/animations/mixed-units.html", + "url": "/_mozilla/css/animations/mixed-units.html" + } + ], "css/animations/transition-raf.html": [ { "path": "css/animations/transition-raf.html", diff --git a/tests/wpt/mozilla/tests/css/animations/mixed-units.html b/tests/wpt/mozilla/tests/css/animations/mixed-units.html new file mode 100644 index 00000000000..bb029a9fa80 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/animations/mixed-units.html @@ -0,0 +1,33 @@ + + +Animation test: mixed units. + + + +
+