aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-07-29 17:31:22 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-07-29 17:32:21 -0700
commit01e5c513a9d3259f978a1c4027057d96fc319663 (patch)
treed03f8553559d541ba7b0ad8c564853689681d533 /components/script/script_task.rs
parent8b7120012a5f5eed71236fcf5d546ae76837ea11 (diff)
downloadservo-01e5c513a9d3259f978a1c4027057d96fc319663.tar.gz
servo-01e5c513a9d3259f978a1c4027057d96fc319663.zip
script: Squash duplicate animation tick events in the queue.
This prevents them from piling up endlessly if the JS `requestAnimationFrame()` callback takes a long time to complete.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index d9560e40911..0e09dde70cc 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -665,8 +665,9 @@ impl ScriptTask {
}
};
- // Squash any pending resize, reflow, and mouse-move events in the queue.
+ // Squash any pending resize, reflow, animation tick, and mouse-move events in the queue.
let mut mouse_move_event_index = None;
+ let mut animation_ticks = HashSet::new();
loop {
match event {
// This has to be handled before the ResizeMsg below,
@@ -682,6 +683,13 @@ impl ScriptTask {
MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
self.handle_viewport(id, rect);
}
+ MixedMessage::FromConstellation(ConstellationControlMsg::TickAllAnimations(
+ pipeline_id)) => {
+ if !animation_ticks.contains(&pipeline_id) {
+ animation_ticks.insert(pipeline_id);
+ sequential.push(event);
+ }
+ }
MixedMessage::FromConstellation(ConstellationControlMsg::SendEvent(
_,
MouseMoveEvent(_))) => {