aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/script_task.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-07-15 17:32:52 +0200
committerMs2ger <ms2ger@gmail.com>2014-07-15 22:29:03 +0200
commitb11440750b70a302ced4394f5f47be3dff3e413d (patch)
tree783ed95c6166c2b88c06979682a93b6d9be16844 /src/components/script/script_task.rs
parent7b7303e6bc4309c7f0fefbef2191d38b3759ca50 (diff)
downloadservo-b11440750b70a302ced4394f5f47be3dff3e413d.tar.gz
servo-b11440750b70a302ced4394f5f47be3dff3e413d.zip
Load scripts in workers.
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r--src/components/script/script_task.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 5551e9d6869..e173a37f762 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -115,10 +115,10 @@ impl ScriptChan {
}
}
-struct StackRootTLS;
+pub struct StackRootTLS;
impl StackRootTLS {
- fn new(roots: &RootCollection) -> StackRootTLS {
+ pub fn new(roots: &RootCollection) -> StackRootTLS {
StackRoots.replace(Some(roots as *RootCollection));
StackRootTLS
}
@@ -210,6 +210,21 @@ impl ScriptTask {
window_size: WindowSizeData)
-> Rc<ScriptTask> {
let (js_runtime, js_context) = ScriptTask::new_rt_and_cx();
+ unsafe {
+ // JS_SetWrapObjectCallbacks clobbers the existing wrap callback,
+ // and JSCompartment::wrap crashes if that happens. The only way
+ // to retrieve the default callback is as the result of
+ // JS_SetWrapObjectCallbacks, which is why we call it twice.
+ let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
+ None,
+ Some(wrap_for_same_compartment),
+ None);
+ JS_SetWrapObjectCallbacks((*js_runtime).ptr,
+ callback,
+ Some(wrap_for_same_compartment),
+ Some(pre_wrap));
+ }
+
let page = Page::new(id, None, layout_chan, window_size,
resource_task.clone(),
constellation_chan.clone(),
@@ -231,26 +246,12 @@ impl ScriptTask {
})
}
- fn new_rt_and_cx() -> (js::rust::rt, Rc<Cx>) {
+ pub fn new_rt_and_cx() -> (js::rust::rt, Rc<Cx>) {
let js_runtime = js::rust::rt();
assert!({
let ptr: *mut JSRuntime = (*js_runtime).ptr;
ptr.is_not_null()
});
- unsafe {
- // JS_SetWrapObjectCallbacks clobbers the existing wrap callback,
- // and JSCompartment::wrap crashes if that happens. The only way
- // to retrieve the default callback is as the result of
- // JS_SetWrapObjectCallbacks, which is why we call it twice.
- let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
- None,
- Some(wrap_for_same_compartment),
- None);
- JS_SetWrapObjectCallbacks((*js_runtime).ptr,
- callback,
- Some(wrap_for_same_compartment),
- Some(pre_wrap));
- }
let js_context = js_runtime.cx();
assert!({