style: Clamp to non-negative value after doing interpolation for circle(), ellipse(), and inset().

Replace LengthOrPercentage with NonNegativeLengthOrPercentage on
ShapeRadius, Circle, Ellipse. And derive ToAnimatedValue for ShapeSource and
its related types, so we clamp its interpolated results into non-negative
values. (i.e. The radius of circle()/ellipse() and the border-radius of
inset().)

Note: We may get negative values when using a negative easing function, so the
clamp is necessary to avoid the incorrect result or any undefined behavior.

Differential Revision: https://phabricator.services.mozilla.com/D14654
This commit is contained in:
Boris Chiou 2018-12-19 19:08:08 +00:00 committed by Emilio Cobos Álvarez
parent 627559546d
commit f0f3eb3194
10 changed files with 110 additions and 27 deletions

View file

@ -286,7 +286,9 @@ impl GeckoStyleCoordConvertible for ComputedShapeRadius {
None
}
},
_ => LengthOrPercentage::from_gecko_style_coord(coord).map(ShapeRadius::Length),
_ => {
GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length)
},
}
}
}