mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make WebIDL constructors take a more specific global if possible (fixes #14071)
This commit is contained in:
parent
8af2327e95
commit
973f77c006
17 changed files with 50 additions and 49 deletions
|
@ -3168,7 +3168,7 @@ class CGCallGenerator(CGThing):
|
|||
|
||||
if isFallible:
|
||||
if static:
|
||||
glob = "&global"
|
||||
glob = "global.upcast::<GlobalScope>()"
|
||||
else:
|
||||
glob = "&this.global()"
|
||||
|
||||
|
@ -5245,12 +5245,14 @@ class CGClassConstructHook(CGAbstractExternMethod):
|
|||
assert constructor
|
||||
CGAbstractExternMethod.__init__(self, descriptor, name, 'bool', args)
|
||||
self.constructor = constructor
|
||||
self.exposureSet = descriptor.interface.exposureSet
|
||||
|
||||
def definition_body(self):
|
||||
preamble = CGGeneric("""\
|
||||
let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());
|
||||
let args = CallArgs::from_vp(vp, argc);
|
||||
""")
|
||||
preamble = """let global = GlobalScope::from_object(JS_CALLEE(cx, vp).to_object());\n"""
|
||||
if len(self.exposureSet) == 1:
|
||||
preamble += "let global = Root::downcast::<dom::types::%s>(global).unwrap();\n" % list(self.exposureSet)[0]
|
||||
preamble += """let args = CallArgs::from_vp(vp, argc);\n"""
|
||||
preamble = CGGeneric(preamble)
|
||||
name = self.constructor.identifier.name
|
||||
nativeName = MakeNativeName(self.descriptor.binaryNameFor(name))
|
||||
callGenerator = CGMethodCall(["&global"], nativeName, True,
|
||||
|
@ -5582,6 +5584,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'dom::bindings::error::throw_dom_exception',
|
||||
'dom::bindings::guard::Condition',
|
||||
'dom::bindings::guard::Guard',
|
||||
'dom::bindings::inheritance::Castable',
|
||||
'dom::bindings::proxyhandler',
|
||||
'dom::bindings::proxyhandler::ensure_expando_object',
|
||||
'dom::bindings::proxyhandler::fill_property_descriptor',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue