mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Convert animation-name longhand into vector_longhand
This commit is contained in:
parent
164e8f5071
commit
3934f505d6
1 changed files with 36 additions and 61 deletions
|
@ -757,82 +757,57 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
||||||
pub use properties::longhands::transition_duration::single_value::{get_initial_value, parse};
|
pub use properties::longhands::transition_duration::single_value::{get_initial_value, parse};
|
||||||
</%helpers:vector_longhand>
|
</%helpers:vector_longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="animation-name"
|
<%helpers:vector_longhand name="animation-name"
|
||||||
need_index="True"
|
allow_empty="True"
|
||||||
animatable="False",
|
need_index="True"
|
||||||
allowed_in_keyframe_block="False"
|
animatable="False",
|
||||||
spec="https://drafts.csswg.org/css-animations/#propdef-animation-name">
|
allowed_in_keyframe_block="False"
|
||||||
|
spec="https://drafts.csswg.org/css-animations/#propdef-animation-name">
|
||||||
|
use Atom;
|
||||||
|
use std::fmt;
|
||||||
|
use std::ops::Deref;
|
||||||
|
use style_traits::ToCss;
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::ComputedValueAsSpecified;
|
||||||
use values::NoViewportPercentage;
|
use values::NoViewportPercentage;
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
use Atom;
|
pub use super::SpecifiedValue as T;
|
||||||
use parser::{Parse, ParserContext};
|
}
|
||||||
use std::fmt;
|
|
||||||
use std::ops::Deref;
|
|
||||||
use style_traits::ToCss;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
|
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct AnimationName(pub Atom);
|
pub struct SpecifiedValue(pub Atom);
|
||||||
|
|
||||||
impl fmt::Display for AnimationName {
|
impl fmt::Display for SpecifiedValue {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub use self::AnimationName as SingleComputedValue;
|
|
||||||
|
|
||||||
impl Parse for AnimationName {
|
|
||||||
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
|
||||||
use cssparser::Token;
|
|
||||||
Ok(match input.next() {
|
|
||||||
Ok(Token::Ident(ref value)) if value != "none" => AnimationName(Atom::from(&**value)),
|
|
||||||
Ok(Token::QuotedString(value)) => AnimationName(Atom::from(&*value)),
|
|
||||||
_ => return Err(()),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
|
||||||
pub struct T(pub Vec<AnimationName>);
|
|
||||||
|
|
||||||
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, name) in self.0.iter().enumerate() {
|
|
||||||
if i != 0 {
|
|
||||||
try!(dest.write_str(", "));
|
|
||||||
}
|
|
||||||
// NB: to_string() needed due to geckolib backend.
|
|
||||||
try!(dest.write_str(&*name.to_string()));
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
impl ToCss for SpecifiedValue {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
dest.write_str(&*self.0.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for SpecifiedValue {
|
||||||
|
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||||
|
use cssparser::Token;
|
||||||
|
Ok(match input.next() {
|
||||||
|
Ok(Token::Ident(ref value)) if value != "none" => SpecifiedValue(Atom::from(&**value)),
|
||||||
|
Ok(Token::QuotedString(value)) => SpecifiedValue(Atom::from(&*value)),
|
||||||
|
_ => return Err(()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
impl NoViewportPercentage for SpecifiedValue {}
|
impl NoViewportPercentage for SpecifiedValue {}
|
||||||
pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
|
||||||
computed_value::T(vec![])
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||||
use std::borrow::Cow;
|
SpecifiedValue::parse(context, input)
|
||||||
Ok(SpecifiedValue(try!(input.parse_comma_separated(|i| SingleSpecifiedValue::parse(context, i)))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||||
</%helpers:longhand>
|
</%helpers:vector_longhand>
|
||||||
|
|
||||||
<%helpers:vector_longhand name="animation-duration"
|
<%helpers:vector_longhand name="animation-duration"
|
||||||
need_index="True"
|
need_index="True"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue