Add thaw/freeze messages that can suspend/resume webcontent timers #4907

This commit is contained in:
Pawel Kondzior 2015-02-19 11:20:55 +07:00
parent dc31d96f65
commit c2961c94b4
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(