mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove deref_mut from Untraceable/Traceable (fixes #2736)
This commit is contained in:
parent
f3b9c11f7a
commit
7cc8e2eb57
3 changed files with 7 additions and 17 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue