aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-03-06 18:45:29 +0100
committerAnthony Ramine <nox@nox.paris>2020-03-06 18:45:29 +0100
commit05077d31c8083644d004c559a4cf8423dbd48d66 (patch)
tree28d8bb3db54d18ca8ef453e0d7d71780fc6d8b67 /components/script/dom/bindings/codegen
parent356c4e0bc860307ca373f85156e816f8c0a0d132 (diff)
downloadservo-05077d31c8083644d004c559a4cf8423dbd48d66.tar.gz
servo-05077d31c8083644d004c559a4cf8423dbd48d66.zip
Change how we reflect DOM objects in codegen
We now go through <Root<MaybeUnreflectedDom<T>>>::reflect_with, to decrease the amount of bad stuff we can end up doing. This avoids a source of vtable pointer instability that could cause issues down the road.
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index a06414c306e..f7ce60cc80c 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2728,7 +2728,7 @@ assert!(!obj.is_null());
SetProxyReservedSlot(
obj.get(),
0,
- &PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
+ &PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
);
"""
else:
@@ -2742,7 +2742,7 @@ assert!(!obj.is_null());
JS_SetReservedSlot(
obj.get(),
DOM_OBJECT_SLOT,
- &PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
+ &PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
);
"""
create = create % {"concreteType": self.descriptor.concreteType}
@@ -2765,11 +2765,11 @@ GetProtoObject(cx, scope, proto.handle_mut());
assert!(!proto.is_null());
%(createObject)s
-raw.init_reflector(obj.get());
+let root = raw.reflect_with(obj.get());
%(copyUnforgeable)s
-DomRoot::from_ref(&*raw)\
+DomRoot::from_ref(&*root)\
""" % {'copyUnforgeable': unforgeable, 'createObject': create})
@@ -2809,12 +2809,12 @@ rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
create_global_object(
cx,
&Class.base,
- &*raw as *const %(concreteType)s as *const libc::c_void,
+ raw.as_ptr() as *const %(concreteType)s as *const libc::c_void,
_trace,
obj.handle_mut());
assert!(!obj.is_null());
-raw.init_reflector(obj.get());
+let root = raw.reflect_with(obj.get());
let _ac = JSAutoRealm::new(*cx, obj.get());
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
@@ -2828,7 +2828,7 @@ assert!(immutable);
%(unforgeable)s
-DomRoot::from_ref(&*raw)\
+DomRoot::from_ref(&*root)\
""" % values)