beforeunload and unload infrastructure

This commit is contained in:
Gregory Terzian 2018-03-18 13:20:24 +08:00
parent a1d1b18710
commit 427eaed535
28 changed files with 267 additions and 60 deletions

View file

@ -1157,6 +1157,7 @@ impl ScriptThread {
AttachLayout(ref new_layout_info) => Some(new_layout_info.new_pipeline_id),
Resize(id, ..) => Some(id),
ResizeInactive(id, ..) => Some(id),
UnloadDocument(id) => Some(id),
ExitPipeline(id, ..) => Some(id),
ExitScriptThread => None,
SendEvent(id, ..) => Some(id),
@ -1275,6 +1276,8 @@ impl ScriptThread {
},
ConstellationControlMsg::Navigate(parent_pipeline_id, browsing_context_id, load_data, replace) =>
self.handle_navigate(parent_pipeline_id, Some(browsing_context_id), load_data, replace),
ConstellationControlMsg::UnloadDocument(pipeline_id) =>
self.handle_unload_document(pipeline_id),
ConstellationControlMsg::SendEvent(id, event) =>
self.handle_event(id, event),
ConstellationControlMsg::ResizeInactive(id, new_size) =>
@ -1668,6 +1671,13 @@ impl ScriptThread {
}
}
fn handle_unload_document(&self, pipeline_id: PipelineId) {
let document = self.documents.borrow().find_document(pipeline_id);
if let Some(document) = document {
document.unload(false, false);
}
}
fn handle_update_pipeline_id(&self,
parent_pipeline_id: PipelineId,
browsing_context_id: BrowsingContextId,