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