Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Animate NonNegativeLength as its inner type
  • Loading branch information
nox committed Feb 15, 2018
1 parent 52f0fca commit d8c43ac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
10 changes: 5 additions & 5 deletions components/style/values/animated/effects.rs
Expand Up @@ -13,7 +13,7 @@ use values::Impossible;
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use values::animated::color::RGBA;
use values::computed::{Angle, Number};
use values::computed::length::{Length, NonNegativeLength};
use values::computed::length::Length;
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::effects::BoxShadow as GenericBoxShadow;
use values::generics::effects::Filter as GenericFilter;
Expand All @@ -33,7 +33,7 @@ pub type TextShadowList = ShadowList<SimpleShadow>;
pub struct ShadowList<Shadow>(Vec<Shadow>);

/// An animated value for a single `box-shadow`.
pub type BoxShadow = GenericBoxShadow<Option<RGBA>, Length, NonNegativeLength, Length>;
pub type BoxShadow = GenericBoxShadow<Option<RGBA>, Length, Length, Length>;

/// An animated value for the `filter` property.
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
Expand All @@ -42,14 +42,14 @@ pub struct FilterList(pub Vec<Filter>);

/// An animated value for a single `filter`.
#[cfg(feature = "gecko")]
pub type Filter = GenericFilter<Angle, Number, NonNegativeLength, SimpleShadow>;
pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow>;

/// An animated value for a single `filter`.
#[cfg(not(feature = "gecko"))]
pub type Filter = GenericFilter<Angle, Number, NonNegativeLength, Impossible>;
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;

/// An animated value for the `drop-shadow()` filter.
pub type SimpleShadow = GenericSimpleShadow<Option<RGBA>, Length, NonNegativeLength>;
pub type SimpleShadow = GenericSimpleShadow<Option<RGBA>, Length, Length>;

impl ToAnimatedValue for ComputedBoxShadowList {
type AnimatedValue = BoxShadowList;
Expand Down
15 changes: 0 additions & 15 deletions components/style/values/animated/mod.rs
Expand Up @@ -17,7 +17,6 @@ use values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
use values::computed::ComputedUrl;
use values::computed::MaxLength as ComputedMaxLength;
use values::computed::MozLength as ComputedMozLength;
use values::computed::NonNegativeLength as ComputedNonNegativeLength;
use values::specified::url::SpecifiedUrl;

pub mod color;
Expand Down Expand Up @@ -261,20 +260,6 @@ trivial_to_animated_value!(ComputedUrl);
trivial_to_animated_value!(bool);
trivial_to_animated_value!(f32);

impl ToAnimatedValue for ComputedNonNegativeLength {
type AnimatedValue = Self;

#[inline]
fn to_animated_value(self) -> Self {
self
}

#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
ComputedNonNegativeLength::new(animated.px().max(0.))
}
}

impl ToAnimatedValue for ComputedBorderCornerRadius {
type AnimatedValue = Self;

Expand Down
14 changes: 14 additions & 0 deletions components/style/values/computed/length.rs
Expand Up @@ -815,6 +815,20 @@ pub type LengthOrNormal = Either<Length, Normal>;
/// A wrapper of Length, whose value must be >= 0.
pub type NonNegativeLength = NonNegative<Length>;

impl ToAnimatedValue for NonNegativeLength {
type AnimatedValue = Length;

#[inline]
fn to_animated_value(self) -> Self::AnimatedValue {
self.0
}

#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
NonNegativeLength::new(animated.px().max(0.))
}
}

impl NonNegativeLength {
/// Create a NonNegativeLength.
#[inline]
Expand Down

0 comments on commit d8c43ac

Please sign in to comment.