mirror of
https://github.com/servo/servo.git
synced 2025-06-20 07:08:59 +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
|
@ -121,14 +121,19 @@ pub fn is_dom_proxy(obj: *JSObject) -> bool {
|
|||
}
|
||||
|
||||
#[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 slot = if is_dom_class(clasp) {
|
||||
DOM_OBJECT_SLOT
|
||||
if is_dom_class(clasp) {
|
||||
DOM_OBJECT_SLOT as u32
|
||||
} else {
|
||||
assert!(is_dom_proxy(obj));
|
||||
DOM_PROXY_OBJECT_SLOT
|
||||
} as u32;
|
||||
DOM_PROXY_OBJECT_SLOT 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);
|
||||
cast::transmute(RUST_JSVAL_TO_PRIVATE(val))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue