From 9695e097077f29bd44ae0cd3faa0cf35ab9e4ef6 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 27 Mar 2015 19:01:54 -0700 Subject: script: Squash mouse-move events just like resizes. Otherwise they queue up if the event handler isn't 60FPS. --- components/script/script_task.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index e5463285200..c289a0576dc 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -574,13 +574,15 @@ impl ScriptTask { } }; - // Squash any pending resize and reflow events in the queue. + // Squash any pending resize, reflow, and mouse-move events in the queue. + let mut mouse_move_event_index = None; loop { match event { // This has to be handled before the ResizeMsg below, // otherwise the page may not have been added to the // child list yet, causing the find() to fail. - MixedMessage::FromConstellation(ConstellationControlMsg::AttachLayout(new_layout_info)) => { + MixedMessage::FromConstellation(ConstellationControlMsg::AttachLayout( + new_layout_info)) => { self.handle_new_layout(new_layout_info); } MixedMessage::FromConstellation(ConstellationControlMsg::Resize(id, size)) => { @@ -589,6 +591,19 @@ impl ScriptTask { MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => { self.handle_viewport(id, rect); } + MixedMessage::FromConstellation(ConstellationControlMsg::SendEvent( + _, + MouseMoveEvent(_))) => { + match mouse_move_event_index { + None => { + mouse_move_event_index = Some(sequential.len()); + sequential.push(event); + } + Some(index) => { + sequential[index] = event + } + } + } _ => { sequential.push(event); } -- cgit v1.2.3