Backed out changeset e0b51717bb64 (bug 866450)

This commit is contained in:
Ed Morley 2013-05-02 11:56:57 +01:00
parent b0210309e0
commit b957907d9a
18 changed files with 48 additions and 47 deletions

View File

@ -659,10 +659,10 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS::Rooted<JSObject*> param(ctx, JS_NewObject(ctx, nullptr, nullptr, nullptr));
NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<JS::Value> targetv(ctx);
JS::Value targetv;
JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
nsContentUtils::WrapNative(ctx, global, aTarget, targetv.address(), nullptr, true);
nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, nullptr, true);
// To keep compatibility with e10s message manager,
// define empty objects array.
@ -699,9 +699,9 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS_DefineProperty(ctx, param, "data", json, nullptr, nullptr, JSPROP_ENUMERATE);
JS_DefineProperty(ctx, param, "objects", objectsv, nullptr, nullptr, JSPROP_ENUMERATE);
JS::Rooted<JS::Value> thisValue(ctx, JS::UndefinedValue());
JS::Rooted<JS::Value> thisValue(ctx, JSVAL_VOID);
JS::Rooted<JS::Value> funval(ctx);
JS::Value funval;
if (JS_ObjectIsCallable(ctx, object)) {
// If the listener is a JS function:
funval.setObject(*object);
@ -719,7 +719,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
thisValue.address(), nullptr, true);
} else {
// If the listener is a JS object which has receiveMessage function:
if (!JS_GetProperty(ctx, object, "receiveMessage", funval.address()) ||
if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) ||
!funval.isObject())
return NS_ERROR_UNEXPECTED;
@ -1073,8 +1073,8 @@ nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
.setFileAndLine(url.get(), 1)
.setPrincipals(nsJSPrincipals::get(mPrincipal));
JS::RootedObject empty(mCx, nullptr);
JS::Rooted<JSScript*> script(mCx, JS::Compile(mCx, empty, options,
dataString.get(), dataString.Length()));
JS::Rooted<JSScript*> script = JS::Compile(mCx, empty, options,
dataString.get(), dataString.Length());
if (script) {
nsAutoCString scheme;

View File

@ -3089,15 +3089,16 @@ nsObjectLoadingContent::TeardownProtoChain()
JS::Rooted<JSObject*> obj(cx, thisContent->GetWrapper());
NS_ENSURE_TRUE(obj, /* void */);
JS::Rooted<JSObject*> proto(cx);
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, obj);
JSObject *proto;
// Loop over the DOM element's JS object prototype chain and remove
// all JS objects of the class sNPObjectJSWrapperClass
bool removed = false;
while (obj) {
if (!::JS_GetPrototype(cx, obj, proto.address())) {
if (!::JS_GetPrototype(cx, obj, &proto)) {
return;
}
if (!proto) {
@ -3107,7 +3108,7 @@ nsObjectLoadingContent::TeardownProtoChain()
// an NP object, that counts too.
if (JS_GetClass(js::UncheckedUnwrap(proto)) == &sNPObjectJSWrapperClass) {
// We found an NPObject on the proto chain, get its prototype...
if (!::JS_GetPrototype(cx, proto, proto.address())) {
if (!::JS_GetPrototype(cx, proto, &proto)) {
return;
}

View File

@ -3630,14 +3630,14 @@ nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv)
{
const nsID* iid = aIID->GetID();
nsCOMPtr<nsISupports> result;
JS::Rooted<JS::Value> v(aCx, JSVAL_NULL);
JS::Value v = JSVAL_NULL;
aRv = GetInterface(*iid, getter_AddRefs(result));
NS_ENSURE_FALSE(aRv.Failed(), JSVAL_NULL);
JS::Rooted<JSObject*> wrapper(aCx, GetWrapper());
JSAutoCompartment ac(aCx, wrapper);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, wrapper));
aRv = nsContentUtils::WrapNative(aCx, global, result, iid, v.address());
aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v);
return aRv.Failed() ? JSVAL_NULL : v;
}

View File

@ -164,7 +164,7 @@ DashArrayToJSVal(FallibleTArray<T>& dashes,
for (uint32_t i = 0; i < dashes.Length(); ++i) {
double d = dashes[i];
JS::Value elt = DOUBLE_TO_JSVAL(d);
if (!JS_DefineElement(cx, obj, i, elt, nullptr, nullptr, 0)) {
if (!JS_SetElement(cx, obj, i, &elt)) {
rv.Throw(NS_ERROR_FAILURE);
return JSVAL_NULL;
}

View File

@ -57,8 +57,8 @@ nsDOMMessageEvent::GetData(JSContext* aCx, JS::Value* aData)
JS::Value
nsDOMMessageEvent::GetData(JSContext* aCx, mozilla::ErrorResult& aRv)
{
JS::Rooted<JS::Value> data(aCx, mData);
if (!JS_WrapValue(aCx, data.address())) {
JS::Value data = mData;
if (!JS_WrapValue(aCx, &data)) {
aRv.Throw(NS_ERROR_FAILURE);
}
return data;

View File

@ -291,8 +291,8 @@ HTMLOptionsCollection::NamedItem(JSContext* cx, const nsAString& name,
}
JS::Rooted<JSObject*> wrapper(cx, nsWrapperCache::GetWrapper());
JSAutoCompartment ac(cx, wrapper);
JS::Rooted<JS::Value> v(cx);
if (!mozilla::dom::WrapObject(cx, wrapper, item, item, nullptr, v.address())) {
JS::Value v;
if (!mozilla::dom::WrapObject(cx, wrapper, item, item, nullptr, &v)) {
error.Throw(NS_ERROR_FAILURE);
return nullptr;
}

View File

@ -234,8 +234,8 @@ TableRowsCollection::NamedItem(JSContext* cx, const nsAString& name,
if (item) {
JS::Rooted<JSObject*> wrapper(cx, nsWrapperCache::GetWrapper());
JSAutoCompartment ac(cx, wrapper);
JS::Rooted<JS::Value> v(cx);
if (!mozilla::dom::WrapObject(cx, wrapper, item, v.address())) {
JS::Value v;
if (!mozilla::dom::WrapObject(cx, wrapper, item, &v)) {
error.Throw(NS_ERROR_FAILURE);
return nullptr;
}

View File

@ -2257,7 +2257,7 @@ nsFormControlList::NamedItem(const nsAString& aName,
*aReturn = nullptr;
nsCOMPtr<nsISupports> supports;
if (!mNameLookupTable.Get(aName, getter_AddRefs(supports))) {
// key not found
return NS_OK;
@ -2553,8 +2553,8 @@ nsFormControlList::NamedItem(JSContext* cx, const nsAString& name,
}
JS::Rooted<JSObject*> wrapper(cx, nsWrapperCache::GetWrapper());
JSAutoCompartment ac(cx, wrapper);
JS::Rooted<JS::Value> v(cx);
if (!mozilla::dom::WrapObject(cx, wrapper, item, v.address())) {
JS::Value v;
if (!mozilla::dom::WrapObject(cx, wrapper, item, &v)) {
error.Throw(NS_ERROR_FAILURE);
return nullptr;
}

View File

@ -2367,13 +2367,13 @@ nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
return nullptr;
}
JS::Rooted<JS::Value> val(cx);
JS::Value val;
{ // Scope for auto-compartment
JS::Rooted<JSObject*> wrapper(cx, GetWrapper());
JSAutoCompartment ac(cx, wrapper);
// XXXbz Should we call the (slightly misnamed, really) WrapNativeParent
// here?
if (!dom::WrapObject(cx, wrapper, supp, cache, nullptr, val.address())) {
if (!dom::WrapObject(cx, wrapper, supp, cache, nullptr, &val)) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}

View File

@ -1387,9 +1387,9 @@ nsXULTemplateBuilder::InitHTMLTemplateRoot()
JSAutoRequest ar(jscontext);
JS::Rooted<JS::Value> v(jscontext);
JS::Value v;
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, v.address(),
rv = nsContentUtils::WrapNative(jscontext, scope, mRoot, mRoot, &v,
getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1515,9 +1515,9 @@ nsJSContext::BindCompiledEventHandler(nsISupports* aTarget, JSObject* aScope,
XPCAutoRequest ar(mContext);
// Get the jsobject associated with this target
JS::Rooted<JSObject*> target(mContext);
JSObject *target = nullptr;
JS::Rooted<JSObject*> scope(mContext, aScope);
nsresult rv = JSObjectFromInterface(aTarget, scope, target.address());
nsresult rv = JSObjectFromInterface(aTarget, scope, &target);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef DEBUG

View File

@ -922,13 +922,13 @@ InterfaceToJsval(nsPIDOMWindow* aWindow, nsISupports* aObject, const nsIID* aIID
return JSVAL_NULL;
}
JS::Rooted<JS::Value> someJsVal(cx);
JS::Value someJsVal;
JS::Rooted<JSObject*> global(cx, JS_GetGlobalObject(cx));
nsresult rv = nsContentUtils::WrapNative(cx,
global,
aObject,
aIID,
someJsVal.address());
&someJsVal);
if (NS_FAILED(rv)) {
return JSVAL_NULL;
}

View File

@ -245,11 +245,11 @@ ArchiveRequest::GetFilesResult(JSContext* aCx,
for (uint32_t i = 0; i < aFileList.Length(); ++i) {
nsCOMPtr<nsIDOMFile> file = aFileList[i];
JS::Rooted<JS::Value> value(aCx);
JS::Value value;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv = nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile), value.address());
if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, value.address())) {
&NS_GET_IID(nsIDOMFile), &value);
if (NS_FAILED(rv) || !JS_SetElement(aCx, array, i, &value)) {
return NS_ERROR_FAILURE;
}
}

View File

@ -665,13 +665,13 @@ public:
nsRefPtr<IDBFileHandle> fileHandle = IDBFileHandle::Create(aDatabase,
aData.name, aData.type, fileInfo.forget());
JS::Rooted<JS::Value> wrappedFileHandle(aCx);
jsval wrappedFileHandle;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global,
static_cast<nsIDOMFileHandle*>(fileHandle),
&NS_GET_IID(nsIDOMFileHandle),
wrappedFileHandle.address());
&wrappedFileHandle);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to wrap native!");
return nullptr;

View File

@ -57,11 +57,11 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
}
#endif
JS::Rooted<JS::Value> wrappedFile(aCx);
JS::Value wrappedFile;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile), wrappedFile.address());
&NS_GET_IID(nsIDOMFile), &wrappedFile);
if (NS_FAILED(rv)) {
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
return nullptr;
@ -90,11 +90,11 @@ Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
}
#endif
JS::Rooted<JS::Value> wrappedBlob(aCx);
JS::Value wrappedBlob;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global, blob,
&NS_GET_IID(nsIDOMBlob), wrappedBlob.address());
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
if (NS_FAILED(rv)) {
Error(aCx, nsIDOMDOMException::DATA_CLONE_ERR);
return nullptr;

View File

@ -60,8 +60,8 @@ MobileMessageCallback::NotifySuccess(nsISupports *aMessage)
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, global);
JS::Rooted<JS::Value> wrappedMessage(cx);
rv = nsContentUtils::WrapNative(cx, global, aMessage, wrappedMessage.address());
JS::Value wrappedMessage;
rv = nsContentUtils::WrapNative(cx, global, aMessage, &wrappedMessage);
NS_ENSURE_SUCCESS(rv, rv);
return NotifySuccess(wrappedMessage);

View File

@ -73,8 +73,8 @@ MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult)
JSAutoRequest ar(cx);
JSAutoCompartment ac(cx, global);
JS::Rooted<JS::Value> wrappedResult(cx);
rv = nsContentUtils::WrapNative(cx, global, aResult, wrappedResult.address());
JS::Value wrappedResult;
rv = nsContentUtils::WrapNative(cx, global, aResult, &wrappedResult);
NS_ENSURE_SUCCESS(rv, rv);
mDOMCursor->FireSuccess(wrappedResult);

View File

@ -308,11 +308,11 @@ struct MainThreadWorkerStructuredCloneCallbacks
// nsIDOMFiles should be threadsafe, thus we will use the same instance
// on the main thread.
JS::Rooted<JS::Value> wrappedFile(aCx);
JS::Value wrappedFile;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global, file,
&NS_GET_IID(nsIDOMFile), wrappedFile.address());
&NS_GET_IID(nsIDOMFile), &wrappedFile);
if (NS_FAILED(rv)) {
Error(aCx, DATA_CLONE_ERR);
return nullptr;
@ -342,11 +342,11 @@ struct MainThreadWorkerStructuredCloneCallbacks
// nsIDOMBlobs should be threadsafe, thus we will use the same instance
// on the main thread.
JS::Rooted<JS::Value> wrappedBlob(aCx);
JS::Value wrappedBlob;
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
nsresult rv =
nsContentUtils::WrapNative(aCx, global, blob,
&NS_GET_IID(nsIDOMBlob), wrappedBlob.address());
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
if (NS_FAILED(rv)) {
Error(aCx, DATA_CLONE_ERR);
return nullptr;