mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
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:
parent
627559546d
commit
f0f3eb3194
10 changed files with 110 additions and 27 deletions
|
@ -12,7 +12,9 @@ use crate::properties::PropertyId;
|
|||
use crate::values::computed::length::CalcLengthOrPercentage;
|
||||
use crate::values::computed::url::ComputedUrl;
|
||||
use crate::values::computed::Angle as ComputedAngle;
|
||||
use crate::values::computed::Image;
|
||||
use crate::values::CSSFloat;
|
||||
use crate::values::specified::SVGPathData;
|
||||
use app_units::Au;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use smallvec::SmallVec;
|
||||
|
@ -338,6 +340,19 @@ trivial_to_animated_value!(ComputedAngle);
|
|||
trivial_to_animated_value!(ComputedUrl);
|
||||
trivial_to_animated_value!(bool);
|
||||
trivial_to_animated_value!(f32);
|
||||
// Note: This implementation is for ToAnimatedValue of ShapeSource.
|
||||
//
|
||||
// SVGPathData uses Box<[T]>. If we want to derive ToAnimatedValue for all the
|
||||
// types, we have to do "impl ToAnimatedValue for Box<[T]>" first.
|
||||
// However, the general version of "impl ToAnimatedValue for Box<[T]>" needs to
|
||||
// clone |T| and convert it into |T::AnimatedValue|. However, for SVGPathData
|
||||
// that is unnecessary--moving |T| is sufficient. So here, we implement this
|
||||
// trait manually.
|
||||
trivial_to_animated_value!(SVGPathData);
|
||||
// FIXME: Bug 1514342, Image is not animatable, but we still need to implement
|
||||
// this to avoid adding this derive to generic::Image and all its arms. We can
|
||||
// drop this after landing Bug 1514342.
|
||||
trivial_to_animated_value!(Image);
|
||||
|
||||
impl ToAnimatedZero for Au {
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue