mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Reuse report_pending_exception in CallSetup.
This commit is contained in:
parent
061cf054e7
commit
72540009d5
1 changed files with 4 additions and 10 deletions
|
@ -4,15 +4,14 @@
|
||||||
|
|
||||||
//! Base classes to work with IDL callbacks.
|
//! Base classes to work with IDL callbacks.
|
||||||
|
|
||||||
use dom::bindings::error::{Error, Fallible};
|
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||||
use dom::bindings::global::global_root_from_object;
|
use dom::bindings::global::global_root_from_object;
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
use js::jsapi::GetGlobalForObjectCrossCompartment;
|
use js::jsapi::GetGlobalForObjectCrossCompartment;
|
||||||
use js::jsapi::JSAutoCompartment;
|
use js::jsapi::JS_GetProperty;
|
||||||
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
|
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
|
||||||
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
|
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
|
||||||
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
|
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
|
||||||
use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException};
|
|
||||||
use js::jsval::{JSVal, UndefinedValue};
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use js::rust::RootedGuard;
|
use js::rust::RootedGuard;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -189,13 +188,8 @@ impl<'a> Drop for CallSetup<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_LeaveCompartment(self.cx, self.old_compartment);
|
JS_LeaveCompartment(self.cx, self.old_compartment);
|
||||||
}
|
if self.handling == ExceptionHandling::Report {
|
||||||
let need_to_deal_with_exception = self.handling == ExceptionHandling::Report &&
|
report_pending_exception(self.cx, *self.exception_compartment);
|
||||||
unsafe { JS_IsExceptionPending(self.cx) };
|
|
||||||
if need_to_deal_with_exception {
|
|
||||||
unsafe {
|
|
||||||
let _ac = JSAutoCompartment::new(self.cx, *self.exception_compartment);
|
|
||||||
JS_ReportPendingException(self.cx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue