Add has_current_styles_for_traversal().

In animation-only restyle, we just need to check the element
has animation restyle hints or has recascade self which is a result
of animation-only restyle for ancestors.
has_current_styles() in Servo_ResolveStyle() is intentionally left there,
it will be changed in a subsequent patch.
This commit is contained in:
Hiroyuki Ikezoe 2017-07-18 19:13:48 +09:00
parent ae55e51aaf
commit f91126ba86
4 changed files with 37 additions and 7 deletions

View file

@ -33,6 +33,7 @@ use std::ops::Deref;
use stylearc::{Arc, ArcBorrow};
use stylist::Stylist;
use thread_state;
use traversal::TraversalFlags;
pub use style_traits::UnsafeNode;
@ -478,6 +479,29 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
data.has_styles() && !data.has_invalidations()
}
/// Returns whether the element's styles are up-to-date for |traversal_flags|.
fn has_current_styles_for_traversal(&self,
data: &ElementData,
traversal_flags: TraversalFlags) -> bool {
if traversal_flags.for_animation_only() {
// In animation-only restyle we never touch snapshots and don't
// care about them. But we can't assert '!self.handled_snapshot()'
// here since there are some cases that a second animation-only
// restyle which is a result of normal restyle (e.g. setting
// animation-name in normal restyle and creating a new CSS
// animation in a SequentialTask) is processed after the normal
// traversal in that we had elements that handled snapshot.
return data.has_styles() &&
!data.restyle.hint.has_animation_hint_or_recascade();
}
if self.has_snapshot() && !self.handled_snapshot() {
return false;
}
data.has_styles() && !data.has_invalidations()
}
/// Flags an element and its ancestors with a given `DescendantsBit`.
///
/// TODO(emilio): We call this conservatively from restyle_element_internal