author | Tom Schuster <evilpies@gmail.com> |
Fri, 05 Apr 2013 15:21:02 +0200 | |
changeset 127829 | ddb51ef64845804c6c4b1af12b019cb1ffb3ef9f |
parent 127828 | 8e58ad2f288b61a9e299086f8b0b55595d005185 |
child 127830 | 1766922c611f729467f667de29447dad896e9978 |
push id | 24512 |
push user | ryanvm@gmail.com |
push date | Fri, 05 Apr 2013 20:13:49 +0000 |
treeherder | autoland@139b6ba547fa [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz, terrence |
bugs | 855411 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
content/xbl/src/nsXBLProtoImplField.cpp | file | annotate | diff | comparison | revisions | |
content/xbl/src/nsXBLProtoImplField.h | file | annotate | diff | comparison | revisions |
--- a/content/xbl/src/nsXBLProtoImplField.cpp +++ b/content/xbl/src/nsXBLProtoImplField.cpp @@ -326,87 +326,87 @@ FieldSetter(JSContext *cx, unsigned argc // why we do this. return xpc::WrapperFactory::WaiveXrayAndWrap(cx, args.mutableThisv().address()) && JS::CallNonGenericMethod<ValueHasISupportsPrivate, FieldSetterImpl> (cx, args); } nsresult nsXBLProtoImplField::InstallAccessors(JSContext* aCx, - JSObject* aTargetClassObject) + JS::Handle<JSObject*> aTargetClassObject) { MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx)); - JSObject* globalObject = JS_GetGlobalForObject(aCx, aTargetClassObject); - JSObject* scopeObject = xpc::GetXBLScope(aCx, globalObject); + JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject)); + JS::Rooted<JSObject*> scopeObject(aCx, xpc::GetXBLScope(aCx, globalObject)); // Don't install it if the field is empty; see also InstallField which also must // implement the not-empty requirement. if (IsEmpty()) { return NS_OK; } // Install a getter/setter pair which will resolve the field onto the actual // object, when invoked. // Get the field name as an id. - jsid id; + JS::Rooted<jsid> id(aCx); JS::TwoByteChars chars(mName, NS_strlen(mName)); - if (!JS_CharsToId(aCx, chars, &id)) + if (!JS_CharsToId(aCx, chars, id.address())) return NS_ERROR_OUT_OF_MEMORY; // Properties/Methods have historically taken precendence over fields. We // install members first, so just bounce here if the property is already // defined. JSBool found = false; if (!JS_AlreadyHasOwnPropertyById(aCx, aTargetClassObject, id, &found)) return NS_ERROR_FAILURE; if (found) return NS_OK; // FieldGetter and FieldSetter need to run in the XBL scope so that they can // see through any SOWs on their targets. // First, enter the XBL scope, and compile the functions there. JSAutoCompartment ac(aCx, scopeObject); - JS::Value wrappedClassObj = JS::ObjectValue(*aTargetClassObject); - if (!JS_WrapValue(aCx, &wrappedClassObj) || !JS_WrapId(aCx, &id)) + JS::Rooted<JS::Value> wrappedClassObj(aCx, JS::ObjectValue(*aTargetClassObject)); + if (!JS_WrapValue(aCx, wrappedClassObj.address()) || !JS_WrapId(aCx, id.address())) return NS_ERROR_OUT_OF_MEMORY; - JSObject *get = + JS::Rooted<JSObject*> get(aCx, JS_GetFunctionObject(js::NewFunctionByIdWithReserved(aCx, FieldGetter, - 0, 0, scopeObject, id)); + 0, 0, scopeObject, id))); if (!get) { return NS_ERROR_OUT_OF_MEMORY; } js::SetFunctionNativeReserved(get, XBLPROTO_SLOT, wrappedClassObj); js::SetFunctionNativeReserved(get, FIELD_SLOT, JS::StringValue(JSID_TO_STRING(id))); - JSObject *set = + JS::Rooted<JSObject*> set(aCx, JS_GetFunctionObject(js::NewFunctionByIdWithReserved(aCx, FieldSetter, - 1, 0, scopeObject, id)); + 1, 0, scopeObject, id))); if (!set) { return NS_ERROR_OUT_OF_MEMORY; } js::SetFunctionNativeReserved(set, XBLPROTO_SLOT, wrappedClassObj); js::SetFunctionNativeReserved(set, FIELD_SLOT, JS::StringValue(JSID_TO_STRING(id))); // Now, re-enter the class object's scope, wrap the getters/setters, and define // them there. JSAutoCompartment ac2(aCx, aTargetClassObject); - if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set) || - !JS_WrapId(aCx, &id)) + if (!JS_WrapObject(aCx, get.address()) || !JS_WrapObject(aCx, set.address()) || + !JS_WrapId(aCx, id.address())) { return NS_ERROR_OUT_OF_MEMORY; } if (!::JS_DefinePropertyById(aCx, aTargetClassObject, id, JS::UndefinedValue(), - JS_DATA_TO_FUNC_PTR(JSPropertyOp, get), - JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, set), + JS_DATA_TO_FUNC_PTR(JSPropertyOp, get.get()), + JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, set.get()), AccessorAttributes())) { return NS_ERROR_OUT_OF_MEMORY; } return NS_OK; } nsresult
--- a/content/xbl/src/nsXBLProtoImplField.h +++ b/content/xbl/src/nsXBLProtoImplField.h @@ -32,17 +32,17 @@ public: void SetNext(nsXBLProtoImplField* aNext) { mNext = aNext; } nsresult InstallField(nsIScriptContext* aContext, JSObject* aBoundNode, nsIURI* aBindingDocURI, bool* aDidInstall) const; nsresult InstallAccessors(JSContext* aCx, - JSObject* aTargetClassObject); + JS::Handle<JSObject*> aTargetClassObject); nsresult Read(nsIScriptContext* aContext, nsIObjectInputStream* aStream); nsresult Write(nsIScriptContext* aContext, nsIObjectOutputStream* aStream); const PRUnichar* GetName() const { return mName; } unsigned AccessorAttributes() const { return JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER |