mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
commit
f1f8265449
8 changed files with 23 additions and 19 deletions
|
@ -114,7 +114,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
|
|||
*refcount -= 1;
|
||||
if *refcount == 0 {
|
||||
self.script_chan.send(
|
||||
ScriptMsg::RefcountCleanup(TrustedReference(self.ptr)));
|
||||
ScriptMsg::RefcountCleanup(TrustedReference(self.ptr))).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ pub struct SendableWorkerScriptChan {
|
|||
}
|
||||
|
||||
impl ScriptChan for SendableWorkerScriptChan {
|
||||
fn send(&self, msg: ScriptMsg) {
|
||||
self.sender.send((self.worker.clone(), msg)).unwrap();
|
||||
fn send(&self, msg: ScriptMsg) -> Result<(), ()> {
|
||||
return self.sender.send((self.worker.clone(), msg)).map_err(|_| ());
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<ScriptChan + Send> {
|
||||
|
@ -147,7 +147,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
Err(_) => {
|
||||
println!("error loading script {}", worker_url.serialize());
|
||||
parent_sender.send(ScriptMsg::RunnableMsg(
|
||||
box WorkerEventHandler::new(worker)));
|
||||
box WorkerEventHandler::new(worker))).unwrap();
|
||||
return;
|
||||
}
|
||||
Ok((metadata, bytes)) => {
|
||||
|
@ -235,7 +235,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerG
|
|||
let col_num = errorevent.Colno();
|
||||
let worker = self.worker.borrow().as_ref().unwrap().clone();
|
||||
self.parent_sender.send(ScriptMsg::WorkerDispatchErrorEvent(worker, msg, file_name,
|
||||
line_num, col_num));
|
||||
line_num, col_num)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalSc
|
|||
let data = try!(StructuredCloneData::write(cx, message));
|
||||
let worker = self.worker.borrow().as_ref().unwrap().clone();
|
||||
self.parent_sender.send(ScriptMsg::RunnableMsg(
|
||||
box WorkerMessageHandler::new(worker, data)));
|
||||
box WorkerMessageHandler::new(worker, data))).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
|
|||
}
|
||||
|
||||
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
|
||||
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().page().id, load_data));
|
||||
win.r().script_chan().send(ScriptMsg::TriggerLoad(win.r().page().id, load_data)).unwrap();
|
||||
}
|
||||
|
||||
fn get_form_dataset<'b>(self, submitter: Option<FormSubmitter<'b>>) -> Vec<FormDatum> {
|
||||
|
|
|
@ -257,7 +257,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
|
|||
ScriptOrigin::Internal => {
|
||||
let chan = window.script_chan();
|
||||
let handler = Trusted::new(window.get_cx(), self, chan.clone());
|
||||
chan.send(ScriptMsg::RunnableMsg(box handler));
|
||||
chan.send(ScriptMsg::RunnableMsg(box handler)).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
|
|||
let window = window.r();
|
||||
let chan = window.script_chan();
|
||||
let handler = Trusted::new(window.get_cx(), self, chan.clone());
|
||||
chan.send(ScriptMsg::RunnableMsg(box handler));
|
||||
chan.send(ScriptMsg::RunnableMsg(box handler)).unwrap();
|
||||
}
|
||||
|
||||
fn dispatch_load_event(self) {
|
||||
|
|
|
@ -197,7 +197,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
}
|
||||
|
||||
fn Close(self) {
|
||||
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone()));
|
||||
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone())).unwrap();
|
||||
}
|
||||
|
||||
fn Document(self) -> Temporary<Document> {
|
||||
|
@ -387,10 +387,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
|||
let url = url.unwrap();
|
||||
match url.fragment {
|
||||
Some(fragment) => {
|
||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment));
|
||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, fragment)).unwrap();
|
||||
},
|
||||
None => {
|
||||
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
|
||||
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url))).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ impl XMLHttpRequest {
|
|||
xhr.process_partial_response(msg);
|
||||
},
|
||||
SyncOrAsync::Async(ref addr, ref script_chan) => {
|
||||
script_chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg)));
|
||||
script_chan.send(ScriptMsg::RunnableMsg(box XHRProgressHandler::new(addr.clone(), msg))).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -149,7 +149,10 @@ impl TimerManager {
|
|||
let id = select.wait();
|
||||
if id == timeout_handle.id() {
|
||||
timeout_port.recv().unwrap();
|
||||
script_chan.send(ScriptMsg::FireTimer(source, TimerId(handle)));
|
||||
if script_chan.send(ScriptMsg::FireTimer(source, TimerId(handle))).is_err() {
|
||||
break;
|
||||
}
|
||||
|
||||
if is_interval == IsInterval::NonInterval {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue