Use CustomIdent in will-change

This commit is contained in:
Anthony Ramine 2017-06-15 11:30:41 +02:00
parent b0392dbf39
commit cdcc8157c6
2 changed files with 15 additions and 22 deletions

View file

@ -2683,19 +2683,19 @@ fn static_assert() {
} }
for feature in features.iter() { for feature in features.iter() {
if feature == &atom!("scroll-position") { if feature.0 == atom!("scroll-position") {
self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL as u8; self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_SCROLL as u8;
} else if feature == &atom!("opacity") { } else if feature.0 == atom!("opacity") {
self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_OPACITY as u8; self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_OPACITY as u8;
} else if feature == &atom!("transform") { } else if feature.0 == atom!("transform") {
self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_TRANSFORM as u8; self.gecko.mWillChangeBitField |= NS_STYLE_WILL_CHANGE_TRANSFORM as u8;
} }
unsafe { unsafe {
Gecko_AppendWillChange(&mut self.gecko, feature.as_ptr()); Gecko_AppendWillChange(&mut self.gecko, feature.0.as_ptr());
} }
if let Ok(prop_id) = PropertyId::parse(feature.to_string().into()) { if let Ok(prop_id) = PropertyId::parse(feature.0.to_string().into()) {
match prop_id.as_shorthand() { match prop_id.as_shorthand() {
Ok(shorthand) => { Ok(shorthand) => {
for longhand in shorthand.longhands() { for longhand in shorthand.longhands() {

View file

@ -1866,9 +1866,9 @@ ${helpers.single_keyword("-moz-orient",
<%helpers:longhand name="will-change" products="gecko" animation_value_type="none" <%helpers:longhand name="will-change" products="gecko" animation_value_type="none"
spec="https://drafts.csswg.org/css-will-change/#will-change"> spec="https://drafts.csswg.org/css-will-change/#will-change">
use cssparser::serialize_identifier;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::CustomIdent;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -1882,7 +1882,7 @@ ${helpers.single_keyword("-moz-orient",
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Auto, Auto,
AnimateableFeatures(Vec<Atom>), AnimateableFeatures(Vec<CustomIdent>),
} }
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
@ -1891,12 +1891,10 @@ ${helpers.single_keyword("-moz-orient",
SpecifiedValue::Auto => dest.write_str("auto"), SpecifiedValue::Auto => dest.write_str("auto"),
SpecifiedValue::AnimateableFeatures(ref features) => { SpecifiedValue::AnimateableFeatures(ref features) => {
let (first, rest) = features.split_first().unwrap(); let (first, rest) = features.split_first().unwrap();
// handle head element first.to_css(dest)?;
serialize_identifier(&*first.to_string(), dest)?;
// handle tail, precede each with a delimiter
for feature in rest { for feature in rest {
dest.write_str(", ")?; dest.write_str(", ")?;
serialize_identifier(&*feature.to_string(), dest)?; feature.to_css(dest)?;
} }
Ok(()) Ok(())
} }
@ -1916,17 +1914,12 @@ ${helpers.single_keyword("-moz-orient",
Ok(computed_value::T::Auto) Ok(computed_value::T::Auto)
} else { } else {
input.parse_comma_separated(|i| { input.parse_comma_separated(|i| {
let ident = i.expect_ident()?; CustomIdent::from_ident(i.expect_ident()?, &[
let bad_keyword = match_ignore_ascii_case! { &ident, "will-change",
"will-change" | "none" | "all" | "auto" | "none",
"initial" | "inherit" | "unset" | "default" => true, "all",
_ => false, "auto",
}; ])
if bad_keyword {
Err(SelectorParseError::UnexpectedIdent(ident.into()).into())
} else {
Ok(Atom::from(ident))
}
}).map(SpecifiedValue::AnimateableFeatures) }).map(SpecifiedValue::AnimateableFeatures)
} }
} }