mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
commit
f1f8265449
8 changed files with 23 additions and 19 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue