mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Change AnimatedValue for NonNegativeLengthOrPercentage to its inner type
This commit is contained in:
parent
b79dc269f7
commit
da5acc81d2
3 changed files with 16 additions and 17 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue