aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/interface.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-01-23 23:32:51 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2016-02-25 15:15:44 +0100
commitca979e115b087cf627baf2be8d54ea47b1f773a1 (patch)
tree7dcfe3f4380a468f766ec2291dc162530bd2d061 /components/script/dom/bindings/interface.rs
parent2c4d5da86685537b550f05a6a142c6543320ab0f (diff)
downloadservo-ca979e115b087cf627baf2be8d54ea47b1f773a1.tar.gz
servo-ca979e115b087cf627baf2be8d54ea47b1f773a1.zip
Cache legacy callback interface objects in proto_or_icache_array
We need them to be cached to not instantiate them multiple times with lazy initialisation.
Diffstat (limited to 'components/script/dom/bindings/interface.rs')
-rw-r--r--components/script/dom/bindings/interface.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs
index bb98c06f63a..a5bc3ec513c 100644
--- a/components/script/dom/bindings/interface.rs
+++ b/components/script/dom/bindings/interface.rs
@@ -178,13 +178,14 @@ pub unsafe fn create_callback_interface_object(
cx: *mut JSContext,
receiver: HandleObject,
constants: &'static [ConstantSpec],
- name: &'static [u8]) {
+ name: &'static [u8],
+ rval: MutableHandleObject) {
assert!(!constants.is_empty());
- let interface_object = RootedObject::new(cx, JS_NewObject(cx, ptr::null()));
- assert!(!interface_object.ptr.is_null());
- define_constants(cx, interface_object.handle(), constants);
- define_name(cx, interface_object.handle(), name);
- define_on_global_object(cx, receiver, name, interface_object.handle());
+ rval.set(JS_NewObject(cx, ptr::null()));
+ assert!(!rval.ptr.is_null());
+ define_constants(cx, rval.handle(), constants);
+ define_name(cx, rval.handle(), name);
+ define_on_global_object(cx, receiver, name, rval.handle());
}
/// Create the interface prototype object of a non-callback interface.