diff options
author | Glenn Watson <gw@intuitionlibrary.com> | 2016-01-22 16:00:13 +1000 |
---|---|---|
committer | Glenn Watson <gw@intuitionlibrary.com> | 2016-01-22 16:08:28 +1000 |
commit | dfaf28d5cdc2577271c09874b23bed784483a4d8 (patch) | |
tree | eb2ddb5211ea1a85ae66c469b7207ff3c36b5698 /components/script/dom | |
parent | 1c6fb0f04e0cf305f4e1f75371be84944b1e5518 (diff) | |
download | servo-dfaf28d5cdc2577271c09874b23bed784483a4d8.tar.gz servo-dfaf28d5cdc2577271c09874b23bed784483a4d8.zip |
Fixes additional calls to rAF.
Often, a rAF callback will request another rAF from the callback itself.
Previously, the constellation would quickly receive two messages saying
that there were no animations, and then there are animations again in the
situation above. This would make the compositor tick the new animation straight
away, causing strange fluctuations and timings in rAF callbacks.
Instead, only send the NoAnimationCallbacks message if the animation
callback queue is still empty after invoking the callbacks.
This fixes rAF timing, which now runs at the correct (vsync) framerate.
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/document.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index b6e1ce8bde0..9edc7bb9c35 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1199,11 +1199,6 @@ impl Document { { let mut list = self.animation_frame_list.borrow_mut(); animation_frame_list = Vec::from_iter(list.drain()); - - let ConstellationChan(ref chan) = self.window.constellation_chan(); - let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(), - AnimationState::NoAnimationCallbacksPresent); - chan.send(event).unwrap(); } let performance = self.window.Performance(); let performance = performance.r(); @@ -1213,6 +1208,13 @@ impl Document { callback(*timing); } + if self.animation_frame_list.borrow().is_empty() { + let ConstellationChan(ref chan) = self.window.constellation_chan(); + let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(), + AnimationState::NoAnimationCallbacksPresent); + chan.send(event).unwrap(); + } + self.window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::RequestAnimationFrame); |