mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Use the try macro in unwrap_jsmanaged.
This commit is contained in:
parent
58e7b8c154
commit
e1dae2f59b
1 changed files with 9 additions and 11 deletions
|
@ -127,7 +127,7 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
|
||||||
proto_id: PrototypeList::ID,
|
proto_id: PrototypeList::ID,
|
||||||
proto_depth: uint) -> Result<JS<T>, ()> {
|
proto_depth: uint) -> Result<JS<T>, ()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let dom_class = get_dom_class(obj).or_else(|_| {
|
let dom_class = try!(get_dom_class(obj).or_else(|_| {
|
||||||
if IsWrapper(obj) == 1 {
|
if IsWrapper(obj) == 1 {
|
||||||
debug!("found wrapper");
|
debug!("found wrapper");
|
||||||
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::null_mut());
|
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::null_mut());
|
||||||
|
@ -143,17 +143,15 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
|
||||||
debug!("not a dom wrapper");
|
debug!("not a dom wrapper");
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
dom_class.and_then(|dom_class| {
|
if dom_class.interface_chain[proto_depth] == proto_id {
|
||||||
if dom_class.interface_chain[proto_depth] == proto_id {
|
debug!("good prototype");
|
||||||
debug!("good prototype");
|
Ok(JS::from_raw(unwrap(obj)))
|
||||||
Ok(JS::from_raw(unwrap(obj)))
|
} else {
|
||||||
} else {
|
debug!("bad prototype");
|
||||||
debug!("bad prototype");
|
Err(())
|
||||||
Err(())
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue