diff --git a/components/style/matching.rs b/components/style/matching.rs index 63165927a8a..939af246c3e 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -589,12 +589,14 @@ pub trait MatchMethods : TElement { let mut applicable_declarations: Vec = Vec::with_capacity(16); let stylist = &context.shared.stylist; let style_attribute = self.style_attribute(); + let animation_rule = self.get_animation_rule(None); // Compute the primary rule node. let mut primary_relations = stylist.push_applicable_declarations(self, parent_bf, style_attribute, + animation_rule, None, &mut applicable_declarations, MatchingReason::ForStyling); @@ -604,7 +606,9 @@ pub trait MatchMethods : TElement { let mut per_pseudo: PseudoRuleNodes = HashMap::with_hasher(Default::default()); SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| { debug_assert!(applicable_declarations.is_empty()); + let pseudo_animation_rule = self.get_animation_rule(Some(&pseudo)); stylist.push_applicable_declarations(self, parent_bf, None, + pseudo_animation_rule, Some(&pseudo.clone()), &mut applicable_declarations, MatchingReason::ForStyling); diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 27ffea363d1..3d1291788f0 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -21,6 +21,7 @@ use rule_tree::{RuleTree, StrongRuleNode, StyleSource}; use selector_parser::{ElementExt, SelectorImpl, PseudoElement, Snapshot}; use selectors::Element; use selectors::bloom::BloomFilter; +use selectors::matching::AFFECTED_BY_ANIMATIONS; use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS}; use selectors::matching::{MatchingReason, StyleRelations, matches_complex_selector}; use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector}; @@ -384,6 +385,7 @@ impl Stylist { let mut declarations = vec![]; self.push_applicable_declarations(element, + None, None, None, Some(pseudo), @@ -490,6 +492,7 @@ impl Stylist { element: &E, parent_bf: Option<&BloomFilter>, style_attribute: Option<&Arc>>, + animation_rule: Option>>, pseudo_element: Option<&PseudoElement>, applicable_declarations: &mut V, reason: MatchingReason) -> StyleRelations @@ -560,7 +563,16 @@ impl Stylist { debug!("style attr: {:?}", relations); - // Step 5: Author-supplied `!important` rules. + // Step 5: Animations. + if let Some(anim) = animation_rule { + relations |= AFFECTED_BY_ANIMATIONS; + Push::push( + applicable_declarations, + ApplicableDeclarationBlock::from_declarations(anim.clone(), Importance::Normal)); + } + debug!("animation: {:?}", relations); + + // Step 6: Author-supplied `!important` rules. map.author.get_all_matching_rules(element, parent_bf, applicable_declarations, @@ -570,7 +582,7 @@ impl Stylist { debug!("author important: {:?}", relations); - // Step 6: `!important` style attributes. + // Step 7: `!important` style attributes. if let Some(sa) = style_attribute { if sa.read().any_important() { relations |= AFFECTED_BY_STYLE_ATTRIBUTE; @@ -582,7 +594,7 @@ impl Stylist { debug!("style attr important: {:?}", relations); - // Step 7: User `!important` rules. + // Step 8: User `!important` rules. map.user.get_all_matching_rules(element, parent_bf, applicable_declarations, @@ -595,7 +607,7 @@ impl Stylist { debug!("skipping non-agent rules"); } - // Step 8: UA `!important` rules. + // Step 9: UA `!important` rules. map.user_agent.get_all_matching_rules(element, parent_bf, applicable_declarations,