auto merge of #4960 : pkondzior/servo/add-script-timers-suspend-resume-functionality, r=jdm

Adds free/thaw methods to script_task that let you send suspend/resume messages to web content timers. Fixes #4907
This commit is contained in:
bors-servo 2015-02-23 21:45:46 -07:00
commit a3ea3eed47
6 changed files with 105 additions and 9 deletions

View file

@ -834,6 +834,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
pipeline.clone(),
parent.borrow().clone())),
NavigationType::Load);
// Send message to ScriptTask that will suspend all timers
source_frame.pipeline.borrow().freeze();
self.pipelines.insert(pipeline.id, pipeline);
}
@ -853,6 +855,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let old = self.current_frame().as_ref().unwrap();
for frame in old.iter() {
frame.pipeline.borrow().revoke_paint_permission();
frame.pipeline.borrow().freeze();
}
}
self.navigation_context.forward(&mut *self.compositor_proxy)
@ -865,6 +868,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let old = self.current_frame().as_ref().unwrap();
for frame in old.iter() {
frame.pipeline.borrow().revoke_paint_permission();
frame.pipeline.borrow().freeze();
}
}
self.navigation_context.back(&mut *self.compositor_proxy)
@ -873,6 +877,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for frame in destination_frame.iter() {
frame.pipeline.borrow().load();
frame.pipeline.borrow().thaw();
}
self.send_frame_tree_and_grant_paint_permission(destination_frame);

View file

@ -191,6 +191,16 @@ impl Pipeline {
}
pub fn freeze(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan;
let _ = script_channel.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
}
pub fn thaw(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan;
let _ = script_channel.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
}
pub fn force_exit(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan;
let _ = script_channel.send(