aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Kuehn <tkuehn@cmu.edu>2013-09-21 15:37:30 -0400
committerTim Kuehn <tkuehn@cmu.edu>2013-09-24 00:03:52 -0400
commit99f125bb644db6eabef4ee282010db995be7d4eb (patch)
tree77f01c4ba45f605236e80452563c571f0f5e008b /src
parentc56b015623ee6f78c1603dfe789418add7618289 (diff)
downloadservo-99f125bb644db6eabef4ee282010db995be7d4eb.tar.gz
servo-99f125bb644db6eabef4ee282010db995be7d4eb.zip
script task only exits when the root pipeline exits
Diffstat (limited to 'src')
-rw-r--r--src/components/main/pipeline.rs2
-rw-r--r--src/components/script/dom/window.rs3
-rw-r--r--src/components/script/script_task.rs56
3 files changed, 49 insertions, 12 deletions
diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs
index b90edc7e320..603f13a0d28 100644
--- a/src/components/main/pipeline.rs
+++ b/src/components/main/pipeline.rs
@@ -217,7 +217,7 @@ impl Pipeline {
pub fn exit(&self) {
// Script task handles shutting down layout, as well
- self.script_chan.send(script_task::ExitMsg);
+ self.script_chan.send(script_task::ExitMsg(self.id));
let (response_port, response_chan) = comm::stream();
self.render_chan.send(render_task::ExitMsg(response_chan));
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 7c60da4d6c5..8b27b8862f1 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -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),
+ TimerMessage_TriggerExit => script_chan.send(ExitMsg(id)),
}
}
}
@@ -225,7 +225,6 @@ impl Window {
};
unsafe {
- // TODO(tkuehn): This just grabs the top-level page. Need to handle subframes.
let cache = ptr::to_unsafe_ptr(win.get_wrappercache());
win.wrap_object_shared(cx, ptr::null()); //XXXjdm proper scope
let global = (*cache).wrapper;
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 8c800727657..cb5f166daac 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -71,7 +71,7 @@ pub enum ScriptMsg {
/// Notifies script that window has been resized but to not take immediate action.
ResizeInactiveMsg(PipelineId, Size2D<uint>),
/// Exits the constellation.
- ExitMsg,
+ ExitMsg(PipelineId),
}
pub struct NewLayoutInfo {
@@ -171,6 +171,28 @@ impl PageTree {
stack: ~[self],
}
}
+
+ // must handle root case separately
+ pub fn remove(&mut self, id: PipelineId) -> Option<PageTree> {
+ let remove_idx = {
+ self.inner.mut_iter()
+ .enumerate()
+ .find(|&(_idx, ref page_tree)| page_tree.page.id == id)
+ .map(|&(idx, _)| idx)
+ };
+ match remove_idx {
+ Some(idx) => return Some(self.inner.remove(idx)),
+ None => {
+ for page_tree in self.inner.mut_iter() {
+ match page_tree.remove(id) {
+ found @ Some(_) => return found,
+ None => (), // keep going...
+ }
+ }
+ }
+ }
+ None
+ }
}
impl<'self> Iterator<@mut Page> for PageTreeIterator<'self> {
@@ -494,9 +516,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 => {
- self.handle_exit_msg();
- return false
+ ExitMsg(id) => {
+ if self.handle_exit_msg(id) { return false }
},
ResizeMsg(*) => fail!("should have handled ResizeMsg already"),
}
@@ -603,12 +624,29 @@ impl ScriptTask {
}
/// Handles a request to exit the script task and shut down layout.
- fn handle_exit_msg(&mut self) {
- for page in self.page_tree.iter() {
- page.join_layout();
- page.layout_chan.send(layout_interface::ExitMsg);
+ /// Returns true if the script task should shut down and false otherwise.
+ fn handle_exit_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() {
+ page.join_layout();
+ page.layout_chan.send(layout_interface::ExitMsg);
+ }
+ return true
+ }
+ // otherwise find just the matching page and exit all sub-pages
+ match self.page_tree.remove(id) {
+ Some(ref mut page_tree) => {
+ for page in page_tree.iter() {
+ page.join_layout();
+ page.layout_chan.send(layout_interface::ExitMsg);
+ }
+ return false
+ }
+ None => fail!("ScriptTask: Received exit message from
+ pipeline whose id is not in page tree"),
}
- self.compositor.close();
+
}
/// The entry point to document loading. Defines bindings, sets up the window and document