Change AnimatedValue for NonNegativeLengthOrPercentage to its inner type

This commit is contained in:
Anthony Ramine 2018-02-12 23:35:18 +01:00
parent b79dc269f7
commit da5acc81d2
3 changed files with 16 additions and 17 deletions

View file

@ -789,7 +789,7 @@ impl ToAnimatedZero for AnimationValue {
impl RepeatableListAnimatable for LengthOrPercentage {}
impl RepeatableListAnimatable for Either<f32, LengthOrPercentage> {}
impl RepeatableListAnimatable for Either<NonNegativeNumber, NonNegativeLengthOrPercentage> {}
impl RepeatableListAnimatable for SvgLengthOrPercentageOrNumber<NonNegativeLengthOrPercentage, NonNegativeNumber> {}
impl RepeatableListAnimatable for SvgLengthOrPercentageOrNumber<LengthOrPercentage, NonNegativeNumber> {}
macro_rules! repeated_vec_impl {
($($ty:ty),*) => {

View file

@ -19,7 +19,6 @@ use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqua
use values::computed::MaxLength as ComputedMaxLength;
use values::computed::MozLength as ComputedMozLength;
use values::computed::NonNegativeLength as ComputedNonNegativeLength;
use values::computed::NonNegativeLengthOrPercentage as ComputedNonNegativeLengthOrPercentage;
use values::computed::NonNegativeNumber as ComputedNonNegativeNumber;
use values::specified::url::SpecifiedUrl;
@ -306,20 +305,6 @@ impl ToAnimatedValue for ComputedNonNegativeLength {
}
}
impl ToAnimatedValue for ComputedNonNegativeLengthOrPercentage {
type AnimatedValue = Self;
#[inline]
fn to_animated_value(self) -> Self {
self
}
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
animated.0.clamp_to_non_negative().into()
}
}
impl ToAnimatedValue for ComputedBorderCornerRadius {
type AnimatedValue = Self;

View file

@ -14,7 +14,7 @@ use style_traits::{CssWriter, ToCss};
use style_traits::values::specified::AllowedNumericType;
use super::{Number, ToComputedValue, Context, Percentage};
use values::{Auto, CSSFloat, Either, None_, Normal, specified};
use values::animated::{Animate, Procedure, ToAnimatedZero};
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use values::computed::NonNegativeNumber;
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::NonNegative;
@ -664,6 +664,20 @@ impl ToComputedValue for specified::LengthOrPercentageOrNone {
/// A wrapper of LengthOrPercentage, whose value must be >= 0.
pub type NonNegativeLengthOrPercentage = NonNegative<LengthOrPercentage>;
impl ToAnimatedValue for NonNegativeLengthOrPercentage {
type AnimatedValue = LengthOrPercentage;
#[inline]
fn to_animated_value(self) -> Self::AnimatedValue {
self.into()
}
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
animated.clamp_to_non_negative().into()
}
}
impl From<NonNegativeLength> for NonNegativeLengthOrPercentage {
#[inline]
fn from(length: NonNegativeLength) -> Self {