aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/refcounted.rs
diff options
context:
space:
mode:
authorchansuke <chansuke@georepublic.de>2018-09-18 23:24:15 +0900
committerJosh Matthews <josh@joshmatthews.net>2018-09-19 17:40:47 -0400
commitc37a345dc9f4dda6ea29c42f96f6c7201c42cbac (patch)
tree1f05b49bac02318455a59d5b143c186fd872bdb9 /components/script/dom/bindings/refcounted.rs
parent2ca7a134736bb4759ff209c1bc0b6dc3cc1984c9 (diff)
downloadservo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.tar.gz
servo-c37a345dc9f4dda6ea29c42f96f6c7201c42cbac.zip
Format script component
Diffstat (limited to 'components/script/dom/bindings/refcounted.rs')
-rw-r--r--components/script/dom/bindings/refcounted.rs36
1 files changed, 21 insertions, 15 deletions
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs
index 2c5a179ca2b..11a422a2f3f 100644
--- a/components/script/dom/bindings/refcounted.rs
+++ b/components/script/dom/bindings/refcounted.rs
@@ -39,9 +39,9 @@ use std::rc::Rc;
use std::sync::{Arc, Weak};
use task::TaskOnce;
-
-#[allow(missing_docs)] // FIXME
-mod dummy { // Attributes don’t apply through the macro.
+#[allow(missing_docs)] // FIXME
+mod dummy {
+ // Attributes don’t apply through the macro.
use std::cell::RefCell;
use std::rc::Rc;
use super::LiveDOMReferences;
@@ -50,7 +50,6 @@ mod dummy { // Attributes don’t apply through the macro.
}
pub use self::dummy::LIVE_REFERENCES;
-
/// A pointer to a Rust DOM object that needs to be destroyed.
pub struct TrustedReference(*const libc::c_void);
unsafe impl Send for TrustedReference {}
@@ -98,19 +97,28 @@ impl TrustedPromise {
LIVE_REFERENCES.with(|ref r| {
let r = r.borrow();
let live_references = r.as_ref().unwrap();
- assert_eq!(self.owner_thread, (&*live_references) as *const _ as *const libc::c_void);
+ assert_eq!(
+ self.owner_thread,
+ (&*live_references) as *const _ as *const libc::c_void
+ );
// Borrow-check error requires the redundant `let promise = ...; promise` here.
- let promise = match live_references.promise_table.borrow_mut().entry(self.dom_object) {
+ let promise = match live_references
+ .promise_table
+ .borrow_mut()
+ .entry(self.dom_object)
+ {
Occupied(mut entry) => {
let promise = {
let promises = entry.get_mut();
- promises.pop().expect("rooted promise list unexpectedly empty")
+ promises
+ .pop()
+ .expect("rooted promise list unexpectedly empty")
};
if entry.get().is_empty() {
entry.remove();
}
promise
- }
+ },
Vacant(_) => unreachable!(),
};
promise
@@ -182,9 +190,7 @@ impl<T: DomObject> Trusted<T> {
let live_references = r.as_ref().unwrap();
self.owner_thread == (&*live_references) as *const _ as *const libc::c_void
}));
- unsafe {
- DomRoot::from_ref(&*(self.refcount.0 as *const T))
- }
+ unsafe { DomRoot::from_ref(&*(self.refcount.0 as *const T)) }
}
}
@@ -246,15 +252,15 @@ impl LiveDOMReferences {
let refcount = Arc::new(TrustedReference::new(ptr));
entry.insert(Arc::downgrade(&refcount));
refcount
- }
+ },
}
}
}
/// Remove null entries from the live references table
-fn remove_nulls<K: Eq + Hash + Clone, V> (table: &mut HashMap<K, Weak<V>>) {
- let to_remove: Vec<K> =
- table.iter()
+fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) {
+ let to_remove: Vec<K> = table
+ .iter()
.filter(|&(_, value)| Weak::upgrade(value).is_none())
.map(|(key, _)| key.clone())
.collect();