From c2961c94b49a401d647e3f10cf04cd74aa7287c8 Mon Sep 17 00:00:00 2001 From: Pawel Kondzior Date: Thu, 19 Feb 2015 11:20:55 +0700 Subject: Add thaw/freeze messages that can suspend/resume webcontent timers #4907 --- components/script/script_task.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 8573efa9d3f..fa397113c9b 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -602,6 +602,10 @@ impl ScriptTask { panic!("should have handled ExitPipeline already"), ConstellationControlMsg::GetTitle(pipeline_id) => self.handle_get_title_msg(pipeline_id), + ConstellationControlMsg::Freeze(pipeline_id) => + self.handle_freeze_msg(pipeline_id), + ConstellationControlMsg::Thaw(pipeline_id) => + self.handle_thaw_msg(pipeline_id) } } @@ -685,6 +689,26 @@ impl ScriptTask { window.r().handle_fire_timer(timer_id); } + /// Handles freeze message + fn handle_freeze_msg(&self, id: PipelineId) { + let page = self.page.borrow_mut(); + let page = page.find(id).expect("ScriptTask: received freeze msg for a + pipeline ID not associated with this script task. This is a bug."); + let frame = page.frame(); + let window = frame.as_ref().unwrap().window.root(); + window.r().freeze(); + } + + /// Handles thaw message + fn handle_thaw_msg(&self, id: PipelineId) { + let page = self.page.borrow_mut(); + let page = page.find(id).expect("ScriptTask: received thaw msg for a + pipeline ID not associated with this script task. This is a bug."); + let frame = page.frame(); + let window = frame.as_ref().unwrap().window.root(); + window.r().thaw(); + } + /// Handles a notification that reflow completed. fn handle_reflow_complete_msg(&self, pipeline_id: PipelineId, reflow_id: uint) { debug!("Script: Reflow {:?} complete for {:?}", reflow_id, pipeline_id); -- cgit v1.2.3