Factor out restyle_kind_for_animation.

This commit is contained in:
Hiroyuki Ikezoe 2017-07-18 19:13:22 +09:00
parent 7b134440fc
commit ae55e51aaf

View file

@ -278,25 +278,17 @@ impl ElementData {
pub fn restyle_kind(&self, pub fn restyle_kind(&self,
shared_context: &SharedStyleContext) shared_context: &SharedStyleContext)
-> RestyleKind { -> RestyleKind {
if shared_context.traversal_flags.for_animation_only() {
return self.restyle_kind_for_animation(shared_context);
}
debug_assert!(!self.has_styles() || self.has_invalidations(), debug_assert!(!self.has_styles() || self.has_invalidations(),
"Should've stopped earlier"); "Should've stopped earlier");
if !self.has_styles() { if !self.has_styles() {
debug_assert!(!shared_context.traversal_flags.for_animation_only(),
"Unstyled element shouldn't be traversed during \
animation-only traversal");
return RestyleKind::MatchAndCascade; return RestyleKind::MatchAndCascade;
} }
let hint = self.restyle.hint; let hint = self.restyle.hint;
if shared_context.traversal_flags.for_animation_only() {
// return either CascadeWithReplacements or CascadeOnly in case of
// animation-only restyle.
if hint.has_animation_hint() {
return RestyleKind::CascadeWithReplacements(hint & RestyleHint::for_animations());
}
return RestyleKind::CascadeOnly;
}
if hint.match_self() { if hint.match_self() {
return RestyleKind::MatchAndCascade; return RestyleKind::MatchAndCascade;
} }
@ -312,6 +304,26 @@ impl ElementData {
return RestyleKind::CascadeOnly; return RestyleKind::CascadeOnly;
} }
/// Returns the kind of restyling for animation-only restyle.
pub fn restyle_kind_for_animation(&self,
shared_context: &SharedStyleContext)
-> RestyleKind {
debug_assert!(shared_context.traversal_flags.for_animation_only());
debug_assert!(self.has_styles(),
"Unstyled element shouldn't be traversed during \
animation-only traversal");
// return either CascadeWithReplacements or CascadeOnly in case of
// animation-only restyle. I.e. animation-only restyle never does
// selector matching.
let hint = self.restyle.hint;
if hint.has_animation_hint() {
return RestyleKind::CascadeWithReplacements(hint & RestyleHint::for_animations());
}
return RestyleKind::CascadeOnly;
}
/// Return true if important rules are different. /// Return true if important rules are different.
/// We use this to make sure the cascade of off-main thread animations is correct. /// We use this to make sure the cascade of off-main thread animations is correct.
/// Note: Ignore custom properties for now because we only support opacity and transform /// Note: Ignore custom properties for now because we only support opacity and transform