Various fixes for cleaning up iframes, compositor layers, pipelines and threads.

This allows most of the jquery test suite to run without exhausting thread resources.
This commit is contained in:
Glenn Watson 2015-04-29 09:13:46 +10:00
parent 5e61ebaa05
commit 2b3737d34e
11 changed files with 191 additions and 14 deletions

View file

@ -385,5 +385,32 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
self.process_the_iframe_attributes();
}
}
fn unbind_from_tree(&self, tree_in_doc: bool) {
if let Some(ref s) = self.super_type() {
s.unbind_from_tree(tree_in_doc);
}
// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded
match (self.containing_page_pipeline_id(), self.subpage_id()) {
(Some(containing_pipeline_id), Some(subpage_id)) => {
let window = window_from_node(*self).root();
let window = window.r();
let ConstellationChan(ref chan) = window.constellation_chan();
let msg = ConstellationMsg::RemoveIFrame(containing_pipeline_id,
subpage_id);
chan.send(msg).unwrap();
// Resetting the subpage id to None is required here so that
// if this iframe is subsequently re-added to the document
// the load doesn't think that it's a navigation, but instead
// a new iframe. Without this, the constellation gets very
// confused.
self.subpage_id.set(None);
}
_ => {}
}
}
}

View file

@ -1078,6 +1078,13 @@ impl ScriptTask {
/// 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_pipeline_msg(&self, id: PipelineId, exit_type: PipelineExitType) -> bool {
if self.page.borrow().is_none() {
// The root page doesn't even exist yet, so it
// is safe to exit this script task.
// TODO(gw): This probably leaks resources!
return true;
}
// If root is being exited, shut down all pages
let page = self.root_page();
let window = page.window().root();
@ -1452,7 +1459,11 @@ impl ScriptTask {
}, LoadConsumer::Channel(input_chan))).unwrap();
let load_response = input_port.recv().unwrap();
script_chan.send(ScriptMsg::PageFetchComplete(id, subpage, load_response)).unwrap();
if script_chan.send(ScriptMsg::PageFetchComplete(id, subpage, load_response)).is_err() {
// TODO(gw): This should be handled by aborting
// the load before the script task exits.
debug!("PageFetchComplete: script channel has exited");
}
});
self.incomplete_loads.borrow_mut().push(incomplete);