aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2014-07-01 00:59:52 +0530
committerManish Goregaokar <manishsmail@gmail.com>2014-07-01 00:59:52 +0530
commit7cc8e2eb5753c17fcbd171f69685ff6c98d23f03 (patch)
treeab92d92129efd718f9fa02c41e37ad219be8fee3
parentf3b9c11f7a8d3a834bb2547639eb2261210a1695 (diff)
downloadservo-7cc8e2eb5753c17fcbd171f69685ff6c98d23f03.tar.gz
servo-7cc8e2eb5753c17fcbd171f69685ff6c98d23f03.zip
Remove deref_mut from Untraceable/Traceable (fixes #2736)
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py6
-rw-r--r--src/components/script/dom/bindings/trace.rs12
-rw-r--r--src/components/script/dom/bindings/utils.rs6
3 files changed, 7 insertions, 17 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 58e805a0c19..17001fd734a 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1757,7 +1757,8 @@ def CreateBindingJSObject(descriptor, parent=None):
assert not descriptor.createGlobal
create += """
let js_info = aScope.deref().page().js_info();
-let handler = js_info.get_ref().dom_static.proxy_handlers.deref().get(&(PrototypeList::id::%s as uint));
+let mut handlers = js_info.get_ref().dom_static.proxy_handlers.deref().borrow_mut();
+let handler = handlers.get(&(PrototypeList::id::%s as uint));
let mut private = PrivateValue(squirrel_away_unique(aObject) as *libc::c_void);
let obj = with_compartment(aCx, proto, || {
NewProxyObject(aCx, *handler,
@@ -2080,7 +2081,8 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
getPrototypeOf: None,
trace: Some(%s)
};
-js_info.dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
+let mut handlers = js_info.dom_static.proxy_handlers.deref().borrow_mut();
+handlers.insert(PrototypeList::id::%s as uint,
CreateProxyHandler(&traps, &Class as *_ as *_));
""" % (FINALIZE_HOOK_NAME,
diff --git a/src/components/script/dom/bindings/trace.rs b/src/components/script/dom/bindings/trace.rs
index 1c3655bbde3..8cbf32e0cbd 100644
--- a/src/components/script/dom/bindings/trace.rs
+++ b/src/components/script/dom/bindings/trace.rs
@@ -104,12 +104,6 @@ impl<T> Deref<T> for Untraceable<T> {
}
}
-impl<T> DerefMut<T> for Untraceable<T> {
- fn deref_mut<'a>(&'a mut self) -> &'a mut T {
- &mut self.inner
- }
-}
-
/// Encapsulates a type that can be traced but is boxed in a type we don't control
/// (such as RefCell). Wrap a field in Traceable and implement the Encodable trait
/// for that new concrete type to achieve magic compiler-derived trace hooks.
@@ -135,12 +129,6 @@ impl<T> Deref<T> for Traceable<T> {
}
}
-impl<T> DerefMut<T> for Traceable<T> {
- fn deref_mut<'a>(&'a mut self) -> &'a mut T {
- &mut self.inner
- }
-}
-
impl<S: Encoder<E>, E, T: Encodable<S, E>> Encodable<S, E> for Traceable<RefCell<T>> {
fn encode(&self, s: &mut S) -> Result<(), E> {
self.borrow().encode(s)
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index d2c1a43ccf8..2c494c2008e 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -14,7 +14,7 @@ use servo_util::str::DOMString;
use std::collections::hashmap::HashMap;
use libc;
use libc::c_uint;
-use std::cell::Cell;
+use std::cell::{Cell, RefCell};
use std::mem;
use std::cmp::PartialEq;
use std::ptr;
@@ -52,13 +52,13 @@ use js;
#[allow(raw_pointer_deriving)]
#[deriving(Encodable)]
pub struct GlobalStaticData {
- pub proxy_handlers: Untraceable<HashMap<uint, *libc::c_void>>,
+ pub proxy_handlers: Untraceable<RefCell<HashMap<uint, *libc::c_void>>>,
pub windowproxy_handler: Untraceable<*libc::c_void>,
}
pub fn GlobalStaticData() -> GlobalStaticData {
GlobalStaticData {
- proxy_handlers: Untraceable::new(HashMap::new()),
+ proxy_handlers: Untraceable::new(RefCell::new(HashMap::new())),
windowproxy_handler: Untraceable::new(browsercontext::new_window_proxy_handler()),
}
}