mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Factor out restyle_kind_for_animation.
This commit is contained in:
parent
7b134440fc
commit
ae55e51aaf
1 changed files with 24 additions and 12 deletions
|
@ -278,25 +278,17 @@ impl ElementData {
|
|||
pub fn restyle_kind(&self,
|
||||
shared_context: &SharedStyleContext)
|
||||
-> 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(),
|
||||
"Should've stopped earlier");
|
||||
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;
|
||||
}
|
||||
|
||||
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() {
|
||||
return RestyleKind::MatchAndCascade;
|
||||
}
|
||||
|
@ -312,6 +304,26 @@ impl ElementData {
|
|||
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.
|
||||
/// 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue