Remove GlobalRoot and GlobalRef

This commit is contained in:
Anthony Ramine 2016-10-05 10:29:38 +02:00
parent c66cf46bee
commit b6bbd41e11
13 changed files with 63 additions and 173 deletions

View file

@ -174,8 +174,6 @@ pub struct Request {
pub body: RefCell<Option<Vec<u8>>>, pub body: RefCell<Option<Vec<u8>>>,
// TODO: client object // TODO: client object
pub is_service_worker_global_scope: bool, pub is_service_worker_global_scope: bool,
// pub client: GlobalRef, // XXXManishearth copy over only the relevant fields of the global scope,
// not the entire scope to avoid the libscript dependency
pub window: Cell<Window>, pub window: Cell<Window>,
// TODO: target browsing context // TODO: target browsing context
pub keep_alive: Cell<bool>, pub keep_alive: Cell<bool>,

View file

@ -5,8 +5,8 @@
//! Base classes to work with IDL callbacks. //! Base classes to work with IDL callbacks.
use dom::bindings::error::{Error, Fallible, report_pending_exception}; use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::global::global_scope_from_object;
use dom::bindings::reflector::Reflectable; use dom::bindings::reflector::Reflectable;
use dom::globalscope::GlobalScope;
use js::jsapi::{Heap, MutableHandleObject, RootedObject}; use js::jsapi::{Heap, MutableHandleObject, RootedObject};
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject}; use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment}; use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
@ -165,7 +165,7 @@ impl<'a> CallSetup<'a> {
callback: &T, callback: &T,
handling: ExceptionHandling) handling: ExceptionHandling)
-> CallSetup<'a> { -> CallSetup<'a> {
let global = unsafe { global_scope_from_object(callback.callback()) }; let global = unsafe { GlobalScope::from_object(callback.callback()) };
let cx = global.get_cx(); let cx = global.get_cx();
exception_compartment.ptr = unsafe { exception_compartment.ptr = unsafe {

View file

@ -817,7 +817,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
{ // Scope for our JSAutoCompartment. { // Scope for our JSAutoCompartment.
rooted!(in(cx) let globalObj = CurrentGlobalOrNull(cx)); rooted!(in(cx) let globalObj = CurrentGlobalOrNull(cx));
let promiseGlobal = global_scope_from_object_maybe_wrapped(globalObj.handle().get()); let promiseGlobal = GlobalScope::from_object_maybe_wrapped(globalObj.handle().get());
rooted!(in(cx) let mut valueToResolve = $${val}.get()); rooted!(in(cx) let mut valueToResolve = $${val}.get());
if !JS_WrapValue(cx, valueToResolve.handle_mut()) { if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
@ -3170,7 +3170,7 @@ class CGCallGenerator(CGThing):
if static: if static:
glob = "&global" glob = "&global"
else: else:
glob = "&global_scope_from_reflector(this)" glob = "&this.global_scope()"
self.cgRoot.append(CGGeneric( self.cgRoot.append(CGGeneric(
"let result = match result {\n" "let result = match result {\n"
@ -3386,7 +3386,7 @@ class CGAbstractStaticBindingMethod(CGAbstractMethod):
def definition_body(self): def definition_body(self):
preamble = CGGeneric("""\ preamble = CGGeneric("""\
let global = global_scope_from_object(JS_CALLEE(cx, vp).to_object()); let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
""") """)
return CGList([preamble, self.generate_code()]) return CGList([preamble, self.generate_code()])
@ -5252,7 +5252,7 @@ class CGClassConstructHook(CGAbstractExternMethod):
def definition_body(self): def definition_body(self):
preamble = CGGeneric("""\ preamble = CGGeneric("""\
let global = global_scope_from_object(JS_CALLEE(cx, vp).to_object()); let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
let args = CallArgs::from_vp(vp, argc); let args = CallArgs::from_vp(vp, argc);
""") """)
name = self.constructor.identifier.name name = self.constructor.identifier.name
@ -5499,10 +5499,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::bindings::codegen::InterfaceObjectMap', 'dom::bindings::codegen::InterfaceObjectMap',
'dom::bindings::constant::ConstantSpec', 'dom::bindings::constant::ConstantSpec',
'dom::bindings::constant::ConstantVal', 'dom::bindings::constant::ConstantVal',
'dom::bindings::global::GlobalRef',
'dom::bindings::global::global_scope_from_object_maybe_wrapped',
'dom::bindings::global::global_scope_from_reflector',
'dom::bindings::global::global_scope_from_object',
'dom::bindings::interface::ConstructorClassHook', 'dom::bindings::interface::ConstructorClassHook',
'dom::bindings::interface::InterfaceConstructorBehavior', 'dom::bindings::interface::InterfaceConstructorBehavior',
'dom::bindings::interface::NonCallbackInterfaceObjectClass', 'dom::bindings::interface::NonCallbackInterfaceObjectClass',

View file

@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods;
use dom::bindings::codegen::PrototypeList::proto_id_to_name; use dom::bindings::codegen::PrototypeList::proto_id_to_name;
use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible}; use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSValConvertible};
use dom::bindings::conversions::root_from_object; use dom::bindings::conversions::root_from_object;
use dom::bindings::global::global_scope_from_context;
use dom::bindings::str::USVString; use dom::bindings::str::USVString;
use dom::domexception::{DOMErrorName, DOMException}; use dom::domexception::{DOMErrorName, DOMException};
use dom::globalscope::GlobalScope; use dom::globalscope::GlobalScope;
@ -246,8 +245,8 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool)
error_info.message); error_info.message);
if dispatch_event { if dispatch_event {
let global = global_scope_from_context(cx); GlobalScope::from_context(cx)
global.report_an_error(error_info, value.handle()); .report_an_error(error_info, value.handle());
} }
} }
} }

View file

@ -1,143 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Abstractions for global scopes.
//!
//! This module contains smart pointers to global scopes, to simplify writing
//! code that works in workers as well as window scopes.
use dom::bindings::conversions::root_from_object;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::globalscope::GlobalScope;
use dom::window;
use dom::workerglobalscope::WorkerGlobalScope;
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};
/// A freely-copyable reference to a rooted global object.
#[derive(Copy, Clone)]
pub enum GlobalRef<'a> {
/// A reference to a `Window` object.
Window(&'a window::Window),
/// A reference to a `WorkerGlobalScope` object.
Worker(&'a WorkerGlobalScope),
}
/// A stack-based rooted reference to a global object.
pub enum GlobalRoot {
/// A root for a `Window` object.
Window(Root<window::Window>),
/// A root for a `WorkerGlobalScope` object.
Worker(Root<WorkerGlobalScope>),
}
impl<'a> GlobalRef<'a> {
/// Returns that `GlobalRef` as a `GlobalScope` referengce.
pub fn as_global_scope(&self) -> &GlobalScope {
match *self {
GlobalRef::Window(window) => window.upcast(),
GlobalRef::Worker(worker) => worker.upcast(),
}
}
/// Get the `JSContext` for the `JSRuntime` associated with the thread
/// this global object is on.
pub fn get_cx(&self) -> *mut JSContext {
match *self {
GlobalRef::Window(ref window) => window.get_cx(),
GlobalRef::Worker(ref worker) => worker.get_cx(),
}
}
}
impl<'a> Reflectable for GlobalRef<'a> {
fn reflector(&self) -> &Reflector {
match *self {
GlobalRef::Window(ref window) => window.reflector(),
GlobalRef::Worker(ref worker) => worker.reflector(),
}
}
}
impl GlobalRoot {
/// Obtain a safe reference to the global object that cannot outlive the
/// lifetime of this root.
pub fn r(&self) -> GlobalRef {
match *self {
GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()),
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()),
}
}
}
/// Returns the global scope of the realm that the given DOM object's reflector was created in.
pub fn global_scope_from_reflector<T: Reflectable>(reflector: &T) -> Root<GlobalScope> {
unsafe { global_scope_from_object(*reflector.reflector().get_jsobject()) }
}
/// Returns the Rust global scope from a JS global object.
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
assert!(!global.is_null());
let clasp = JS_GetClass(global);
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
root_from_object(global).unwrap()
}
/// Returns the Rust global object from a JS global object.
#[allow(unrooted_must_root)]
unsafe fn global_root_from_global(global: *mut JSObject) -> GlobalRoot {
let global_scope = global_scope_from_global(global);
if let Some(window) = global_scope.downcast::<window::Window>() {
return GlobalRoot::Window(Root::from_ref(window));
}
if let Some(worker) = Root::downcast(global_scope) {
return GlobalRoot::Worker(worker);
}
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
}
/// Returns the global scope of the realm that the given JS object was created in.
pub unsafe fn global_scope_from_object(obj: *mut JSObject) -> Root<GlobalScope> {
assert!(!obj.is_null());
let global = GetGlobalForObjectCrossCompartment(obj);
global_scope_from_global(global)
}
/// Returns the global object of the realm that the given JS object was created in.
#[allow(unrooted_must_root)]
pub unsafe fn global_root_from_object(obj: *mut JSObject) -> GlobalRoot {
assert!(!obj.is_null());
let global = GetGlobalForObjectCrossCompartment(obj);
global_root_from_global(global)
}
/// Returns the global scope for the given JSContext
#[allow(unrooted_must_root)]
pub unsafe fn global_scope_from_context(cx: *mut JSContext) -> Root<GlobalScope> {
let global = CurrentGlobalOrNull(cx);
global_scope_from_global(global)
}
/// Returns the global object for the given JSContext
#[allow(unrooted_must_root)]
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_scope_from_object_maybe_wrapped(
mut obj: *mut JSObject)
-> Root<GlobalScope> {
if IsWrapper(obj) {
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
assert!(!obj.is_null());
}
global_scope_from_object(obj)
}

View file

@ -134,7 +134,6 @@ pub mod cell;
pub mod constant; pub mod constant;
pub mod conversions; pub mod conversions;
pub mod error; pub mod error;
pub mod global;
pub mod guard; pub mod guard;
pub mod inheritance; pub mod inheritance;
pub mod interface; pub mod interface;

View file

@ -5,7 +5,6 @@
//! The `Reflector` struct. //! The `Reflector` struct.
use dom::bindings::conversions::DerivedFrom; use dom::bindings::conversions::DerivedFrom;
use dom::bindings::global::global_scope_from_reflector;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::globalscope::GlobalScope; use dom::globalscope::GlobalScope;
use js::jsapi::{HandleObject, JSContext, JSObject}; use js::jsapi::{HandleObject, JSContext, JSObject};
@ -82,7 +81,7 @@ pub trait Reflectable {
/// Returns the global scope of the realm that the Reflectable was created in. /// Returns the global scope of the realm that the Reflectable was created in.
fn global_scope(&self) -> Root<GlobalScope> where Self: Sized { fn global_scope(&self) -> Root<GlobalScope> where Self: Sized {
global_scope_from_reflector(self) GlobalScope::from_reflector(self)
} }
} }

View file

@ -11,7 +11,6 @@ use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods; use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::{ErrorInfo, ErrorResult}; use dom::bindings::error::{ErrorInfo, ErrorResult};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection}; use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable; use dom::bindings::reflector::Reflectable;
@ -343,7 +342,7 @@ impl DedicatedWorkerGlobalScope {
#[allow(unsafe_code)] #[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool { unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let worker = let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx)) Root::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
.expect("global is not a worker scope"); .expect("global is not a worker scope");
assert!(worker.is::<DedicatedWorkerGlobalScope>()); assert!(worker.is::<DedicatedWorkerGlobalScope>());

View file

@ -5,6 +5,7 @@
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use dom::bindings::cell::DOMRefCell; use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::root_from_object;
use dom::bindings::error::{ErrorInfo, report_pending_exception}; use dom::bindings::error::{ErrorInfo, report_pending_exception};
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::js::{JS, MutNullableHeap, Root};
@ -19,8 +20,12 @@ use dom::eventtarget::EventTarget;
use dom::window::Window; use dom::window::Window;
use dom::workerglobalscope::WorkerGlobalScope; use dom::workerglobalscope::WorkerGlobalScope;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, Evaluate2, JS_GetContext, JS_GetObjectRuntime}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue}; use js::glue::{IsWrapper, UnwrapObject};
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
use js::jsapi::{HandleValue, Evaluate2, JSAutoCompartment, JSContext};
use js::jsapi::{JSObject, JS_GetClass, JS_GetContext};
use js::jsapi::{JS_GetObjectRuntime, MutableHandleValue};
use js::rust::CompileOptionsWrapper; use js::rust::CompileOptionsWrapper;
use libc; use libc;
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
@ -116,6 +121,39 @@ impl GlobalScope {
} }
} }
/// Returns the global scope of the realm that the given DOM object's reflector
/// was created in.
#[allow(unsafe_code)]
pub fn from_reflector<T: Reflectable>(reflector: &T) -> Root<Self> {
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
}
/// Returns the global scope of the realm that the given JS object was created in.
#[allow(unsafe_code)]
pub unsafe fn from_object(obj: *mut JSObject) -> Root<Self> {
assert!(!obj.is_null());
let global = GetGlobalForObjectCrossCompartment(obj);
global_scope_from_global(global)
}
/// Returns the global scope for the given JSContext
#[allow(unsafe_code)]
pub unsafe fn from_context(cx: *mut JSContext) -> Root<Self> {
let global = CurrentGlobalOrNull(cx);
global_scope_from_global(global)
}
/// Returns the global object of the realm that the given JS object
/// was created in, after unwrapping any wrappers.
#[allow(unsafe_code)]
pub unsafe fn from_object_maybe_wrapped(mut obj: *mut JSObject) -> Root<Self> {
if IsWrapper(obj) {
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
assert!(!obj.is_null());
}
GlobalScope::from_object(obj)
}
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub fn get_cx(&self) -> *mut JSContext { pub fn get_cx(&self) -> *mut JSContext {
unsafe { unsafe {
@ -475,3 +513,12 @@ impl GlobalScope {
fn timestamp_in_ms(time: Timespec) -> u64 { fn timestamp_in_ms(time: Timespec) -> u64 {
(time.sec * 1000 + (time.nsec / 1000000) as i64) as u64 (time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
} }
/// Returns the Rust global scope from a JS global object.
#[allow(unsafe_code)]
unsafe fn global_scope_from_global(global: *mut JSObject) -> Root<GlobalScope> {
assert!(!global.is_null());
let clasp = JS_GetClass(global);
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
root_from_object(global).unwrap()
}

View file

@ -8,7 +8,6 @@ use dom::abstractworker::WorkerScriptMsg;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding; use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding;
use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods; use dom::bindings::codegen::Bindings::ServiceWorkerGlobalScopeBinding::ServiceWorkerGlobalScopeMethods;
use dom::bindings::global::global_scope_from_context;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{Root, RootCollection}; use dom::bindings::js::{Root, RootCollection};
use dom::bindings::reflector::Reflectable; use dom::bindings::reflector::Reflectable;
@ -311,7 +310,7 @@ impl ServiceWorkerGlobalScope {
#[allow(unsafe_code)] #[allow(unsafe_code)]
unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool { unsafe extern "C" fn interrupt_callback(cx: *mut JSContext) -> bool {
let worker = let worker =
Root::downcast::<WorkerGlobalScope>(global_scope_from_context(cx)) Root::downcast::<WorkerGlobalScope>(GlobalScope::from_context(cx))
.expect("global is not a worker scope"); .expect("global is not a worker scope");
assert!(worker.is::<ServiceWorkerGlobalScope>()); assert!(worker.is::<ServiceWorkerGlobalScope>());

View file

@ -21,7 +21,6 @@ use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBool
use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong}; use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong};
use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean}; use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean};
use dom::bindings::error::{Error, Fallible}; use dom::bindings::error::{Error, Fallible};
use dom::bindings::global::global_scope_from_context;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::bindings::mozmap::MozMap; use dom::bindings::mozmap::MozMap;
use dom::bindings::num::Finite; use dom::bindings::num::Finite;
@ -714,7 +713,7 @@ impl TestBindingMethods for TestBinding {
impl Callback for SimpleHandler { impl Callback for SimpleHandler {
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn callback(&self, cx: *mut JSContext, v: HandleValue) { fn callback(&self, cx: *mut JSContext, v: HandleValue) {
let global = unsafe { global_scope_from_context(cx) }; let global = unsafe { GlobalScope::from_context(cx) };
let _ = self.handler.Call_(&*global, v, ExceptionHandling::Report); let _ = self.handler.Call_(&*global, v, ExceptionHandling::Report);
} }
} }

View file

@ -17,7 +17,6 @@ use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions}; use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
use dom::bindings::codegen::UnionTypes::RequestOrUSVString; use dom::bindings::codegen::UnionTypes::RequestOrUSVString;
use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::global::global_scope_from_object;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::num::Finite; use dom::bindings::num::Finite;
@ -1496,7 +1495,7 @@ impl Window {
/// in a top-level `Window` global. /// in a top-level `Window` global.
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub unsafe fn global_is_mozbrowser(_: *mut JSContext, obj: HandleObject) -> bool { pub unsafe fn global_is_mozbrowser(_: *mut JSContext, obj: HandleObject) -> bool {
global_scope_from_object(obj.get()) GlobalScope::from_object(obj.get())
.downcast::<Window>() .downcast::<Window>()
.map_or(false, |window| window.is_mozbrowser()) .map_or(false, |window| window.is_mozbrowser())
} }

View file

@ -8,7 +8,6 @@
use dom::bindings::callback::ExceptionHandling; use dom::bindings::callback::ExceptionHandling;
use dom::bindings::cell::DOMRefCell; use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
use dom::bindings::global::global_scope_from_object;
use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots}; use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots};
use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects}; use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects};
use dom::bindings::trace::trace_traceables; use dom::bindings::trace::trace_traceables;
@ -178,7 +177,7 @@ unsafe extern "C" fn enqueue_job(_cx: *mut JSContext,
_allocation_site: HandleObject, _allocation_site: HandleObject,
_data: *mut c_void) -> bool { _data: *mut c_void) -> bool {
let result = panic::catch_unwind(AssertUnwindSafe(|| { let result = panic::catch_unwind(AssertUnwindSafe(|| {
let global = global_scope_from_object(job.get()); let global = GlobalScope::from_object(job.get());
let pipeline = global.pipeline_id(); let pipeline = global.pipeline_id();
global.enqueue_promise_job(EnqueuedPromiseCallback { global.enqueue_promise_job(EnqueuedPromiseCallback {
callback: PromiseJobCallback::new(job.get()), callback: PromiseJobCallback::new(job.get()),