Removed some sources of panic from script thread and devtools, using Option values instead to indicate when a pipeline context is missing where appropriate. Additionally, removed erroneous method get_browsing_context.

This commit is contained in:
David Raifaizen 2016-07-25 20:34:47 -04:00
parent 4b78b9adab
commit 2475dc1d21
7 changed files with 89 additions and 54 deletions

View file

@ -1108,7 +1108,10 @@ impl ScriptThread {
fn handle_resize(&self, id: PipelineId, size: WindowSizeData, size_type: WindowSizeType) {
if let Some(ref context) = self.find_child_context(id) {
let window = context.active_window();
let window = match context.find(id) {
Some(browsing_context) => browsing_context.active_window(),
None => return warn!("Message sent to closed pipeline {}.", id),
};
window.set_resize_event(size, size_type);
return;
}
@ -2204,15 +2207,6 @@ fn shut_down_layout(context_tree: &BrowsingContext) {
}
}
// TODO: remove this function, as it's a source of panic.
pub fn get_browsing_context(context: &BrowsingContext,
pipeline_id: PipelineId)
-> Root<BrowsingContext> {
context.find(pipeline_id).expect("ScriptThread: received an event \
message for a layout channel that is not associated with this script thread.\
This is a bug.")
}
fn dom_last_modified(tm: &Tm) -> String {
tm.to_local().strftime("%m/%d/%Y %H:%M:%S").unwrap().to_string()
}