mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: return early in needs_animations_update.
This commit is contained in:
parent
e5bd8fc5d8
commit
e30a4d2ad2
1 changed files with 26 additions and 23 deletions
|
@ -227,34 +227,37 @@ trait PrivateMatchMethods: TElement {
|
||||||
fn needs_animations_update(
|
fn needs_animations_update(
|
||||||
&self,
|
&self,
|
||||||
context: &mut StyleContext<Self>,
|
context: &mut StyleContext<Self>,
|
||||||
old_values: Option<&Arc<ComputedValues>>,
|
old_values: Option<&ComputedValues>,
|
||||||
new_values: &ComputedValues,
|
new_values: &ComputedValues,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let new_box_style = new_values.get_box();
|
let new_box_style = new_values.get_box();
|
||||||
let has_new_animation_style = new_box_style.specifies_animations();
|
let has_new_animation_style = new_box_style.specifies_animations();
|
||||||
|
|
||||||
|
let old = match old_values {
|
||||||
|
Some(old) => old,
|
||||||
|
None => return has_new_animation_style,
|
||||||
|
};
|
||||||
|
|
||||||
let has_animations = self.has_css_animations();
|
let has_animations = self.has_css_animations();
|
||||||
|
let old_box_style = old.get_box();
|
||||||
|
let old_display_style = old_box_style.clone_display();
|
||||||
|
let new_display_style = new_box_style.clone_display();
|
||||||
|
|
||||||
old_values.map_or(has_new_animation_style, |old| {
|
// If the traverse is triggered by CSS rule changes, we need to
|
||||||
let old_box_style = old.get_box();
|
// try to update all CSS animations on the element if the element
|
||||||
let old_display_style = old_box_style.clone_display();
|
// has or will have CSS animation style regardless of whether the
|
||||||
let new_display_style = new_box_style.clone_display();
|
// animation is running or not.
|
||||||
|
// TODO: We should check which @keyframes changed/added/deleted
|
||||||
// If the traverse is triggered by CSS rule changes, we need to
|
// and update only animations corresponding to those @keyframes.
|
||||||
// try to update all CSS animations on the element if the element
|
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) &&
|
||||||
// has or will have CSS animation style regardless of whether the
|
(has_new_animation_style || has_animations)) ||
|
||||||
// animation is running or not.
|
!old_box_style.animations_equals(new_box_style) ||
|
||||||
// TODO: We should check which @keyframes changed/added/deleted
|
(old_display_style == Display::None &&
|
||||||
// and update only animations corresponding to those @keyframes.
|
new_display_style != Display::None &&
|
||||||
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) &&
|
has_new_animation_style) ||
|
||||||
(has_new_animation_style || has_animations)) ||
|
(old_display_style != Display::None &&
|
||||||
!old_box_style.animations_equals(new_box_style) ||
|
new_display_style == Display::None &&
|
||||||
(old_display_style == Display::None &&
|
has_animations)
|
||||||
new_display_style != Display::None &&
|
|
||||||
has_new_animation_style) ||
|
|
||||||
(old_display_style != Display::None &&
|
|
||||||
new_display_style == Display::None &&
|
|
||||||
has_animations)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a SequentialTask for resolving descendants in a SMIL display property
|
/// Create a SequentialTask for resolving descendants in a SMIL display property
|
||||||
|
@ -313,7 +316,7 @@ trait PrivateMatchMethods: TElement {
|
||||||
// in addition to the unvisited styles.
|
// in addition to the unvisited styles.
|
||||||
|
|
||||||
let mut tasks = UpdateAnimationsTasks::empty();
|
let mut tasks = UpdateAnimationsTasks::empty();
|
||||||
if self.needs_animations_update(context, old_values.as_ref(), new_values) {
|
if self.needs_animations_update(context, old_values.as_ref().map(|s| &**s), new_values) {
|
||||||
tasks.insert(UpdateAnimationsTasks::CSS_ANIMATIONS);
|
tasks.insert(UpdateAnimationsTasks::CSS_ANIMATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue