mirror of
https://github.com/servo/servo.git
synced 2025-06-19 22:59:03 +01:00
Make proxy finalizers retrieve the DOM object from the right slot.
This commit is contained in:
parent
92f6599854
commit
bc81716c30
2 changed files with 11 additions and 6 deletions
|
@ -4027,7 +4027,7 @@ def finalizeHook(descriptor, hookName, context):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
assert descriptor.nativeIsISupports
|
assert descriptor.nativeIsISupports
|
||||||
release = """let val = JS_GetReservedSlot(obj, 0);
|
release = """let val = JS_GetReservedSlot(obj, dom_object_slot(obj));
|
||||||
let _: @mut %s = cast::transmute(RUST_JSVAL_TO_PRIVATE(val));
|
let _: @mut %s = cast::transmute(RUST_JSVAL_TO_PRIVATE(val));
|
||||||
debug!("%s finalize: %%p", this);
|
debug!("%s finalize: %%p", this);
|
||||||
""" % (descriptor.concreteType, descriptor.concreteType)
|
""" % (descriptor.concreteType, descriptor.concreteType)
|
||||||
|
|
|
@ -121,14 +121,19 @@ pub fn is_dom_proxy(obj: *JSObject) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fixed_stack_segment]
|
#[fixed_stack_segment]
|
||||||
pub unsafe fn unwrap<T>(obj: *JSObject) -> T {
|
pub unsafe fn dom_object_slot(obj: *JSObject) -> u32 {
|
||||||
let clasp = JS_GetClass(obj);
|
let clasp = JS_GetClass(obj);
|
||||||
let slot = if is_dom_class(clasp) {
|
if is_dom_class(clasp) {
|
||||||
DOM_OBJECT_SLOT
|
DOM_OBJECT_SLOT as u32
|
||||||
} else {
|
} else {
|
||||||
assert!(is_dom_proxy(obj));
|
assert!(is_dom_proxy(obj));
|
||||||
DOM_PROXY_OBJECT_SLOT
|
DOM_PROXY_OBJECT_SLOT as u32
|
||||||
} as u32;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[fixed_stack_segment]
|
||||||
|
pub unsafe fn unwrap<T>(obj: *JSObject) -> T {
|
||||||
|
let slot = dom_object_slot(obj);
|
||||||
let val = JS_GetReservedSlot(obj, slot);
|
let val = JS_GetReservedSlot(obj, slot);
|
||||||
cast::transmute(RUST_JSVAL_TO_PRIVATE(val))
|
cast::transmute(RUST_JSVAL_TO_PRIVATE(val))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue