mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Force all messages to worker tasks to send a TrustedWorkerAddress along with the ScriptMsg. This ensures that the main-thread Worker object is rooted for as long as there are events in flight or being processed.
This commit is contained in:
parent
2f059c15e7
commit
9a7cd31134
11 changed files with 234 additions and 121 deletions
|
@ -52,7 +52,7 @@ use time;
|
|||
#[dom_struct]
|
||||
pub struct Window {
|
||||
eventtarget: EventTarget,
|
||||
script_chan: ScriptChan,
|
||||
script_chan: Box<ScriptChan+Send>,
|
||||
control_chan: ScriptControlChan,
|
||||
console: MutNullableJS<Console>,
|
||||
location: MutNullableJS<Location>,
|
||||
|
@ -75,8 +75,8 @@ impl Window {
|
|||
(*js_info.as_ref().unwrap().js_context).ptr
|
||||
}
|
||||
|
||||
pub fn script_chan<'a>(&'a self) -> &'a ScriptChan {
|
||||
&self.script_chan
|
||||
pub fn script_chan(&self) -> Box<ScriptChan+Send> {
|
||||
self.script_chan.clone()
|
||||
}
|
||||
|
||||
pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan {
|
||||
|
@ -189,8 +189,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
}
|
||||
|
||||
fn Close(self) {
|
||||
let ScriptChan(ref chan) = self.script_chan;
|
||||
chan.send(ScriptMsg::ExitWindow(self.page.id.clone()));
|
||||
self.script_chan.send(ScriptMsg::ExitWindow(self.page.id.clone()));
|
||||
}
|
||||
|
||||
fn Document(self) -> Temporary<Document> {
|
||||
|
@ -342,11 +341,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
|||
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
||||
// FIXME: handle URL parse errors more gracefully.
|
||||
let url = url.unwrap();
|
||||
let ScriptChan(ref script_chan) = self.script_chan;
|
||||
if href.as_slice().starts_with("#") {
|
||||
script_chan.send(ScriptMsg::TriggerFragment(self.page.id, url));
|
||||
self.script_chan.send(ScriptMsg::TriggerFragment(self.page.id, url));
|
||||
} else {
|
||||
script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
|
||||
self.script_chan.send(ScriptMsg::TriggerLoad(self.page.id, LoadData::new(url)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +357,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
|||
impl Window {
|
||||
pub fn new(cx: *mut JSContext,
|
||||
page: Rc<Page>,
|
||||
script_chan: ScriptChan,
|
||||
script_chan: Box<ScriptChan+Send>,
|
||||
control_chan: ScriptControlChan,
|
||||
compositor: Box<ScriptListener+'static>,
|
||||
image_cache_task: ImageCacheTask)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue