mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Remove all traces of owned DOM objects. This DOM is all about sharing.
This commit is contained in:
parent
db5eca4764
commit
6fbf40988f
9 changed files with 4 additions and 69 deletions
|
@ -25,10 +25,6 @@ impl CacheableWrapper for ClientRect {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"nyi")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||||
let mut unused = false;
|
let mut unused = false;
|
||||||
ClientRectBinding::Wrap(cx, scope, self, &mut unused)
|
ClientRectBinding::Wrap(cx, scope, self, &mut unused)
|
||||||
|
|
|
@ -24,10 +24,6 @@ impl CacheableWrapper for ClientRectList {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"nyi")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||||
let mut unused = false;
|
let mut unused = false;
|
||||||
ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
|
ClientRectListBinding::Wrap(cx, scope, self, &mut unused)
|
||||||
|
|
|
@ -2439,7 +2439,7 @@ def CreateBindingJSObject(descriptor, parent):
|
||||||
let handler = (*content).dom_static.proxy_handlers.get(&(prototypes::id::%s as uint));
|
let handler = (*content).dom_static.proxy_handlers.get(&(prototypes::id::%s as uint));
|
||||||
""" % descriptor.name
|
""" % descriptor.name
|
||||||
create = handler + """ let obj = NewProxyObject(aCx, *handler,
|
create = handler + """ let obj = NewProxyObject(aCx, *handler,
|
||||||
ptr::addr_of(&RUST_PRIVATE_TO_JSVAL(squirrel_away_ref(aObject) as *libc::c_void)),
|
ptr::addr_of(&RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void)),
|
||||||
proto, %s,
|
proto, %s,
|
||||||
ptr::null(), ptr::null());
|
ptr::null(), ptr::null());
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
|
@ -2454,7 +2454,7 @@ def CreateBindingJSObject(descriptor, parent):
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
||||||
RUST_PRIVATE_TO_JSVAL(squirrel_away_ref(aObject) as *libc::c_void));
|
RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void));
|
||||||
"""
|
"""
|
||||||
return create % parent
|
return create % parent
|
||||||
|
|
||||||
|
@ -2462,7 +2462,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert descriptor.interface.hasInterfacePrototypeObject()
|
assert descriptor.interface.hasInterfacePrototypeObject()
|
||||||
args = [Argument('*JSContext', 'aCx'), Argument('*JSObject', 'aScope'),
|
args = [Argument('*JSContext', 'aCx'), Argument('*JSObject', 'aScope'),
|
||||||
Argument('&mut BindingReference<' + descriptor.nativeType + '>', 'aObject'),
|
Argument('@mut ' + descriptor.nativeType, 'aObject'),
|
||||||
Argument('*mut bool', 'aTriedToWrap')]
|
Argument('*mut bool', 'aTriedToWrap')]
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap_', '*JSObject', args)
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap_', '*JSObject', args)
|
||||||
|
|
||||||
|
@ -2505,8 +2505,7 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', '*JSObject', args, inline=True, pub=True)
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', '*JSObject', args, inline=True, pub=True)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return " let mut binding = BindingReference(Right(aObject)); \
|
return "return Wrap_(aCx, aScope, aObject, aTriedToWrap);"
|
||||||
return Wrap_(aCx, aScope, &mut binding, aTriedToWrap);"
|
|
||||||
|
|
||||||
class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
|
class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
|
|
|
@ -145,10 +145,6 @@ impl CacheableWrapper for Document {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"need to implement wrapping");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
let content = task_from_context(cx);
|
let content = task_from_context(cx);
|
||||||
unsafe { create((*content).compartment.get(), self) }
|
unsafe { create((*content).compartment.get(), self) }
|
||||||
|
|
|
@ -11,10 +11,6 @@ impl CacheableWrapper for DOMParser {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"need to implement wrapping");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||||
let mut unused = false;
|
let mut unused = false;
|
||||||
DOMParserBinding::Wrap(cx, scope, self, &mut unused)
|
DOMParserBinding::Wrap(cx, scope, self, &mut unused)
|
||||||
|
|
|
@ -31,10 +31,6 @@ impl CacheableWrapper for HTMLCollection {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"nyi")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
||||||
let mut unused = false;
|
let mut unused = false;
|
||||||
HTMLCollectionBinding::Wrap(cx, scope, self, &mut unused)
|
HTMLCollectionBinding::Wrap(cx, scope, self, &mut unused)
|
||||||
|
|
|
@ -167,10 +167,6 @@ impl CacheableWrapper for AbstractNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"need to implement wrapping");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
fail!(~"need to implement wrapping");
|
fail!(~"need to implement wrapping");
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,12 +130,6 @@ pub unsafe fn squirrel_away<T>(x: @mut T) -> *rust_box<T> {
|
||||||
y
|
y
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
|
|
||||||
let y: *rust_box<T> = cast::reinterpret_cast(&x);
|
|
||||||
cast::forget(x);
|
|
||||||
y
|
|
||||||
}
|
|
||||||
|
|
||||||
//XXX very incomplete
|
//XXX very incomplete
|
||||||
pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
|
pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
|
||||||
let jsstr;
|
let jsstr;
|
||||||
|
@ -561,7 +555,6 @@ pub fn initialize_global(global: *JSObject) {
|
||||||
|
|
||||||
pub trait CacheableWrapper {
|
pub trait CacheableWrapper {
|
||||||
fn get_wrappercache(&mut self) -> &mut WrapperCache;
|
fn get_wrappercache(&mut self) -> &mut WrapperCache;
|
||||||
fn wrap_object_unique(~self, cx: *JSContext, scope: *JSObject) -> *JSObject;
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject;
|
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,39 +616,10 @@ pub fn WrapNativeParent(cx: *JSContext, scope: *JSObject, mut p: @mut CacheableW
|
||||||
wrapper
|
wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BindingReference<T>(Either<~T, @mut T>);
|
|
||||||
|
|
||||||
pub trait BindingObject {
|
pub trait BindingObject {
|
||||||
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper;
|
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T: BindingObject + CacheableWrapper> BindingReference<T> {
|
|
||||||
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
|
|
||||||
match **self {
|
|
||||||
Left(ref obj) => obj.GetParentObject(cx),
|
|
||||||
Right(ref obj) => obj.GetParentObject(cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_wrappercache(&mut self) -> &mut WrapperCache {
|
|
||||||
match **self {
|
|
||||||
Left(ref mut obj) => obj.get_wrappercache(),
|
|
||||||
Right(ref mut obj) => obj.get_wrappercache()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn squirrel_away_ref<R>(obj: &mut BindingReference<R>) -> *rust_box<R> {
|
|
||||||
let mut tmp: BindingReference<R> = unstable::intrinsics::init();
|
|
||||||
tmp <-> *obj;
|
|
||||||
unsafe {
|
|
||||||
match tmp {
|
|
||||||
BindingReference(Left(obj)) => squirrel_away_unique(obj),
|
|
||||||
BindingReference(Right(obj)) => squirrel_away(obj)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool,
|
pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool,
|
||||||
vp: *JSVal) -> bool {
|
vp: *JSVal) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -159,10 +159,6 @@ impl CacheableWrapper for Window {
|
||||||
unsafe { cast::transmute(&self.wrapper) }
|
unsafe { cast::transmute(&self.wrapper) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
|
||||||
fail!(~"should this be called?");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
fail!(~"should this be called?");
|
fail!(~"should this be called?");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue