aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/cell.rs7
-rw-r--r--components/script/dom/bindings/refcounted.rs6
-rw-r--r--components/script/page.rs4
-rw-r--r--components/script/script_task.rs10
4 files changed, 17 insertions, 10 deletions
diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs
index 41ebf76f426..fc0a845b748 100644
--- a/components/script/dom/bindings/cell.rs
+++ b/components/script/dom/bindings/cell.rs
@@ -41,6 +41,13 @@ impl<T> DOMRefCell<T> {
&*self.value.as_unsafe_cell().get()
}
+ /// Borrow the contents for the purpose of script deallocation.
+ ///
+ pub unsafe fn borrow_for_script_deallocation<'a>(&'a self) -> &'a mut T {
+ debug_assert!(task_state::get().contains(SCRIPT));
+ &mut *self.value.as_unsafe_cell().get()
+ }
+
/// Is the cell mutably borrowed?
///
/// For safety checks in debug builds only.
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs
index 742f187e061..35a87411fd9 100644
--- a/components/script/dom/bindings/refcounted.rs
+++ b/components/script/dom/bindings/refcounted.rs
@@ -188,9 +188,3 @@ impl LiveDOMReferences {
})
}
}
-
-impl Drop for LiveDOMReferences {
- fn drop(&mut self) {
- assert!(self.table.borrow().keys().count() == 0);
- }
-}
diff --git a/components/script/page.rs b/components/script/page.rs
index b9dce92fac5..954813e607c 100644
--- a/components/script/page.rs
+++ b/components/script/page.rs
@@ -273,6 +273,10 @@ impl Page {
self.js_info.borrow_mut()
}
+ pub unsafe fn unsafe_mut_js_info<'a>(&'a self) -> &'a mut Option<JSPageInfo> {
+ self.js_info.borrow_for_script_deallocation()
+ }
+
pub fn js_info<'a>(&'a self) -> Ref<'a, Option<JSPageInfo>> {
self.js_info.borrow()
}
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 11127f67733..64242d4b297 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -248,11 +248,13 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
fn drop(&mut self) {
match self.owner {
Some(owner) => {
- let page = owner.page.borrow_mut();
- for page in page.iter() {
- *page.mut_js_info() = None;
+ unsafe {
+ let page = owner.page.borrow_for_script_deallocation();
+ for page in page.iter() {
+ *page.unsafe_mut_js_info() = None;
+ }
+ *owner.js_context.borrow_for_script_deallocation() = None;
}
- *owner.js_context.borrow_mut() = None;
}
None => (),
}