mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
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.
This commit is contained in:
parent
8b7120012a
commit
01e5c513a9
1 changed files with 9 additions and 1 deletions
|
@ -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 mouse_move_event_index = None;
|
||||||
|
let mut animation_ticks = HashSet::new();
|
||||||
loop {
|
loop {
|
||||||
match event {
|
match event {
|
||||||
// This has to be handled before the ResizeMsg below,
|
// This has to be handled before the ResizeMsg below,
|
||||||
|
@ -682,6 +683,13 @@ impl ScriptTask {
|
||||||
MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
|
MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
|
||||||
self.handle_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(
|
MixedMessage::FromConstellation(ConstellationControlMsg::SendEvent(
|
||||||
_,
|
_,
|
||||||
MouseMoveEvent(_))) => {
|
MouseMoveEvent(_))) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue