mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Auto merge of #20098 - servo:spurious-raf-optim, r=pcwalton
Avoid dropping arbitrary animation callbacks without running them <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20098) <!-- Reviewable:end -->
This commit is contained in:
commit
cccca27f4f
1 changed files with 12 additions and 4 deletions
|
@ -1485,10 +1485,18 @@ impl Document {
|
||||||
// constellation to stop giving us video refresh callbacks, to save energy. (A spurious
|
// constellation to stop giving us video refresh callbacks, to save energy. (A spurious
|
||||||
// animation frame is one in which the callback did not mutate the DOM—that is, an
|
// animation frame is one in which the callback did not mutate the DOM—that is, an
|
||||||
// animation frame that wasn't actually used for animation.)
|
// animation frame that wasn't actually used for animation.)
|
||||||
if self.animation_frame_list.borrow().is_empty() ||
|
let is_empty = self.animation_frame_list.borrow().is_empty();
|
||||||
(!was_faking_animation_frames && self.is_faking_animation_frames()) {
|
if is_empty || (!was_faking_animation_frames && self.is_faking_animation_frames()) {
|
||||||
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
|
if is_empty {
|
||||||
&mut *animation_frame_list);
|
// If the current animation frame list in the DOM instance is empty,
|
||||||
|
// we can reuse the original `Vec<T>` that we put on the stack to
|
||||||
|
// avoid allocating a new one next time an animation callback
|
||||||
|
// is queued.
|
||||||
|
mem::swap(
|
||||||
|
&mut *self.animation_frame_list.borrow_mut(),
|
||||||
|
&mut *animation_frame_list,
|
||||||
|
);
|
||||||
|
}
|
||||||
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::NoAnimationCallbacksPresent);
|
let event = ScriptMsg::ChangeRunningAnimationsState(AnimationState::NoAnimationCallbacksPresent);
|
||||||
self.send_to_constellation(event);
|
self.send_to_constellation(event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue