Skip to content

Commit

Permalink
Add restyle hint for SMIL animations
Browse files Browse the repository at this point in the history
  • Loading branch information
birtles committed Apr 27, 2017
1 parent ba118df commit af9c7fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 11 additions & 4 deletions components/style/matching.rs
Expand Up @@ -19,7 +19,8 @@ use dom::{AnimationRules, SendElement, TElement, TNode};
use font_metrics::FontMetricsProvider;
use properties::{CascadeFlags, ComputedValues, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, cascade};
use properties::longhands::display::computed_value as display;
use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleHint};
use restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleHint};
use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_SMIL};
use rule_tree::{CascadeLevel, RuleTree, StrongRuleNode};
use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
use selectors::bloom::BloomFilter;
Expand Down Expand Up @@ -1072,12 +1073,18 @@ pub trait MatchMethods : TElement {
}
};

// RESTYLE_CSS_ANIMATIONS or RESTYLE_CSS_TRANSITIONS is processed prior to other
// restyle hints in the name of animation-only traversal. Rest of restyle hints
// will be processed in a subsequent normal traversal.
// Animation restyle hints are processed prior to other restyle hints in the
// animation-only traversal. Non-animation restyle hints will be processed in
// a subsequent normal traversal.
if hint.intersects(RestyleHint::for_animations()) {
debug_assert!(context.shared.traversal_flags.for_animation_only());

if hint.contains(RESTYLE_SMIL) {
replace_rule_node(CascadeLevel::SMILOverride,
self.get_smil_override(),
primary_rules);
}

use data::EagerPseudoStyles;
let mut replace_rule_node_for_animation = |level: CascadeLevel,
primary_rules: &mut StrongRuleNode,
Expand Down
12 changes: 10 additions & 2 deletions components/style/restyle_hints.rs
Expand Up @@ -62,6 +62,11 @@ bitflags! {
/// attribute has changed, and this change didn't have any other
/// dependencies.
const RESTYLE_STYLE_ATTRIBUTE = 0x40,

/// Replace the style data coming from SMIL animations without updating
/// any other style data. This hint is only processed in animation-only
/// traversal which is prior to normal traversal.
const RESTYLE_SMIL = 0x80,
}
}

Expand Down Expand Up @@ -95,19 +100,22 @@ pub fn assert_restyle_hints_match() {
nsRestyleHint_eRestyle_CSSTransitions => RESTYLE_CSS_TRANSITIONS,
nsRestyleHint_eRestyle_CSSAnimations => RESTYLE_CSS_ANIMATIONS,
nsRestyleHint_eRestyle_StyleAttribute => RESTYLE_STYLE_ATTRIBUTE,
nsRestyleHint_eRestyle_StyleAttribute_Animations => RESTYLE_SMIL,
}
}

impl RestyleHint {
/// The subset hints that affect the styling of a single element during the
/// traversal.
#[inline]
pub fn for_self() -> Self {
RESTYLE_SELF | RESTYLE_STYLE_ATTRIBUTE | RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS
RESTYLE_SELF | RESTYLE_STYLE_ATTRIBUTE | Self::for_animations()
}

/// The subset hints that are used for animation restyle.
#[inline]
pub fn for_animations() -> Self {
RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS
RESTYLE_SMIL | RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS
}
}

Expand Down

0 comments on commit af9c7fc

Please sign in to comment.