Skip to content

Commit

Permalink
Bug 1341372 - Part 3: Factor out need_update_animations.
Browse files Browse the repository at this point in the history
We will add another function, needs_update_transitions, to check if we need
to update transitions, so factor this out.

MozReview-Commit-ID: 5LYkyi4aDri
  • Loading branch information
BorisChiou committed Apr 17, 2017
1 parent b1476f1 commit 145e1b6
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions components/style/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,31 @@ trait PrivateMatchMethods: TElement {
pseudo_style.is_some())
}

#[cfg(feature = "gecko")]
fn needs_update_animations(&self,
old_values: &Option<Arc<ComputedValues>>,
new_values: &Arc<ComputedValues>,
pseudo: Option<&PseudoElement>) -> bool {
let ref 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.len() != 0;
let has_animations = self.has_css_animations(pseudo);

old_values.as_ref().map_or(has_new_animation_style, |ref old| {
let ref 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.
!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)
})
}

#[cfg(feature = "gecko")]
fn process_animations(&self,
context: &mut StyleContext<Self>,
Expand All @@ -533,27 +558,8 @@ trait PrivateMatchMethods: TElement {
use context::{CSS_ANIMATIONS, EFFECT_PROPERTIES};
use context::UpdateAnimationsTasks;

let ref 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.len() != 0;
let has_animations = self.has_css_animations(pseudo);

let mut tasks = UpdateAnimationsTasks::empty();
let needs_update_animations =
old_values.as_ref().map_or(has_new_animation_style, |ref old| {
let ref 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.
!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)
});
if needs_update_animations {
if self.needs_update_animations(old_values, new_values, pseudo) {
tasks.insert(CSS_ANIMATIONS);
}
if self.has_animations(pseudo) {
Expand Down

0 comments on commit 145e1b6

Please sign in to comment.