mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement a getter for the 'current' global object.
This commit is contained in:
parent
07b18265f3
commit
01e336f691
1 changed files with 14 additions and 1 deletions
|
@ -27,7 +27,7 @@ use js::jsapi::{HandleValue, Evaluate2, JSAutoCompartment, JSContext};
|
|||
use js::jsapi::{JSObject, JS_GetContext};
|
||||
use js::jsapi::{JS_GetObjectRuntime, MutableHandleValue};
|
||||
use js::panic::maybe_resume_unwind;
|
||||
use js::rust::{CompileOptionsWrapper, get_object_class};
|
||||
use js::rust::{CompileOptionsWrapper, Runtime, get_object_class};
|
||||
use libc;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::{CoreResourceThread, ResourceThreads, IpcSend};
|
||||
|
@ -506,6 +506,19 @@ impl GlobalScope {
|
|||
}
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
/// Returns the ["current"] global object.
|
||||
///
|
||||
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
|
||||
#[allow(unsafe_code)]
|
||||
pub fn current() -> Root<Self> {
|
||||
unsafe {
|
||||
let cx = Runtime::get();
|
||||
assert!(!cx.is_null());
|
||||
let global = CurrentGlobalOrNull(cx);
|
||||
global_scope_from_global(global)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn timestamp_in_ms(time: Timespec) -> u64 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue