style: Move animation-iteration-count outside of mako.

This commit is contained in:
Emilio Cobos Álvarez 2017-10-24 15:18:37 +02:00
parent 2536e1ee98
commit dc414134bf
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
9 changed files with 80 additions and 66 deletions

View file

@ -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)
}
}

View file

@ -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;

View file

@ -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,
}

View file

@ -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))
}
}

View file

@ -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,