diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-08-25 12:51:52 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-08-25 14:29:16 +0200 |
commit | 6da56f7e67262816bcac3523b4ebdbfe1fe1c139 (patch) | |
tree | 95323e2a984ca2a0cb20b5e2b733f182fffbe617 /components/script/dom/bindings/interface.rs | |
parent | 0729000b56bffd943bb7ed925e28ebc2f5fb2adf (diff) | |
download | servo-6da56f7e67262816bcac3523b4ebdbfe1fe1c139.tar.gz servo-6da56f7e67262816bcac3523b4ebdbfe1fe1c139.zip |
Define interface members on the global object directly (fixes #4593)
Diffstat (limited to 'components/script/dom/bindings/interface.rs')
-rw-r--r-- | components/script/dom/bindings/interface.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index d92510754d5..1e21c3db651 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -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, |