mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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.
This commit is contained in:
parent
00cdced2ca
commit
e48f94cbda
1 changed files with 7 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue