Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the 'current' global object. #14647

Merged
merged 4 commits into from Dec 29, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement a getter for the 'current' global object.

  • Loading branch information
Ms2ger committed Dec 23, 2016
commit 01e336f6912292b5ca4c7349846a5d100974d99e
@@ -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 {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.