mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Atomize animation names.
This commit is contained in:
parent
0077eb147c
commit
5b27e46d04
4 changed files with 12 additions and 9 deletions
|
@ -235,7 +235,7 @@ pub fn maybe_start_animations<Impl: SelectorImplExt>(context: &SharedStyleContex
|
|||
}
|
||||
|
||||
// TODO: This should be factored out, too much indentation.
|
||||
if let Some(ref animation) = context.stylist.animations().get(&**name) {
|
||||
if let Some(ref animation) = context.stylist.animations().get(&name) {
|
||||
debug!("maybe_start_animations: found animation {}", name);
|
||||
had_animations = true;
|
||||
let mut last_keyframe_style = compute_style_for_animation_step(context,
|
||||
|
|
|
@ -589,9 +589,10 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
|||
pub mod computed_value {
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use string_cache::Atom;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
|
||||
pub struct T(pub Vec<String>);
|
||||
pub struct T(pub Vec<Atom>);
|
||||
|
||||
impl ToCss for T {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
|
@ -603,7 +604,8 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
|||
if i != 0 {
|
||||
try!(dest.write_str(", "));
|
||||
}
|
||||
try!(dest.write_str(&name));
|
||||
// NB: to_string() needed due to geckolib backend.
|
||||
try!(dest.write_str(&*name.to_string()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -620,7 +622,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", need_clone=
|
|||
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
|
||||
use std::borrow::Cow;
|
||||
Ok(SpecifiedValue(try!(input.parse_comma_separated(|input| {
|
||||
input.expect_ident().map(Cow::into_owned)
|
||||
input.expect_ident().map(Atom::from)
|
||||
}))))
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ use std::collections::HashMap;
|
|||
use std::hash::BuildHasherDefault;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use string_cache::Atom;
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylesheets::{CSSRule, CSSRuleIteratorExt, Origin, Stylesheet};
|
||||
use url::Url;
|
||||
|
@ -129,7 +130,7 @@ pub struct Stylist<Impl: SelectorImplExt> {
|
|||
BuildHasherDefault<::fnv::FnvHasher>>,
|
||||
|
||||
/// A map with all the animations indexed by name.
|
||||
animations: HashMap<String, KeyframesAnimation>,
|
||||
animations: HashMap<Atom, KeyframesAnimation>,
|
||||
|
||||
/// Applicable declarations for a given non-eagerly cascaded pseudo-element.
|
||||
/// These are eagerly computed once, and then used to resolve the new
|
||||
|
@ -461,7 +462,7 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn animations(&self) -> &HashMap<String, KeyframesAnimation> {
|
||||
pub fn animations(&self) -> &HashMap<Atom, KeyframesAnimation> {
|
||||
&self.animations
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ pub enum CSSRule<Impl: SelectorImpl> {
|
|||
|
||||
#[derive(Debug, HeapSizeOf, PartialEq)]
|
||||
pub struct KeyframesRule {
|
||||
pub name: String,
|
||||
pub name: Atom,
|
||||
pub keyframes: Vec<Keyframe>,
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ enum AtRulePrelude {
|
|||
/// A @viewport rule prelude.
|
||||
Viewport,
|
||||
/// A @keyframes rule, with its animation name.
|
||||
Keyframes(String),
|
||||
Keyframes(Atom),
|
||||
}
|
||||
|
||||
|
||||
|
@ -507,7 +507,7 @@ impl<'a, 'b, Impl: SelectorImpl> AtRuleParser for NestedRuleParser<'a, 'b, Impl>
|
|||
},
|
||||
"keyframes" => {
|
||||
let name = try!(input.expect_ident());
|
||||
Ok(AtRuleType::WithBlock(AtRulePrelude::Keyframes(name.into_owned())))
|
||||
Ok(AtRuleType::WithBlock(AtRulePrelude::Keyframes(Atom::from(name))))
|
||||
},
|
||||
_ => Err(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue