mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Use CustomIdent for animation-name and @keyframes
This commit is contained in:
parent
4993a80074
commit
d9c2d1a9fb
8 changed files with 35 additions and 43 deletions
|
@ -62,7 +62,7 @@ use std::ptr;
|
|||
use std::sync::Arc;
|
||||
use std::cmp;
|
||||
use values::computed::ToComputedValue;
|
||||
use values::{Either, Auto};
|
||||
use values::{Either, Auto, CustomIdent};
|
||||
use computed_values::border_style;
|
||||
|
||||
pub mod style_structs {
|
||||
|
@ -2205,7 +2205,7 @@ fn static_assert() {
|
|||
self.gecko.mAnimationNameCount = v.0.len() as u32;
|
||||
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mAnimations.iter_mut()) {
|
||||
// TODO This is inefficient. We should fix this in bug 1329169.
|
||||
gecko.mName.assign_utf8(&nsCString::from(servo.0.to_string()));
|
||||
gecko.mName.assign_utf8(&nsCString::from(servo.0 .0.to_string()));
|
||||
}
|
||||
}
|
||||
pub fn animation_name_at(&self, index: usize)
|
||||
|
@ -2213,7 +2213,8 @@ fn static_assert() {
|
|||
use Atom;
|
||||
use properties::longhands::animation_name::single_value::SpecifiedValue as AnimationName;
|
||||
// XXX: Is there any effective ways?
|
||||
AnimationName(Atom::from(String::from_utf16_lossy(&self.gecko.mAnimations[index].mName[..])))
|
||||
AnimationName(CustomIdent(Atom::from(
|
||||
String::from_utf16_lossy(&self.gecko.mAnimations[index].mName[..]))))
|
||||
}
|
||||
pub fn copy_animation_name_from(&mut self, other: &Self) {
|
||||
unsafe { self.gecko.mAnimations.ensure_len(other.gecko.mAnimations.len()) };
|
||||
|
|
|
@ -796,7 +796,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
use std::ops::Deref;
|
||||
use style_traits::ToCss;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::HasViewportPercentage;
|
||||
use values::{HasViewportPercentage, CustomIdent};
|
||||
|
||||
pub mod computed_value {
|
||||
pub use super::SpecifiedValue as T;
|
||||
|
@ -804,7 +804,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub Atom);
|
||||
pub struct SpecifiedValue(pub CustomIdent);
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
|
@ -813,21 +813,21 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
SpecifiedValue(atom!(""))
|
||||
SpecifiedValue(CustomIdent(atom!("")))
|
||||
}
|
||||
|
||||
impl fmt::Display for SpecifiedValue {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
self.0 .0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.0 == atom!("") {
|
||||
if self.0 .0 == atom!("") {
|
||||
dest.write_str("none")
|
||||
} else {
|
||||
dest.write_str(&*self.0.to_string())
|
||||
self.0.to_css(dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -835,23 +835,19 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
impl Parse for SpecifiedValue {
|
||||
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||
use cssparser::Token;
|
||||
use properties::CSSWideKeyword;
|
||||
use std::ascii::AsciiExt;
|
||||
use values::CustomIdent;
|
||||
|
||||
let atom = match input.next() {
|
||||
Ok(Token::Ident(ref value)) => {
|
||||
if CSSWideKeyword::from_ident(value).is_some() {
|
||||
// We allow any ident for the animation-name except one
|
||||
// of the CSS-wide keywords.
|
||||
return Err(());
|
||||
} else if value.eq_ignore_ascii_case("none") {
|
||||
Ok(Token::Ident(value)) => {
|
||||
if value.eq_ignore_ascii_case("none") {
|
||||
// FIXME We may want to support `@keyframes ""` at some point.
|
||||
atom!("")
|
||||
CustomIdent(atom!(""))
|
||||
} else {
|
||||
Atom::from(&**value)
|
||||
CustomIdent::from_ident(value, &[])?
|
||||
}
|
||||
}
|
||||
Ok(Token::QuotedString(value)) => Atom::from(&*value),
|
||||
Ok(Token::QuotedString(value)) => CustomIdent(Atom::from(value)),
|
||||
_ => return Err(()),
|
||||
};
|
||||
Ok(SpecifiedValue(atom))
|
||||
|
|
|
@ -1617,7 +1617,7 @@ pub mod style_structs {
|
|||
/// Returns whether there is any animation specified with
|
||||
/// animation-name other than `none`.
|
||||
pub fn specifies_animations(&self) -> bool {
|
||||
self.animation_name_iter().any(|name| name.0 != atom!(""))
|
||||
self.animation_name_iter().any(|name| name.0 .0 != atom!(""))
|
||||
}
|
||||
|
||||
/// Returns whether there are any transitions specified.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue