aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/window.rs4
-rw-r--r--src/components/script/script_task.rs29
2 files changed, 22 insertions, 11 deletions
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 8b27b8862f1..5c2bf7cda97 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -10,7 +10,7 @@ use dom::node::{AbstractNode, ScriptView};
use dom::navigator::Navigator;
use layout_interface::ReflowForDisplay;
-use script_task::{ExitMsg, FireTimerMsg, Page, ScriptChan};
+use script_task::{ExitWindowMsg, FireTimerMsg, Page, ScriptChan};
use servo_msg::compositor_msg::ScriptListener;
use servo_net::image_cache_task::ImageCacheTask;
@@ -212,7 +212,7 @@ impl Window {
match timer_port.recv() {
TimerMessage_Close => break,
TimerMessage_Fire(td) => script_chan.send(FireTimerMsg(id, td)),
- TimerMessage_TriggerExit => script_chan.send(ExitMsg(id)),
+ TimerMessage_TriggerExit => script_chan.send(ExitWindowMsg(id)),
}
}
}
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index cb5f166daac..ab184fe67e1 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -70,8 +70,10 @@ pub enum ScriptMsg {
ReflowCompleteMsg(PipelineId, uint),
/// Notifies script that window has been resized but to not take immediate action.
ResizeInactiveMsg(PipelineId, Size2D<uint>),
- /// Exits the constellation.
- ExitMsg(PipelineId),
+ /// Notifies the script that a pipeline should be closed.
+ ExitPipelineMsg(PipelineId),
+ /// Notifies the script that a window associated with a particular pipeline should be closed.
+ ExitWindowMsg(PipelineId),
}
pub struct NewLayoutInfo {
@@ -516,9 +518,8 @@ impl ScriptTask {
NavigateMsg(direction) => self.handle_navigate_msg(direction),
ReflowCompleteMsg(id, reflow_id) => self.handle_reflow_complete_msg(id, reflow_id),
ResizeInactiveMsg(id, new_size) => self.handle_resize_inactive_msg(id, new_size),
- ExitMsg(id) => {
- if self.handle_exit_msg(id) { return false }
- },
+ ExitPipelineMsg(id) => if self.handle_exit_pipeline_msg(id) { return false },
+ ExitWindowMsg(id) => if self.handle_exit_window_msg(id) { return false },
ResizeMsg(*) => fail!("should have handled ResizeMsg already"),
}
}
@@ -623,9 +624,17 @@ impl ScriptTask {
}
}
+ fn handle_exit_window_msg(&mut self, _id: PipelineId) -> bool {
+ // TODO(tkuehn): currently there is only one window,
+ // so this can afford to be naive and just shut down the
+ // compositor. In the future it'll need to be smarter.
+ self.compositor.close();
+ true
+ }
+
/// Handles a request to exit the script task and shut down layout.
/// Returns true if the script task should shut down and false otherwise.
- fn handle_exit_msg(&mut self, id: PipelineId) -> bool {
+ fn handle_exit_pipeline_msg(&mut self, id: PipelineId) -> bool {
// If root is being exited, shut down all pages
if self.page_tree.page.id == id {
for page in self.page_tree.iter() {
@@ -641,10 +650,12 @@ impl ScriptTask {
page.join_layout();
page.layout_chan.send(layout_interface::ExitMsg);
}
- return false
+ false
}
- None => fail!("ScriptTask: Received exit message from
- pipeline whose id is not in page tree"),
+ // TODO(tkuehn): pipeline closing is currently duplicated across
+ // script and constellation, which can cause this to happen. Constellation
+ // needs to be smarter about exiting pipelines.
+ None => false,
}
}