diff options
Diffstat (limited to 'components/script/script_runtime.rs')
-rw-r--r-- | components/script/script_runtime.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 29be8114e35..2ee27ab38bb 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -43,6 +43,7 @@ use js::rust::wrappers::{GetPromiseIsHandled, GetPromiseResult}; use js::rust::Handle; use js::rust::IntoHandle; use js::rust::JSEngine; +use js::rust::ParentRuntime; use js::rust::Runtime as RustRuntime; use malloc_size_of::MallocSizeOfOps; use msg::constellation_msg::PipelineId; @@ -329,9 +330,23 @@ lazy_static! { } #[allow(unsafe_code)] -pub unsafe fn new_rt_and_cx() -> Runtime { +pub unsafe fn new_child_runtime(parent: ParentRuntime) -> Runtime { + new_rt_and_cx_with_parent(Some(parent)) +} + +#[allow(unsafe_code)] +pub fn new_rt_and_cx() -> Runtime { + unsafe { new_rt_and_cx_with_parent(None) } +} + +#[allow(unsafe_code)] +unsafe fn new_rt_and_cx_with_parent(parent: Option<ParentRuntime>) -> Runtime { LiveDOMReferences::initialize(); - let runtime = RustRuntime::new(JS_ENGINE.clone()); + let runtime = if let Some(parent) = parent { + RustRuntime::create_with_parent(parent) + } else { + RustRuntime::new(JS_ENGINE.clone()) + }; let cx = runtime.cx(); JS_AddExtraGCRootsTracer(cx, Some(trace_rust_roots), ptr::null_mut()); |