mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Add animation-iteration-count parsing under experimental flag
This commit is contained in:
parent
b6ecb1ccb1
commit
f529786700
2 changed files with 74 additions and 9 deletions
|
@ -334,4 +334,6 @@ partial interface CSSStyleDeclaration {
|
||||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationDuration;
|
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationDuration;
|
||||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-timing-function;
|
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-timing-function;
|
||||||
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationTimingFunction;
|
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationTimingFunction;
|
||||||
|
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animation-iteration-count;
|
||||||
|
[SetterThrows, TreatNullAs=EmptyString] attribute DOMString animationIterationCount;
|
||||||
};
|
};
|
||||||
|
|
|
@ -270,6 +270,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
||||||
|
|
||||||
// TODO(pcwalton): Multiple transitions.
|
// TODO(pcwalton): Multiple transitions.
|
||||||
<%helpers:longhand name="transition-duration">
|
<%helpers:longhand name="transition-duration">
|
||||||
|
use values::computed::ComputedValueAsSpecified;
|
||||||
use values::specified::Time;
|
use values::specified::Time;
|
||||||
|
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
|
@ -286,15 +287,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct T(pub Vec<SingleComputedValue>);
|
pub struct T(pub Vec<SingleComputedValue>);
|
||||||
|
|
||||||
impl ToComputedValue for T {
|
|
||||||
type ComputedValue = T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_computed_value<Cx: TContext>(&self, _: &Cx) -> T {
|
|
||||||
(*self).clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCss for T {
|
impl ToCss for T {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
if self.0.is_empty() {
|
if self.0.is_empty() {
|
||||||
|
@ -311,6 +303,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn parse_one(input: &mut Parser) -> Result<SingleSpecifiedValue,()> {
|
pub fn parse_one(input: &mut Parser) -> Result<SingleSpecifiedValue,()> {
|
||||||
Time::parse(input)
|
Time::parse(input)
|
||||||
|
@ -886,6 +880,75 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
||||||
pub use super::transition_timing_function::SpecifiedValue;
|
pub use super::transition_timing_function::SpecifiedValue;
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
<%helpers:longhand name="animation-iteration-count" experimental="True">
|
||||||
|
use values::computed::ComputedValueAsSpecified;
|
||||||
|
|
||||||
|
pub mod computed_value {
|
||||||
|
use cssparser::ToCss;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
|
||||||
|
pub enum AnimationIterationCount {
|
||||||
|
Number(u32),
|
||||||
|
Infinite,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for AnimationIterationCount {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
match *self {
|
||||||
|
AnimationIterationCount::Number(n) => write!(dest, "{}", n),
|
||||||
|
AnimationIterationCount::Infinite => dest.write_str("infinite"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
|
||||||
|
pub struct T(pub Vec<AnimationIterationCount>);
|
||||||
|
|
||||||
|
impl ToCss for T {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
if self.0.is_empty() {
|
||||||
|
return dest.write_str("none")
|
||||||
|
}
|
||||||
|
for (i, value) in self.0.iter().enumerate() {
|
||||||
|
if i != 0 {
|
||||||
|
try!(dest.write_str(", "))
|
||||||
|
}
|
||||||
|
try!(value.to_css(dest))
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use self::computed_value::AnimationIterationCount;
|
||||||
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
|
|
||||||
|
pub fn parse_one(input: &mut Parser) -> Result<AnimationIterationCount, ()> {
|
||||||
|
if input.try(|input| input.expect_ident_matching("infinite")).is_ok() {
|
||||||
|
Ok(AnimationIterationCount::Infinite)
|
||||||
|
} else {
|
||||||
|
let number = try!(input.expect_integer());
|
||||||
|
if number < 0 {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
Ok(AnimationIterationCount::Number(number as u32))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||||
|
Ok(SpecifiedValue(try!(input.parse_comma_separated(parse_one))))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
|
computed_value::T(vec![AnimationIterationCount::Number(1)])
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
|
</%helpers:longhand>
|
||||||
|
|
||||||
// CSSOM View Module
|
// CSSOM View Module
|
||||||
// https://www.w3.org/TR/cssom-view-1/
|
// https://www.w3.org/TR/cssom-view-1/
|
||||||
${helpers.single_keyword("scroll-behavior",
|
${helpers.single_keyword("scroll-behavior",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue