mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Implement binding support for returning and accepting Promises in WebIDL.
This commit is contained in:
parent
73b2963509
commit
a1091772ec
12 changed files with 217 additions and 20 deletions
|
@ -18,6 +18,7 @@ use dom::window::{self, ScriptHelpers};
|
|||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
|
||||
use js::glue::{IsWrapper, UnwrapObject};
|
||||
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
|
||||
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
|
||||
use js::jsapi::HandleValue;
|
||||
|
@ -356,3 +357,13 @@ pub unsafe fn global_root_from_context(cx: *mut JSContext) -> GlobalRoot {
|
|||
let global = CurrentGlobalOrNull(cx);
|
||||
global_root_from_global(global)
|
||||
}
|
||||
|
||||
/// Returns the global object of the realm that the given JS object was created in,
|
||||
/// after unwrapping any wrappers.
|
||||
pub unsafe fn global_root_from_object_maybe_wrapped(mut obj: *mut JSObject) -> GlobalRoot {
|
||||
if IsWrapper(obj) {
|
||||
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
|
||||
assert!(!obj.is_null());
|
||||
}
|
||||
global_root_from_object(obj)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue