Bug 1364799 - Create a SequentialTask for updating CSS animations in the case where the traversal is triggered by CSS rule changes. r?birtles
MozReview-Commit-ID: INAnXiNimsJ
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -614,29 +614,33 @@ trait PrivateMatchMethods: TElement {
&context.thread_local.font_metrics_provider,
&without_transition_rules,
primary_style,
InheritMode::Normal))
}
#[cfg(feature = "gecko")]
fn needs_animations_update(&self,
+ context: &mut StyleContext<Self>,
old_values: Option<&Arc<ComputedValues>>,
new_values: &ComputedValues)
-> bool {
let new_box_style = new_values.get_box();
let has_new_animation_style = new_box_style.animation_name_count() >= 1 &&
new_box_style.animation_name_at(0).0.is_some();
let has_animations = self.has_css_animations();
old_values.map_or(has_new_animation_style, |old| {
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();
- // FIXME: Bug 1344581: We still need to compare keyframe rules.
+
+ // If the traverse is triggered by CSS rule changes,
+ // we need to try to update all CSS animations.
+ context.shared.traversal_flags.for_css_rule_changes() ||
!old_box_style.animations_equals(&new_box_style) ||
(old_display_style == display::T::none &&
new_display_style != display::T::none &&
has_new_animation_style) ||
(old_display_style != display::T::none &&
new_display_style == display::T::none &&
has_animations)
})
@@ -647,17 +651,17 @@ trait PrivateMatchMethods: TElement {
context: &mut StyleContext<Self>,
old_values: &mut Option<Arc<ComputedValues>>,
new_values: &mut Arc<ComputedValues>,
primary_style: &ComputedStyle) {
use context::{CSS_ANIMATIONS, CSS_TRANSITIONS, EFFECT_PROPERTIES};
use context::UpdateAnimationsTasks;
let mut tasks = UpdateAnimationsTasks::empty();
- if self.needs_animations_update(old_values.as_ref(), new_values) {
+ if self.needs_animations_update(context, old_values.as_ref(), new_values) {
tasks.insert(CSS_ANIMATIONS);
}
let before_change_style = if self.might_need_transitions_update(old_values.as_ref().map(|s| &**s),
new_values) {
let after_change_style = if self.has_css_transitions() {
self.get_after_change_style(context, primary_style)
} else {