auto merge of #4956 : psdh/servo/interfail, r=jdm

Fixes #4923
This commit is contained in:
bors-servo 2015-02-21 12:51:44 -07:00
commit f1f8265449
8 changed files with 23 additions and 19 deletions

View file

@ -84,6 +84,7 @@ use std::fmt::{self, Display};
use std::mem::replace;
use std::num::ToPrimitive;
use std::rc::Rc;
use std::result::Result;
use std::sync::mpsc::{channel, Sender, Receiver, Select};
use std::u32;
use time::{Tm, strptime};
@ -133,7 +134,7 @@ pub enum ScriptMsg {
/// A cloneable interface for communicating with an event loop.
pub trait ScriptChan {
/// Send a message to the associated event loop.
fn send(&self, msg: ScriptMsg);
fn send(&self, msg: ScriptMsg) -> Result<(), ()>;
/// Clone this handle.
fn clone(&self) -> Box<ScriptChan+Send>;
}
@ -143,9 +144,9 @@ pub trait ScriptChan {
pub struct NonWorkerScriptChan(pub Sender<ScriptMsg>);
impl ScriptChan for NonWorkerScriptChan {
fn send(&self, msg: ScriptMsg) {
fn send(&self, msg: ScriptMsg) -> Result<(), ()> {
let NonWorkerScriptChan(ref chan) = *self;
chan.send(msg).unwrap();
return chan.send(msg).map_err(|_| ());
}
fn clone(&self) -> Box<ScriptChan+Send> {
@ -893,7 +894,7 @@ impl ScriptTask {
// https://html.spec.whatwg.org/multipage/#the-end step 4
let addr: Trusted<Document> = Trusted::new(self.get_cx(), document.r(), self.chan.clone());
let handler = Box::new(DocumentProgressHandler::new(addr.clone(), DocumentProgressTask::DOMContentLoaded));
self.chan.send(ScriptMsg::RunnableMsg(handler));
self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap();
// We have no concept of a document loader right now, so just dispatch the
// "load" event as soon as we've finished executing all scripts parsed during
@ -901,7 +902,7 @@ impl ScriptTask {
// https://html.spec.whatwg.org/multipage/#the-end step 7
let handler = Box::new(DocumentProgressHandler::new(addr, DocumentProgressTask::Load));
self.chan.send(ScriptMsg::RunnableMsg(handler));
self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap();
*page.fragment_name.borrow_mut() = final_url.fragment.clone();