style: Refactor the @keyframes parsing and add adequate computation for it.

This commit is contained in:
Emilio Cobos Álvarez 2016-06-18 15:04:16 +02:00
parent 6a362ae8e8
commit 058bfb39ae
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 103 additions and 43 deletions

View file

@ -8,7 +8,7 @@ use dom::PresentationalHintsSynthetizer;
use element_state::*;
use error_reporting::StdoutErrorReporter;
use keyframes::Keyframe;
use keyframes::ComputedKeyframesAnimation;
use keyframes::KeyframesAnimation;
use media_queries::{Device, MediaType};
use parser::ParserContextExtraData;
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock};
@ -129,7 +129,7 @@ pub struct Stylist<Impl: SelectorImplExt> {
BuildHasherDefault<::fnv::FnvHasher>>,
/// A map with all the animations indexed by name.
animations: HashMap<String, ComputedKeyframesAnimation<Impl::ComputedValues>>,
animations: HashMap<String, KeyframesAnimation>,
/// Applicable declarations for a given non-eagerly cascaded pseudo-element.
/// These are eagerly computed once, and then used to resolve the new
@ -253,9 +253,11 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
self.rules_source_order = rules_source_order;
}
CSSRule::Keyframes(ref keyframes_rule) => {
if let Some(computed) = ComputedKeyframesAnimation::from_keyframes(&keyframes_rule.keyframes) {
debug!("Found valid keyframes rule: {:?}", keyframes_rule);
if let Some(animation) = KeyframesAnimation::from_keyframes(&keyframes_rule.keyframes) {
debug!("Found valid keyframe animation: {:?}", animation);
self.animations.insert(keyframes_rule.name.clone(),
computed);
animation);
}
}
// We don't care about any other rule.
@ -459,7 +461,7 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
}
#[inline]
pub fn animations(&self) -> &HashMap<String, ComputedKeyframesAnimation<Impl::ComputedValues>> {
pub fn animations(&self) -> &HashMap<String, KeyframesAnimation> {
&self.animations
}
}