Skip to content

Commit

Permalink
Change AnimatedValue for PositiveInteger to CSSInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Feb 13, 2018
1 parent e0b38f9 commit b79dc26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 0 additions & 16 deletions components/style/values/animated/mod.rs
Expand Up @@ -11,7 +11,6 @@
use app_units::Au;
use euclid::{Point2D, Size2D};
use smallvec::SmallVec;
use std::cmp::max;
use values::computed::Angle as ComputedAngle;
use values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
#[cfg(feature = "servo")]
Expand All @@ -22,7 +21,6 @@ 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::computed::PositiveInteger as ComputedPositiveInteger;
use values::specified::url::SpecifiedUrl;

pub mod color;
Expand Down Expand Up @@ -308,20 +306,6 @@ impl ToAnimatedValue for ComputedNonNegativeLength {
}
}

impl ToAnimatedValue for ComputedPositiveInteger {
type AnimatedValue = Self;

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

#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
max(animated.0, 1).into()
}
}

impl ToAnimatedValue for ComputedNonNegativeLengthOrPercentage {
type AnimatedValue = Self;

Expand Down
16 changes: 16 additions & 0 deletions components/style/values/computed/mod.rs
Expand Up @@ -18,13 +18,15 @@ use rule_cache::RuleCacheConditions;
#[cfg(feature = "servo")]
use servo_url::ServoUrl;
use std::cell::RefCell;
use std::cmp;
use std::f32;
use std::fmt::{self, Write};
#[cfg(feature = "servo")]
use std::sync::Arc;
use style_traits::{CssWriter, ToCss};
use style_traits::cursor::CursorKind;
use super::{CSSFloat, CSSInteger};
use super::animated::ToAnimatedValue;
use super::generics::{GreaterThanOrEqualToOne, NonNegative};
use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth};
use super::generics::grid::{TrackSize as GenericTrackSize, TrackList as GenericTrackList};
Expand Down Expand Up @@ -511,6 +513,20 @@ impl IntegerOrAuto {
/// A wrapper of Integer, but only accept a value >= 1.
pub type PositiveInteger = GreaterThanOrEqualToOne<CSSInteger>;

impl ToAnimatedValue for PositiveInteger {
type AnimatedValue = CSSInteger;

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

#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
cmp::max(animated, 1).into()
}
}

impl From<CSSInteger> for PositiveInteger {
#[inline]
fn from(int: CSSInteger) -> PositiveInteger {
Expand Down

0 comments on commit b79dc26

Please sign in to comment.