Backed out changeset c5ba9c0dc252 (bug 866450)

This commit is contained in:
Ed Morley 2013-05-02 11:57:04 +01:00
parent e348bd3444
commit d29f694434
6 changed files with 44 additions and 42 deletions

View File

@ -6380,11 +6380,11 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
return true;
}
JS::Rooted<JS::Value> rval(cx, JS::NullValue());
JS::Value rval = JS::NullValue();
size_t idx = 0;
if (!JS_ExecuteRegExpNoStatics(cx, re,
static_cast<jschar*>(aValue.BeginWriting()),
aValue.Length(), &idx, true, rval.address())) {
aValue.Length(), &idx, true, &rval)) {
JS_ClearPendingException(cx);
return true;
}

View File

@ -209,23 +209,23 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx,
return NS_ERROR_TYPE_ERR; // We're not interested
}
JS::Rooted<JSObject*> obj(aCx, &aArgv[0].toObject());
if (!JS_IsArrayObject(aCx, obj)) {
JSObject& obj = aArgv[0].toObject();
if (!JS_IsArrayObject(aCx, &obj)) {
return NS_ERROR_TYPE_ERR; // We're not interested
}
BlobSet blobSet;
uint32_t length;
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, &obj, &length));
for (uint32_t i = 0; i < length; ++i) {
JS::Rooted<JS::Value> element(aCx);
if (!JS_GetElement(aCx, obj, i, element.address()))
JS::Value element;
if (!JS_GetElement(aCx, &obj, i, &element))
return NS_ERROR_TYPE_ERR;
if (element.isObject()) {
JS::Rooted<JSObject*> obj(aCx, &element.toObject());
nsCOMPtr<nsIDOMBlob> blob = aUnwrapFunc(aCx, obj);
JSObject& obj = element.toObject();
nsCOMPtr<nsIDOMBlob> blob = aUnwrapFunc(aCx, &obj);
if (blob) {
// Flatten so that multipart blobs will never nest
nsDOMFileBase* file = static_cast<nsDOMFileBase*>(
@ -239,13 +239,13 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx,
}
continue;
}
if (JS_IsArrayBufferViewObject(obj)) {
blobSet.AppendVoidPtr(JS_GetArrayBufferViewData(obj),
JS_GetArrayBufferViewByteLength(obj));
if (JS_IsArrayBufferViewObject(&obj)) {
blobSet.AppendVoidPtr(JS_GetArrayBufferViewData(&obj),
JS_GetArrayBufferViewByteLength(&obj));
continue;
}
if (JS_IsArrayBufferObject(obj)) {
blobSet.AppendArrayBuffer(obj);
if (JS_IsArrayBufferObject(&obj)) {
blobSet.AppendArrayBuffer(&obj);
continue;
}
// neither Blob nor ArrayBuffer(View)

View File

@ -184,8 +184,8 @@ nsDOMFileReader::GetReadyState(uint16_t *aReadyState)
JS::Value
nsDOMFileReader::GetResult(JSContext* aCx, ErrorResult& aRv)
{
JS::Rooted<JS::Value> result(aCx, JS::UndefinedValue());
aRv = GetResult(aCx, result.address());
JS::Value result = JS::UndefinedValue();
aRv = GetResult(aCx, &result);
return result;
}

View File

@ -4966,16 +4966,16 @@ nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
static JSBool
CustomElementConstructor(JSContext *aCx, unsigned aArgc, JS::Value* aVp)
{
JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp);
JS::Value calleeVal = JS_CALLEE(aCx, aVp);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, &args.callee()));
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, &calleeVal.toObject()));
nsCOMPtr<nsPIDOMWindow> window = do_QueryWrapper(aCx, global);
MOZ_ASSERT(window, "Should have a non-null window");
nsIDocument* document = window->GetDoc();
// Function name is the type of the custom element.
JSString* jsFunName = JS_GetFunctionId(JS_ValueToFunction(aCx, args.calleev()));
JSString* jsFunName = JS_GetFunctionId(JS_ValueToFunction(aCx, calleeVal));
nsDependentJSString elemName;
if (!elemName.init(aCx, jsFunName)) {
return false;
@ -4984,9 +4984,11 @@ CustomElementConstructor(JSContext *aCx, unsigned aArgc, JS::Value* aVp)
nsCOMPtr<nsIContent> newElement;
nsresult rv = document->CreateElem(elemName, nullptr, kNameSpaceID_XHTML,
getter_AddRefs(newElement));
rv = nsContentUtils::WrapNative(aCx, global, newElement, newElement, args.rval().address());
JS::Value v;
rv = nsContentUtils::WrapNative(aCx, global, newElement, newElement, &v);
NS_ENSURE_SUCCESS(rv, false);
JS_SET_RVAL(aCx, aVp, v);
return true;
}
@ -5048,13 +5050,13 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
JSAutoCompartment ac(aCx, global);
JS::Handle<JSObject*> htmlProto(HTMLElementBinding::GetProtoObject(aCx, global));
JSObject* htmlProto = HTMLElementBinding::GetProtoObject(aCx, global);
if (!htmlProto) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
JS::Rooted<JSObject*> protoObject(aCx);
JSObject* protoObject;
if (!aOptions.mPrototype) {
protoObject = JS_NewObject(aCx, nullptr, htmlProto, nullptr);
if (!protoObject) {
@ -5065,14 +5067,14 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
// If a prototype is provided, we must check to ensure that it inherits
// from HTMLElement.
protoObject = aOptions.mPrototype;
if (!JS_WrapObject(aCx, protoObject.address())) {
if (!JS_WrapObject(aCx, &protoObject)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
// Check the proto chain for HTMLElement prototype.
JS::Rooted<JSObject*> protoProto(aCx);
if (!JS_GetPrototype(aCx, protoObject, protoProto.address())) {
JSObject* protoProto;
if (!JS_GetPrototype(aCx, protoObject, &protoProto)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
@ -5080,7 +5082,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
if (protoProto == htmlProto) {
break;
}
if (!JS_GetPrototype(aCx, protoProto, protoProto.address())) {
if (!JS_GetPrototype(aCx, protoProto, &protoProto)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
@ -6582,8 +6584,8 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
// scope. But we try to pass something sane anyway.
JS::Rooted<JSObject*> global(cx, GetScopeObject()->GetGlobalJSObject());
JS::Rooted<JS::Value> v(cx);
rv = nsContentUtils::WrapNative(cx, global, this, this, v.address(), nullptr,
JS::Value v;
rv = nsContentUtils::WrapNative(cx, global, this, this, &v, nullptr,
/* aAllowWrapping = */ false);
if (rv.Failed())
return nullptr;
@ -11215,11 +11217,11 @@ nsIDocument::PostCreateWrapper(JSContext* aCx, JSHandleObject aNewObject)
JSAutoCompartment ac(aCx, aNewObject);
JS::Rooted<JS::Value> winVal(aCx);
jsval winVal;
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = nsContentUtils::WrapNative(aCx, aNewObject, win,
&NS_GET_IID(nsIDOMWindow),
winVal.address(), getter_AddRefs(holder),
&winVal, getter_AddRefs(holder),
false);
if (NS_FAILED(rv)) {
return Throw<true>(aCx, rv);

View File

@ -84,8 +84,8 @@ nsEventListenerInfo::GetJSVal(JSContext* aCx,
*aJSVal = JSVAL_NULL;
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(mListener);
if (wrappedJS) {
JS::Rooted<JSObject*> object(aCx, nullptr);
if (NS_FAILED(wrappedJS->GetJSObject(object.address()))) {
JSObject* object = nullptr;
if (NS_FAILED(wrappedJS->GetJSObject(&object))) {
return false;
}
aAc.construct(aCx, object);
@ -115,8 +115,8 @@ nsEventListenerInfo::ToSource(nsAString& aResult)
// Extra block to finish the auto request before calling pop
JSAutoRequest ar(cx);
mozilla::Maybe<JSAutoCompartment> ac;
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
if (GetJSVal(cx, ac, v.address())) {
JS::Value v = JSVAL_NULL;
if (GetJSVal(cx, ac, &v)) {
JSString* str = JS_ValueToSource(cx, v);
if (str) {
nsDependentJSString depStr;
@ -139,7 +139,7 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
nsCOMPtr<jsdIDebuggerService> jsd =
do_GetService("@mozilla.org/js/jsd/debugger-service;1", &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
bool isOn = false;
jsd->GetIsOn(&isOn);
NS_ENSURE_TRUE(isOn, NS_OK);
@ -149,8 +149,8 @@ nsEventListenerInfo::GetDebugObject(nsISupports** aRetVal)
// Extra block to finish the auto request before calling pop
JSAutoRequest ar(cx);
mozilla::Maybe<JSAutoCompartment> ac;
JS::Rooted<JS::Value> v(cx, JSVAL_NULL);
if (GetJSVal(cx, ac, v.address())) {
JS::Value v = JSVAL_NULL;
if (GetJSVal(cx, ac, &v)) {
nsCOMPtr<jsdIValue> jsdValue;
rv = jsd->WrapValue(v, getter_AddRefs(jsdValue));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -762,13 +762,13 @@ HTMLCanvasElement::GetContext(const nsAString& aContextId,
MOZ_ASSERT(aCx);
contextProps = do_CreateInstance("@mozilla.org/hash-property-bag;1");
JS::Rooted<JSObject*> opts(aCx, &aContextOptions.toObject());
JS::AutoIdArray props(aCx, JS_Enumerate(aCx, opts));
JSObject& opts = aContextOptions.toObject();
JS::AutoIdArray props(aCx, JS_Enumerate(aCx, &opts));
for (size_t i = 0; !!props && i < props.length(); ++i) {
jsid propid = props[i];
JS::Rooted<JS::Value> propname(aCx), propval(aCx);
if (!JS_IdToValue(aCx, propid, propname.address()) ||
!JS_GetPropertyById(aCx, opts, propid, propval.address())) {
JS::Value propname, propval;
if (!JS_IdToValue(aCx, propid, &propname) ||
!JS_GetPropertyById(aCx, &opts, propid, &propval)) {
return NS_ERROR_FAILURE;
}