mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Define interface members on the global object directly (fixes #4593)
This commit is contained in:
parent
0729000b56
commit
6da56f7e67
11 changed files with 63 additions and 905 deletions
|
@ -257,11 +257,7 @@ pub unsafe fn create_callback_interface_object(
|
|||
assert!(!constants.is_empty());
|
||||
rval.set(JS_NewObject(cx, ptr::null()));
|
||||
assert!(!rval.ptr.is_null());
|
||||
for guard in constants {
|
||||
if let Some(specs) = guard.expose(cx, rval.handle()) {
|
||||
define_constants(cx, rval.handle(), specs);
|
||||
}
|
||||
}
|
||||
define_guarded_constants(cx, rval.handle(), constants);
|
||||
define_name(cx, rval.handle(), name);
|
||||
define_on_global_object(cx, global, name, rval.handle());
|
||||
}
|
||||
|
@ -421,11 +417,7 @@ unsafe fn create_object(
|
|||
assert!(!rval.ptr.is_null());
|
||||
define_guarded_methods(cx, rval.handle(), methods);
|
||||
define_guarded_properties(cx, rval.handle(), properties);
|
||||
for guard in constants {
|
||||
if let Some(specs) = guard.expose(cx, rval.handle()) {
|
||||
define_constants(cx, rval.handle(), specs);
|
||||
}
|
||||
}
|
||||
define_guarded_constants(cx, rval.handle(), constants);
|
||||
}
|
||||
|
||||
unsafe fn create_unscopable_object(
|
||||
|
@ -444,6 +436,18 @@ unsafe fn create_unscopable_object(
|
|||
}
|
||||
}
|
||||
|
||||
/// Conditionally define constants on an object.
|
||||
pub unsafe fn define_guarded_constants(
|
||||
cx: *mut JSContext,
|
||||
obj: HandleObject,
|
||||
constants: &[Guard<&[ConstantSpec]>]) {
|
||||
for guard in constants {
|
||||
if let Some(specs) = guard.expose(cx, obj) {
|
||||
define_constants(cx, obj, specs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Conditionally define methods on an object.
|
||||
pub unsafe fn define_guarded_methods(
|
||||
cx: *mut JSContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue