diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index afa0bcaa9e8..7f702a424f6 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1821,8 +1821,11 @@ Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor, "scope")) with_compartment(aCx, obj, || { let proto = GetProtoObject(aCx, obj, obj); JS_SetPrototype(aCx, obj, proto); + + raw.reflector().set_jsobject(obj); + + RegisterBindings::Register(aCx, obj); }); -raw.reflector().set_jsobject(obj); Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor)) @@ -2098,7 +2101,8 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod): def __init__(self, descriptor): assert descriptor.interface.hasInterfaceObject() args = [ - Argument('&JSRef', 'window'), + Argument('*mut JSContext', 'cx'), + Argument('*mut JSObject', 'global'), ] CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'void', args, pub=True) @@ -2107,8 +2111,6 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod): def definition_body(self): return CGGeneric("""\ -let cx = window.get_cx(); -let global = window.reflector().get_jsobject(); assert!(global.is_not_null()); assert!(GetProtoObject(cx, global, global).is_not_null());""") @@ -4267,7 +4269,8 @@ class CGDictionary(CGThing): class CGRegisterProtos(CGAbstractMethod): def __init__(self, config): arguments = [ - Argument('&JSRef', 'window'), + Argument('*mut JSContext', 'cx'), + Argument('*mut JSObject', 'global'), ] CGAbstractMethod.__init__(self, None, 'Register', 'void', arguments, unsafe=False, pub=True) @@ -4275,7 +4278,7 @@ class CGRegisterProtos(CGAbstractMethod): def definition_body(self): return CGList([ - CGGeneric("codegen::Bindings::%sBinding::DefineDOMInterface(window);" % desc.name) + CGGeneric("codegen::Bindings::%sBinding::DefineDOMInterface(cx, global);" % desc.name) for desc in self.config.getDescriptors(hasInterfaceObject=True, register=True) ], "\n") @@ -5303,8 +5306,8 @@ class GlobalGenRoots(): return CGImports(code, [], [ 'dom::bindings::codegen', 'dom::bindings::codegen::PrototypeList::proxies', - 'dom::bindings::js::{JS, JSRef}', - 'dom::window::Window', + 'js::jsapi::JSContext', + 'js::jsapi::JSObject', 'libc', ]) diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index c584d5735f8..dfd121091cf 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -5,7 +5,6 @@ //! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing //! and layout tasks. -use dom::bindings::codegen::RegisterBindings; use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, EventCast}; use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalSettable}; use dom::bindings::js::OptionalRootable; @@ -548,10 +547,6 @@ impl ScriptTask { let document = Document::new(&*window, Some(url.clone()), HTMLDocument, None).root(); window.deref().init_browser_context(&*document); - with_compartment((**cx).ptr, window.reflector().get_jsobject(), || { - RegisterBindings::Register(&*window); - }); - self.compositor.set_ready_state(Loading); // Parse HTML. //