From e48f94cbdac07994ce743ad22aa4b647dac1f174 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Mon, 5 Jun 2017 11:24:38 +0900 Subject: [PATCH] Don't introduce calc() when interpolating between length and percentages if either side is zero Without this patch anim-css-strokewidth-1-by-pct-pct.svg (and possibly others) fails because we calculate the result as 'calc(0px + 10%)' and we don't support calc on stroke-width (yet) so the rendered result is incorrect. As a more thorough fix, we should make the zero-value for LengthOrPercentageOrNumber a zero *number* (instead of a zero length) but that won't work yet since we don't support animating between stroke-widths with units and those that don't (see https://bugzilla.mozilla.org/show_bug.cgi?id=1369614). Regardless of that, we still shouldn't introduce calc in order to add a zero value using the LengthOrPercentage type, so this change is still needed. --- .../style/properties/helpers/animated_properties.mako.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index c23aeec2a7c..e76c0caabbb 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -1040,6 +1040,13 @@ impl Animatable for LengthOrPercentage { .map(LengthOrPercentage::Percentage) } (this, other) => { + // Special handling for zero values since these should not require calc(). + if this.is_definitely_zero() { + return other.add_weighted(&other, 0., other_portion) + } else if other.is_definitely_zero() { + return this.add_weighted(self, self_portion, 0.) + } + let this: CalcLengthOrPercentage = From::from(this); let other: CalcLengthOrPercentage = From::from(other); this.add_weighted(&other, self_portion, other_portion)