mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Pass a JSContext and a reflector to RegisterBindings::Register.
This makes the generated code less dependent on the fact that all global objects are Windows.
This commit is contained in:
parent
2191a578c6
commit
5baff0cc2c
2 changed files with 8 additions and 8 deletions
|
@ -2098,7 +2098,8 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert descriptor.interface.hasInterfaceObject()
|
assert descriptor.interface.hasInterfaceObject()
|
||||||
args = [
|
args = [
|
||||||
Argument('&JSRef<Window>', 'window'),
|
Argument('*mut JSContext', 'cx'),
|
||||||
|
Argument('*mut JSObject', 'global'),
|
||||||
]
|
]
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'void', args, pub=True)
|
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface', 'void', args, pub=True)
|
||||||
|
|
||||||
|
@ -2107,8 +2108,6 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
let cx = window.get_cx();
|
|
||||||
let global = window.reflector().get_jsobject();
|
|
||||||
assert!(global.is_not_null());
|
assert!(global.is_not_null());
|
||||||
assert!(GetProtoObject(cx, global, global).is_not_null());""")
|
assert!(GetProtoObject(cx, global, global).is_not_null());""")
|
||||||
|
|
||||||
|
@ -4267,7 +4266,8 @@ class CGDictionary(CGThing):
|
||||||
class CGRegisterProtos(CGAbstractMethod):
|
class CGRegisterProtos(CGAbstractMethod):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
arguments = [
|
arguments = [
|
||||||
Argument('&JSRef<Window>', 'window'),
|
Argument('*mut JSContext', 'cx'),
|
||||||
|
Argument('*mut JSObject', 'global'),
|
||||||
]
|
]
|
||||||
CGAbstractMethod.__init__(self, None, 'Register', 'void', arguments,
|
CGAbstractMethod.__init__(self, None, 'Register', 'void', arguments,
|
||||||
unsafe=False, pub=True)
|
unsafe=False, pub=True)
|
||||||
|
@ -4275,7 +4275,7 @@ class CGRegisterProtos(CGAbstractMethod):
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGList([
|
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)
|
for desc in self.config.getDescriptors(hasInterfaceObject=True, register=True)
|
||||||
], "\n")
|
], "\n")
|
||||||
|
|
||||||
|
@ -5303,8 +5303,8 @@ class GlobalGenRoots():
|
||||||
return CGImports(code, [], [
|
return CGImports(code, [], [
|
||||||
'dom::bindings::codegen',
|
'dom::bindings::codegen',
|
||||||
'dom::bindings::codegen::PrototypeList::proxies',
|
'dom::bindings::codegen::PrototypeList::proxies',
|
||||||
'dom::bindings::js::{JS, JSRef}',
|
'js::jsapi::JSContext',
|
||||||
'dom::window::Window',
|
'js::jsapi::JSObject',
|
||||||
'libc',
|
'libc',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ impl ScriptTask {
|
||||||
window.deref().init_browser_context(&*document);
|
window.deref().init_browser_context(&*document);
|
||||||
|
|
||||||
with_compartment((**cx).ptr, window.reflector().get_jsobject(), || {
|
with_compartment((**cx).ptr, window.reflector().get_jsobject(), || {
|
||||||
RegisterBindings::Register(&*window);
|
RegisterBindings::Register(window.get_cx(), window.reflector().get_jsobject());
|
||||||
});
|
});
|
||||||
|
|
||||||
self.compositor.set_ready_state(Loading);
|
self.compositor.set_ready_state(Loading);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue