mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Move animation-iteration-count outside of mako.
This commit is contained in:
parent
2536e1ee98
commit
dc414134bf
9 changed files with 80 additions and 66 deletions
|
@ -4,8 +4,21 @@
|
|||
|
||||
//! Computed types for box properties.
|
||||
|
||||
use values::computed::Number;
|
||||
use values::computed::length::LengthOrPercentage;
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
|
||||
/// A computed value for the `vertical-align` property.
|
||||
pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;
|
||||
|
||||
/// A computed value for the `animation-iteration-count` property.
|
||||
pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
|
||||
|
||||
impl AnimationIterationCount {
|
||||
/// Returns the value `1.0`.
|
||||
#[inline]
|
||||
pub fn one() -> Self {
|
||||
GenericAnimationIterationCount::Number(1.0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ pub use self::angle::Angle;
|
|||
pub use self::background::BackgroundSize;
|
||||
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
|
||||
pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing};
|
||||
pub use self::box_::VerticalAlign;
|
||||
pub use self::box_::{AnimationIterationCount, VerticalAlign};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
pub use self::flex::FlexBasis;
|
||||
|
|
|
@ -46,3 +46,12 @@ impl<L> ToAnimatedZero for VerticalAlign<L> {
|
|||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-animations/#animation-iteration-count
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum AnimationIterationCount<Number> {
|
||||
/// A `<number>` value.
|
||||
Number(Number),
|
||||
/// The `infinite` keyword.
|
||||
Infinite,
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
use values::specified::AllowQuirks;
|
||||
use values::specified::{AllowQuirks, Number};
|
||||
use values::specified::length::LengthOrPercentage;
|
||||
|
||||
/// A specified value for the `vertical-align` property.
|
||||
|
@ -39,3 +40,28 @@ impl Parse for VerticalAlign {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-animations/#animation-iteration-count
|
||||
pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
|
||||
|
||||
impl Parse for AnimationIterationCount {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut ::cssparser::Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|input| input.expect_ident_matching("infinite")).is_ok() {
|
||||
return Ok(GenericAnimationIterationCount::Infinite)
|
||||
}
|
||||
|
||||
let number = Number::parse_non_negative(context, input)?;
|
||||
Ok(GenericAnimationIterationCount::Number(number))
|
||||
}
|
||||
}
|
||||
|
||||
impl AnimationIterationCount {
|
||||
/// Returns the value `1.0`.
|
||||
#[inline]
|
||||
pub fn one() -> Self {
|
||||
GenericAnimationIterationCount::Number(Number::new(1.0))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, Justify
|
|||
pub use self::background::BackgroundSize;
|
||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||
pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
|
||||
pub use self::box_::VerticalAlign;
|
||||
pub use self::box_::{AnimationIterationCount, VerticalAlign};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
pub use self::flex::FlexBasis;
|
||||
|
@ -176,8 +176,10 @@ impl BorderStyle {
|
|||
}
|
||||
}
|
||||
|
||||
/// A CSS `<number>` specified value.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-values-3/#number-value
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct Number {
|
||||
/// The numeric value itself.
|
||||
value: CSSFloat,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue