mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Add rt and cx methods to Runtime.
This commit is contained in:
parent
24ef5baf66
commit
2a5119ff37
1 changed files with 14 additions and 4 deletions
|
@ -280,6 +280,16 @@ impl Runtime {
|
||||||
cx: js_context,
|
cx: js_context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the `JSRuntime` object.
|
||||||
|
pub fn rt(&self) -> *mut JSRuntime {
|
||||||
|
self.rt.ptr
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the `JSContext` object.
|
||||||
|
pub fn cx(&self) -> *mut JSContext {
|
||||||
|
self.cx.ptr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
|
/// Information for an entire page. Pages are top-level browsing contexts and can contain multiple
|
||||||
|
@ -500,21 +510,21 @@ impl ScriptTask {
|
||||||
|
|
||||||
pub fn new_rt_and_cx() -> (js::rust::rt, Rc<Cx>) {
|
pub fn new_rt_and_cx() -> (js::rust::rt, Rc<Cx>) {
|
||||||
LiveDOMReferences::initialize();
|
LiveDOMReferences::initialize();
|
||||||
let Runtime { rt: js_runtime, cx: js_context } = Runtime::new();
|
let runtime = Runtime::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_rust_roots), ptr::null_mut());
|
JS_SetExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for debug assertions about whether GC is running.
|
// Needed for debug assertions about whether GC is running.
|
||||||
if !cfg!(ndebug) {
|
if !cfg!(ndebug) {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_SetGCCallback(js_runtime.ptr,
|
JS_SetGCCallback(runtime.rt(),
|
||||||
Some(debug_gc_callback as unsafe extern "C" fn(*mut JSRuntime, JSGCStatus)));
|
Some(debug_gc_callback as unsafe extern "C" fn(*mut JSRuntime, JSGCStatus)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(js_runtime, js_context)
|
(runtime.rt, runtime.cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the root page in the frame tree. Panics if it doesn't exist.
|
// Return the root page in the frame tree. Panics if it doesn't exist.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue