Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close the correct pipelines when evicted from navigation context. #966

Merged
merged 4 commits into from Sep 24, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

script task only exits when the root pipeline exits

  • Loading branch information
Tim Kuehn
Tim Kuehn committed Sep 24, 2013
commit 99f125bb644db6eabef4ee282010db995be7d4eb
@@ -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));
@@ -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;
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.