aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/callback.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-19 17:47:27 -0400
committerGitHub <noreply@github.com>2018-09-19 17:47:27 -0400
commitdf2adebefdfa3da49f173e480fa1e56450f9bda2 (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/bindings/callback.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
parentc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (diff)
downloadservo-df2adebefdfa3da49f173e480fa1e56450f9bda2.tar.gz
servo-df2adebefdfa3da49f173e480fa1e56450f9bda2.zip
Auto merge of #21737 - chansuke:format_script, r=jdm
Format script component --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix part of #21373. - [x] These changes do not require tests because they format code only. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21737) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/callback.rs')
-rw-r--r--components/script/dom/bindings/callback.rs41
1 files changed, 20 insertions, 21 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs
index 6b4d7cd981a..ddc11ce25da 100644
--- a/components/script/dom/bindings/callback.rs
+++ b/components/script/dom/bindings/callback.rs
@@ -53,7 +53,7 @@ pub struct CallbackObject {
///
/// ["callback context"]: https://heycam.github.io/webidl/#dfn-callback-context
/// [sometimes]: https://github.com/whatwg/html/issues/2248
- incumbent: Option<Dom<GlobalScope>>
+ incumbent: Option<Dom<GlobalScope>>,
}
impl Default for CallbackObject {
@@ -81,8 +81,11 @@ impl CallbackObject {
unsafe fn init(&mut self, cx: *mut JSContext, callback: *mut JSObject) {
self.callback.set(callback);
self.permanent_js_root.set(ObjectValue(callback));
- assert!(AddRawValueRoot(cx, self.permanent_js_root.get_unsafe(),
- b"CallbackObject::root\n".as_c_char_ptr()));
+ assert!(AddRawValueRoot(
+ cx,
+ self.permanent_js_root.get_unsafe(),
+ b"CallbackObject::root\n".as_c_char_ptr()
+ ));
}
}
@@ -94,7 +97,6 @@ impl Drop for CallbackObject {
RemoveRawValueRoot(cx, self.permanent_js_root.get_unsafe());
}
}
-
}
impl PartialEq for CallbackObject {
@@ -103,7 +105,6 @@ impl PartialEq for CallbackObject {
}
}
-
/// A trait to be implemented by concrete IDL callback function and
/// callback interface types.
pub trait CallbackContainer {
@@ -124,7 +125,6 @@ pub trait CallbackContainer {
}
}
-
/// A common base class for representing IDL callback function types.
#[derive(JSTraceable, PartialEq)]
#[must_root]
@@ -153,9 +153,6 @@ impl CallbackFunction {
}
}
-
-
-
/// A common base class for representing IDL callback interface types.
#[derive(JSTraceable, PartialEq)]
#[must_root]
@@ -194,19 +191,22 @@ impl CallbackInterface {
}
if !callable.is_object() || !IsCallable(callable.to_object()) {
- return Err(Error::Type(format!("The value of the {} property is not callable",
- name)));
+ return Err(Error::Type(format!(
+ "The value of the {} property is not callable",
+ name
+ )));
}
}
Ok(callable.get())
}
}
-
/// Wraps the reflector for `p` into the compartment of `cx`.
-pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
- p: &T,
- mut rval: MutableHandleObject) {
+pub fn wrap_call_this_object<T: DomObject>(
+ cx: *mut JSContext,
+ p: &T,
+ mut rval: MutableHandleObject,
+) {
rval.set(p.reflector().get_jsobject().get());
assert!(!rval.get().is_null());
@@ -217,7 +217,6 @@ pub fn wrap_call_this_object<T: DomObject>(cx: *mut JSContext,
}
}
-
/// A class that performs whatever setup we need to safely make a call while
/// this class is on the stack. After `new` returns, the call is safe to make.
pub struct CallSetup {
@@ -241,9 +240,7 @@ pub struct CallSetup {
impl CallSetup {
/// Performs the setup needed to make a call.
#[allow(unrooted_must_root)]
- pub fn new<T: CallbackContainer>(callback: &T,
- handling: ExceptionHandling)
- -> CallSetup {
+ pub fn new<T: CallbackContainer>(callback: &T, handling: ExceptionHandling) -> CallSetup {
let global = unsafe { GlobalScope::from_object(callback.callback()) };
let cx = global.get_cx();
@@ -270,8 +267,10 @@ impl Drop for CallSetup {
unsafe {
JS_LeaveCompartment(self.cx, self.old_compartment);
if self.handling == ExceptionHandling::Report {
- let _ac = JSAutoCompartment::new(self.cx,
- self.exception_global.reflector().get_jsobject().get());
+ let _ac = JSAutoCompartment::new(
+ self.cx,
+ self.exception_global.reflector().get_jsobject().get(),
+ );
report_pending_exception(self.cx, true);
}
drop(self.incumbent_script.take());