mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
Cache animation computed values when animations change
Instead of recalculating the animation style every tick of an animation, cache the computed values when animations change. In addition to being more efficient, this will allow us to return animation rules as property declarations because we don't need to consult the final style to produce them.
This commit is contained in:
parent
7df4655b60
commit
83fa1b9eaa
9 changed files with 246 additions and 169 deletions
|
@ -2828,10 +2828,27 @@ pub mod style_structs {
|
|||
/// Returns whether there are any transitions specified.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn specifies_transitions(&self) -> bool {
|
||||
// TODO(mrobinson): This should check the combined duration and not just
|
||||
// the duration.
|
||||
self.transition_duration_iter()
|
||||
.take(self.transition_property_count())
|
||||
.any(|t| t.seconds() > 0.)
|
||||
}
|
||||
|
||||
/// Returns true if animation properties are equal between styles, but without
|
||||
/// considering keyframe data.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn animations_equals(&self, other: &Self) -> bool {
|
||||
self.animation_name_iter().eq(other.animation_name_iter()) &&
|
||||
self.animation_delay_iter().eq(other.animation_delay_iter()) &&
|
||||
self.animation_direction_iter().eq(other.animation_direction_iter()) &&
|
||||
self.animation_duration_iter().eq(other.animation_duration_iter()) &&
|
||||
self.animation_fill_mode_iter().eq(other.animation_fill_mode_iter()) &&
|
||||
self.animation_iteration_count_iter().eq(other.animation_iteration_count_iter()) &&
|
||||
self.animation_play_state_iter().eq(other.animation_play_state_iter()) &&
|
||||
self.animation_timing_function_iter().eq(other.animation_timing_function_iter())
|
||||
}
|
||||
|
||||
% elif style_struct.name == "Column":
|
||||
/// Whether this is a multicol style.
|
||||
#[cfg(feature = "servo")]
|
||||
|
@ -2924,6 +2941,12 @@ impl ComputedValues {
|
|||
self.pseudo.as_ref()
|
||||
}
|
||||
|
||||
/// Returns true if this is the style for a pseudo-element.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn is_pseudo_style(&self) -> bool {
|
||||
self.pseudo().is_some()
|
||||
}
|
||||
|
||||
/// Returns whether this style's display value is equal to contents.
|
||||
pub fn is_display_contents(&self) -> bool {
|
||||
self.get_box().clone_display().is_contents()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue