servo: Merge #6841 - script: Squash duplicate animation tick events in the queue (from pcwalton:squash-animation-ticks); r=metajack

This prevents them from piling up endlessly if the JS
`requestAnimationFrame()` callback takes a long time to complete.

r? @jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 12c46ddd6131533454e353fa8fdd8cb4b517ffd0
This commit is contained in:
Patrick Walton 2015-07-30 00:04:17 -06:00
Родитель d73aab0b4c
Коммит 1eb9c7fff1
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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(_))) => {