diff options
author | Ms2ger <ms2ger@gmail.com> | 2013-11-03 14:47:26 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2013-11-06 21:56:36 +0100 |
commit | edd9c1d5ebb17c68bc1c5b809099aecc3f59943b (patch) | |
tree | 3ac8222096b23c3adf9dae8a1756f4ea549aa726 /src/components/script/dom | |
parent | 5c101526a1432ca783028d70185f78ae0d2559a1 (diff) | |
download | servo-edd9c1d5ebb17c68bc1c5b809099aecc3f59943b.tar.gz servo-edd9c1d5ebb17c68bc1c5b809099aecc3f59943b.zip |
Remove WrapNativeParent and nearby cleanup.
Diffstat (limited to 'src/components/script/dom')
-rw-r--r-- | src/components/script/dom/bindings/callback.rs | 13 | ||||
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 28 | ||||
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 16 |
3 files changed, 19 insertions, 38 deletions
diff --git a/src/components/script/dom/bindings/callback.rs b/src/components/script/dom/bindings/callback.rs index 6cf88b353ed..f7f519012ea 100644 --- a/src/components/script/dom/bindings/callback.rs +++ b/src/components/script/dom/bindings/callback.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use dom::bindings::utils::{WrapNativeParent, Reflectable}; +use dom::bindings::utils::Reflectable; use js::jsapi::{JSContext, JSObject, JS_WrapObject, JSVal, JS_ObjectIsCallable}; use js::jsapi::JS_GetProperty; use js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT}; @@ -67,15 +67,10 @@ pub fn GetJSObjectFromCallback<T: CallbackContainer>(callback: &T) -> *JSObject #[fixed_stack_segment] pub fn WrapCallThisObject<T: 'static + CallbackContainer + Reflectable>(cx: *JSContext, - scope: *JSObject, + _scope: *JSObject, p: @mut T) -> *JSObject { - let mut obj = GetJSObjectFromCallback(p); - if obj.is_null() { - obj = WrapNativeParent(cx, scope, Some(p as @mut Reflectable)); - if obj.is_null() { - return ptr::null(); - } - } + let obj = GetJSObjectFromCallback(p); + assert!(obj.is_not_null()); unsafe { if JS_WrapObject(cx, &obj) == 0 { diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 1d1eb1e4fe0..2efe1af1359 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -2506,8 +2506,8 @@ class CGAbstractMethod(CGThing): def CreateBindingJSObject(descriptor, parent=None): if descriptor.proxy: - handler = """ //let reflector = aObject.mut_reflector(); - + assert not descriptor.createGlobal + handler = """ let page = page_from_context(aCx); let handler = (*page).js_info.get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint)); """ % descriptor.name @@ -2546,33 +2546,29 @@ class CGWrapWithCacheMethod(CGAbstractMethod): return """return aObject->GetJSObject();""" if not self.descriptor.createGlobal: - return """let mut parent = aObject.GetParentObject(aCx); - let parent = WrapNativeParent(aCx, aScope, parent); - if parent.is_null() { - return ptr::null(); - } + return """ + assert!(aScope.is_not_null()); + assert!(((*JS_GetClass(aScope)).flags & JSCLASS_IS_GLOBAL) != 0); - //JSAutoCompartment ac(aCx, parent); - let global = JS_GetGlobalForObject(aCx, parent); - let proto = GetProtoObject(aCx, global, global); + //JSAutoCompartment ac(aCx, aScope); + let proto = GetProtoObject(aCx, aScope, aScope); if proto.is_null() { return ptr::null(); } - - let reflector = aObject.mut_reflector(); %s //NS_ADDREF(aObject); - (*reflector).set_jsobject(obj); + aObject.mut_reflector().set_jsobject(obj); - return obj;""" % (CreateBindingJSObject(self.descriptor, "parent")) + return obj;""" % (CreateBindingJSObject(self.descriptor, "aScope")) else: - return """ let reflector = aObject.mut_reflector(); + return """ + assert!(aScope.is_null()); %s let proto = GetProtoObject(aCx, obj, obj); JS_SetPrototype(aCx, obj, proto); - (*reflector).set_jsobject(obj); + aObject.mut_reflector().set_jsobject(obj); return obj;""" % CreateBindingJSObject(self.descriptor) class CGWrapMethod(CGAbstractMethod): diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index 2754d6261a0..9f258c2424f 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -18,7 +18,7 @@ use std::unstable::raw::Box; use js::glue::*; use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL}; use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily}; -use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewObject, JS_NewFunction, JS_GetGlobalObject}; +use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewObject, JS_NewFunction}; use js::jsapi::{JS_DefineProperties, JS_WrapValue, JS_ForwardGetPropertyTo}; use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength}; use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate}; @@ -567,6 +567,8 @@ impl Reflector { } pub fn set_jsobject(&mut self, object: *JSObject) { + assert!(self.object.is_null()); + assert!(object.is_not_null()); self.object = object; } @@ -593,18 +595,6 @@ pub fn GetReflector(cx: *JSContext, reflector: &Reflector, } #[fixed_stack_segment] -pub fn WrapNativeParent(cx: *JSContext, _scope: *JSObject, mut p: Option<@mut Reflectable>) -> *JSObject { - match p { - Some(ref mut p) => { - let obj = p.reflector().get_jsobject(); - assert!(obj.is_not_null()); - obj - } - None => unsafe { JS_GetGlobalObject(cx) } - } -} - -#[fixed_stack_segment] pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool, vp: *JSVal) -> bool { unsafe { |