Use FunctionKeyword for computed_value of timing-function as well.

This commit is contained in:
Hiroyuki Ikezoe 2017-04-28 07:35:11 +09:00
parent 90ab181a6c
commit f15896078a
3 changed files with 48 additions and 33 deletions

View file

@ -502,6 +502,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use parser::{Parse, ParserContext};
use std::fmt;
use style_traits::ToCss;
use super::FunctionKeyword;
use values::specified;
pub use super::parse;
@ -512,6 +513,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
CubicBezier(Point2D<f32>, Point2D<f32>),
Steps(u32, StartEnd),
Frames(u32),
Keyword(FunctionKeyword),
}
impl ToCss for T {
@ -538,6 +540,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
try!(frames.to_css(dest));
dest.write_str(")")
},
T::Keyword(keyword) => {
super::serialize_keyword(dest, keyword)
}
}
}
}
@ -667,7 +672,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
}
}
// https://drafts.csswg.org/css-transitions/#serializing-a-timing-function
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
@ -715,7 +719,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
SpecifiedValue::Frames(frames) => {
computed_value::T::Frames(frames.to_computed_value(context) as u32)
},
SpecifiedValue::Keyword(keyword) => keyword.to_computed_value(),
SpecifiedValue::Keyword(keyword) => {
computed_value::T::Keyword(keyword)
},
}
}
#[inline]
@ -736,13 +742,16 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
let frames = frames as i32;
SpecifiedValue::Frames(specified::Integer::from_computed_value(&frames))
},
computed_value::T::Keyword(keyword) => {
SpecifiedValue::Keyword(keyword)
},
}
}
}
impl FunctionKeyword {
#[inline]
pub fn to_computed_value(&self) -> computed_value::T {
pub fn to_non_keyword_value(&self) -> computed_value::T {
match *self {
FunctionKeyword::Ease => ease(),
FunctionKeyword::Linear => linear(),
@ -760,7 +769,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
#[inline]
pub fn get_initial_value() -> computed_value::T {
ease()
computed_value::T::Keyword(FunctionKeyword::Ease)
}
#[inline]