mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Animate NonNegativeLength as its inner type
This commit is contained in:
parent
52f0fcabad
commit
d8c43ac855
3 changed files with 19 additions and 20 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue