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

@ -13,7 +13,6 @@ use font_metrics::FontMetricsProvider;
use properties::{self, CascadeFlags, ComputedValues, LonghandId};
use properties::animated_properties::{AnimatedProperty, TransitionProperty};
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
use rule_tree::CascadeLevel;
use servo_arc::Arc;
@ -22,6 +21,7 @@ use stylesheets::keyframes_rule::{KeyframesStep, KeyframesStepValue};
use timer::Timer;
use values::computed::Time;
use values::computed::transform::TimingFunction;
use values::generics::box_::AnimationIterationCount;
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
/// This structure represents a keyframes animation current iteration state.

View file

@ -3261,15 +3261,16 @@ fn static_assert() {
data.longhands_by_name["animation-play-state"].keyword)}
pub fn set_animation_iteration_count<I>(&mut self, v: I)
where I: IntoIterator<Item = longhands::animation_iteration_count::computed_value::single_value::T>,
where
I: IntoIterator<Item = values::computed::AnimationIterationCount>,
I::IntoIter: ExactSizeIterator + Clone
{
use std::f32;
use properties::longhands::animation_iteration_count::single_value::SpecifiedValue as AnimationIterationCount;
use values::generics::box_::AnimationIterationCount;
let v = v.into_iter();
debug_assert!(v.len() != 0);
debug_assert_ne!(v.len(), 0);
let input_len = v.len();
unsafe { self.gecko.mAnimations.ensure_len(input_len) };
@ -3281,10 +3282,12 @@ fn static_assert() {
}
}
}
pub fn animation_iteration_count_at(&self, index: usize)
-> longhands::animation_iteration_count::computed_value::SingleComputedValue {
use properties::longhands::animation_iteration_count::single_value::computed_value::T
as AnimationIterationCount;
pub fn animation_iteration_count_at(
&self,
index: usize,
) -> values::computed::AnimationIterationCount {
use values::generics::box_::AnimationIterationCount;
if self.gecko.mAnimations[index].mIterationCount.is_infinite() {
AnimationIterationCount::Infinite
@ -3292,6 +3295,7 @@ fn static_assert() {
AnimationIterationCount::Number(self.gecko.mAnimations[index].mIterationCount)
}
}
${impl_animation_count('iteration_count', 'IterationCount')}
${impl_copy_animation_value('iteration_count', 'IterationCount')}

View file

@ -541,58 +541,18 @@ ${helpers.predefined_type("animation-timing-function",
allowed_in_keyframe_block=True,
spec="https://drafts.csswg.org/css-transitions/#propdef-animation-timing-function")}
<%helpers:vector_longhand name="animation-iteration-count"
need_index="True"
${helpers.predefined_type(
"animation-iteration-count",
"AnimationIterationCount",
"computed::AnimationIterationCount::one()",
initial_specified_value="specified::AnimationIterationCount::one()",
vector=True,
need_index=True,
animation_value_type="none",
extra_prefixes="moz webkit"
spec="https://drafts.csswg.org/css-animations/#propdef-animation-iteration-count",
allowed_in_keyframe_block="False">
pub mod computed_value {
pub use super::SpecifiedValue as T;
}
// https://drafts.csswg.org/css-animations/#animation-iteration-count
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToComputedValue)]
pub enum SpecifiedValue {
Number(f32),
Infinite,
}
impl Parse for SpecifiedValue {
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(SpecifiedValue::Infinite)
}
let number = input.expect_number()?;
if number < 0.0 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
Ok(SpecifiedValue::Number(number))
}
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
get_initial_specified_value()
}
#[inline]
pub fn get_initial_specified_value() -> SpecifiedValue {
SpecifiedValue::Number(1.0)
}
#[inline]
pub fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<SpecifiedValue, ParseError<'i>> {
SpecifiedValue::parse(context, input)
}
</%helpers:vector_longhand>
extra_prefixes="moz webkit",
allowed_in_keyframe_block=False,
spec="https://drafts.csswg.org/css-transitions/#propdef-animation-iteration-count",
)}
<% animation_direction_custom_consts = { "alternate-reverse": "Alternate_reverse" } %>
${helpers.single_keyword("animation-direction",

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,

View file

@ -5,9 +5,9 @@
use parsing::parse;
use servo_atoms::Atom;
use style::parser::Parse;
use style::properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
use style::properties::longhands::animation_name;
use style::values::{KeyframesName, CustomIdent};
use style::values::specified::AnimationIterationCount;
use style_traits::ToCss;
#[test]