diff options
Diffstat (limited to '')
-rw-r--r-- | servo/components/style/values/specified/animation.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/servo/components/style/values/specified/animation.rs b/servo/components/style/values/specified/animation.rs index 5a1f5003f3..552521711c 100644 --- a/servo/components/style/values/specified/animation.rs +++ b/servo/components/style/values/specified/animation.rs @@ -165,6 +165,12 @@ impl AnimationIterationCount { pub fn one() -> Self { Self::Number(NonNegativeNumber::new(1.0)) } + + /// Returns true if it's `1.0`. + #[inline] + pub fn is_one(&self) -> bool { + *self == Self::one() + } } /// A value for the `animation-name` property. @@ -230,6 +236,17 @@ pub enum AnimationDirection { AlternateReverse, } +impl AnimationDirection { + /// Returns true if the name matches any animation-direction keyword. + #[inline] + pub fn match_keywords(name: &AnimationName) -> bool { + if let Some(name) = name.as_atom() { + return name.with_str(|n| Self::from_ident(n).is_ok()); + } + false + } +} + /// https://drafts.csswg.org/css-animations/#animation-play-state #[derive(Copy, Clone, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[repr(u8)] @@ -239,6 +256,17 @@ pub enum AnimationPlayState { Paused, } +impl AnimationPlayState { + /// Returns true if the name matches any animation-play-state keyword. + #[inline] + pub fn match_keywords(name: &AnimationName) -> bool { + if let Some(name) = name.as_atom() { + return name.with_str(|n| Self::from_ident(n).is_ok()); + } + false + } +} + /// https://drafts.csswg.org/css-animations/#propdef-animation-fill-mode #[derive(Copy, Clone, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[repr(u8)] @@ -250,6 +278,18 @@ pub enum AnimationFillMode { Both, } +impl AnimationFillMode { + /// Returns true if the name matches any animation-fill-mode keyword. + /// Note: animation-name:none is its initial value, so we don't have to match none here. + #[inline] + pub fn match_keywords(name: &AnimationName) -> bool { + if let Some(atom) = name.as_atom() { + return !name.is_none() && atom.with_str(|n| Self::from_ident(n).is_ok()); + } + false + } +} + /// https://drafts.csswg.org/css-animations-2/#animation-composition #[derive(Copy, Clone, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[repr(u8)] |