mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 11:28:38 +00:00
Backed out changeset 7c0ace2560c4 (bug 866450)
This commit is contained in:
parent
b957907d9a
commit
55c0577379
@ -56,7 +56,7 @@ ConvertCloneReadInfosToArrayInternal(
|
|||||||
nsTArray<StructuredCloneReadInfo>& aReadInfos,
|
nsTArray<StructuredCloneReadInfo>& aReadInfos,
|
||||||
jsval* aResult)
|
jsval* aResult)
|
||||||
{
|
{
|
||||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
|
JSObject* array = JS_NewArrayObject(aCx, 0, nullptr);
|
||||||
if (!array) {
|
if (!array) {
|
||||||
NS_WARNING("Failed to make array!");
|
NS_WARNING("Failed to make array!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
@ -72,13 +72,13 @@ ConvertCloneReadInfosToArrayInternal(
|
|||||||
index++) {
|
index++) {
|
||||||
StructuredCloneReadInfo& readInfo = aReadInfos[index];
|
StructuredCloneReadInfo& readInfo = aReadInfos[index];
|
||||||
|
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
if (!IDBObjectStore::DeserializeValue(aCx, readInfo, val.address())) {
|
if (!IDBObjectStore::DeserializeValue(aCx, readInfo, &val)) {
|
||||||
NS_WARNING("Failed to decode!");
|
NS_WARNING("Failed to decode!");
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetElement(aCx, array, index, val.address())) {
|
if (!JS_SetElement(aCx, array, index, &val)) {
|
||||||
NS_WARNING("Failed to set array element!");
|
NS_WARNING("Failed to set array element!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
@ -608,8 +608,8 @@ IDBCursor::GetValue(JSContext* aCx,
|
|||||||
mRooted = true;
|
mRooted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
if (!IDBObjectStore::DeserializeValue(aCx, mCloneReadInfo, val.address())) {
|
if (!IDBObjectStore::DeserializeValue(aCx, mCloneReadInfo, &val)) {
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,8 +740,8 @@ IDBCursor::Update(const jsval& aValue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JS::Rooted<JS::Value> keyVal(aCx);
|
jsval keyVal;
|
||||||
rv = objectKey.ToJSVal(aCx, keyVal.address());
|
rv = objectKey.ToJSVal(aCx, &keyVal);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = mObjectStore->Put(aValue, keyVal, aCx, 1, getter_AddRefs(request));
|
rv = mObjectStore->Put(aValue, keyVal, aCx, 1, getter_AddRefs(request));
|
||||||
@ -811,8 +811,8 @@ IDBCursor::Delete(JSContext* aCx,
|
|||||||
|
|
||||||
Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||||
|
|
||||||
JS::Rooted<JS::Value> key(aCx);
|
jsval key;
|
||||||
nsresult rv = objectKey.ToJSVal(aCx, key.address());
|
nsresult rv = objectKey.ToJSVal(aCx, &key);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIIDBRequest> request;
|
nsCOMPtr<nsIIDBRequest> request;
|
||||||
|
@ -658,7 +658,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
|
|||||||
nsTArray<nsString> storesToOpen;
|
nsTArray<nsString> storesToOpen;
|
||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(aStoreNames)) {
|
if (!JSVAL_IS_PRIMITIVE(aStoreNames)) {
|
||||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aStoreNames));
|
JSObject* obj = JSVAL_TO_OBJECT(aStoreNames);
|
||||||
|
|
||||||
// See if this is a JS array.
|
// See if this is a JS array.
|
||||||
if (JS_IsArrayObject(aCx, obj)) {
|
if (JS_IsArrayObject(aCx, obj)) {
|
||||||
@ -674,10 +674,10 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
|
|||||||
storesToOpen.SetCapacity(length);
|
storesToOpen.SetCapacity(length);
|
||||||
|
|
||||||
for (uint32_t index = 0; index < length; index++) {
|
for (uint32_t index = 0; index < length; index++) {
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
JSString* jsstr;
|
JSString* jsstr;
|
||||||
nsDependentJSString str;
|
nsDependentJSString str;
|
||||||
if (!JS_GetElement(aCx, obj, index, val.address()) ||
|
if (!JS_GetElement(aCx, obj, index, &val) ||
|
||||||
!(jsstr = JS_ValueToString(aCx, val)) ||
|
!(jsstr = JS_ValueToString(aCx, val)) ||
|
||||||
!str.init(aCx, jsstr)) {
|
!str.init(aCx, jsstr)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
|
@ -218,8 +218,8 @@ IDBFactory::Create(ContentParent* aContentParent,
|
|||||||
nsresult rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(globalHolder));
|
nsresult rv = xpc->CreateSandbox(cx, principal, getter_AddRefs(globalHolder));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
JS::Rooted<JSObject*> global(cx);
|
JSObject* global;
|
||||||
rv = globalHolder->GetJSObject(global.address());
|
rv = globalHolder->GetJSObject(&global);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// The CreateSandbox call returns a proxy to the actual sandbox object. We
|
// The CreateSandbox call returns a proxy to the actual sandbox object. We
|
||||||
|
@ -1493,7 +1493,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
|||||||
|
|
||||||
JSAutoRequest ar(aCx);
|
JSAutoRequest ar(aCx);
|
||||||
|
|
||||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, NULL));
|
JSObject* array = JS_NewArrayObject(aCx, 0, NULL);
|
||||||
if (!array) {
|
if (!array) {
|
||||||
NS_WARNING("Failed to make array!");
|
NS_WARNING("Failed to make array!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
@ -1509,14 +1509,14 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
|||||||
const Key& key = keys[index];
|
const Key& key = keys[index];
|
||||||
NS_ASSERTION(!key.IsUnset(), "Bad key!");
|
NS_ASSERTION(!key.IsUnset(), "Bad key!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> value(aCx);
|
jsval value;
|
||||||
nsresult rv = key.ToJSVal(aCx, value.address());
|
nsresult rv = key.ToJSVal(aCx, &value);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to get jsval for key!");
|
NS_WARNING("Failed to get jsval for key!");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetElement(aCx, array, index, value.address())) {
|
if (!JS_SetElement(aCx, array, index, &value)) {
|
||||||
NS_WARNING("Failed to set array element!");
|
NS_WARNING("Failed to set array element!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ ReturnKeyRange(JSContext* aCx,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JSObject*> result(aCx);
|
JSObject* result;
|
||||||
if (NS_FAILED(holder->GetJSObject(result.address()))) {
|
if (NS_FAILED(holder->GetJSObject(&result))) {
|
||||||
JS_ReportError(aCx, "Couldn't get JSObject from wrapper.");
|
JS_ReportError(aCx, "Couldn't get JSObject from wrapper.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -113,8 +113,8 @@ MakeOnlyKeyRange(JSContext* aCx,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v", val.address())) {
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v", &val)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,9 +134,9 @@ MakeLowerBoundKeyRange(JSContext* aCx,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
JSBool open = false;
|
JSBool open = false;
|
||||||
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", val.address(), &open)) {
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", &val, &open)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +156,9 @@ MakeUpperBoundKeyRange(JSContext* aCx,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
JSBool open = false;
|
JSBool open = false;
|
||||||
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", val.address(), &open)) {
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "v/b", &val, &open)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,10 +178,10 @@ MakeBoundKeyRange(JSContext* aCx,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> lowerVal(aCx), upperVal(aCx);
|
jsval lowerVal, upperVal;
|
||||||
JSBool lowerOpen = false, upperOpen = false;
|
JSBool lowerOpen = false, upperOpen = false;
|
||||||
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "vv/bb", lowerVal.address(),
|
if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "vv/bb", &lowerVal,
|
||||||
upperVal.address(), &lowerOpen, &upperOpen)) {
|
&upperVal, &lowerOpen, &upperOpen)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,11 +726,11 @@ public:
|
|||||||
fileInfo);
|
fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> wrappedBlob(aCx);
|
jsval wrappedBlob;
|
||||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||||
rv =
|
rv =
|
||||||
nsContentUtils::WrapNative(aCx, global, domBlob,
|
nsContentUtils::WrapNative(aCx, global, domBlob,
|
||||||
&NS_GET_IID(nsIDOMBlob), wrappedBlob.address());
|
&NS_GET_IID(nsIDOMBlob), &wrappedBlob);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to wrap native!");
|
NS_WARNING("Failed to wrap native!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -753,11 +753,11 @@ public:
|
|||||||
nativeFile, fileInfo);
|
nativeFile, fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> wrappedFile(aCx);
|
jsval wrappedFile;
|
||||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForScopeChain(aCx));
|
||||||
rv =
|
rv =
|
||||||
nsContentUtils::WrapNative(aCx, global, domFile,
|
nsContentUtils::WrapNative(aCx, global, domFile,
|
||||||
&NS_GET_IID(nsIDOMFile), wrappedFile.address());
|
&NS_GET_IID(nsIDOMFile), &wrappedFile);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to wrap native!");
|
NS_WARNING("Failed to wrap native!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -795,7 +795,7 @@ public:
|
|||||||
// File.name
|
// File.name
|
||||||
// File.lastModifiedDate
|
// File.lastModifiedDate
|
||||||
|
|
||||||
JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
JSObject* obj = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
NS_WARNING("Failed to create object!");
|
NS_WARNING("Failed to create object!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -804,8 +804,8 @@ public:
|
|||||||
// Technically these props go on the proto, but this detail won't change
|
// Technically these props go on the proto, but this detail won't change
|
||||||
// the results of index creation.
|
// the results of index creation.
|
||||||
|
|
||||||
JS::RootedString type(aCx,
|
JSString* type =
|
||||||
JS_NewUCStringCopyN(aCx, aData.type.get(), aData.type.Length()));
|
JS_NewUCStringCopyN(aCx, aData.type.get(), aData.type.Length());
|
||||||
if (!type ||
|
if (!type ||
|
||||||
!JS_DefineProperty(aCx, obj, "size",
|
!JS_DefineProperty(aCx, obj, "size",
|
||||||
JS_NumberValue((double)aData.size),
|
JS_NumberValue((double)aData.size),
|
||||||
@ -930,15 +930,15 @@ IDBObjectStore::AppendIndexUpdateInfo(
|
|||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(val) &&
|
if (!JSVAL_IS_PRIMITIVE(val) &&
|
||||||
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(val))) {
|
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(val))) {
|
||||||
JS::Rooted<JSObject*> array(aCx, JSVAL_TO_OBJECT(val));
|
JSObject* array = JSVAL_TO_OBJECT(val);
|
||||||
uint32_t arrayLength;
|
uint32_t arrayLength;
|
||||||
if (!JS_GetArrayLength(aCx, array, &arrayLength)) {
|
if (!JS_GetArrayLength(aCx, array, &arrayLength)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
|
for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
|
||||||
JS::Rooted<JS::Value> arrayItem(aCx);
|
jsval arrayItem;
|
||||||
if (!JS_GetElement(aCx, array, arrayIndex, arrayItem.address())) {
|
if (!JS_GetElement(aCx, array, arrayIndex, &arrayItem)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1818,7 +1818,7 @@ IDBObjectStore::AddOrPut(const jsval& aValue,
|
|||||||
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> keyval(aCx, (aOptionalArgCount >= 1) ? aKey : JSVAL_VOID);
|
jsval keyval = (aOptionalArgCount >= 1) ? aKey : JSVAL_VOID;
|
||||||
|
|
||||||
StructuredCloneWriteInfo cloneWriteInfo;
|
StructuredCloneWriteInfo cloneWriteInfo;
|
||||||
Key key;
|
Key key;
|
||||||
@ -4028,8 +4028,8 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection)
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
JS::Rooted<JS::Value> clone(cx);
|
jsval clone;
|
||||||
if (!buffer.read(cx, clone.address(), &callbacks, &cloneReadInfo)) {
|
if (!buffer.read(cx, &clone, &callbacks, &cloneReadInfo)) {
|
||||||
NS_WARNING("Failed to deserialize structured clone data!");
|
NS_WARNING("Failed to deserialize structured clone data!");
|
||||||
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JSObject*> global(cx, GetParentObject());
|
JSObject* global = GetParentObject();
|
||||||
NS_ASSERTION(global, "This should never be null!");
|
NS_ASSERTION(global, "This should never be null!");
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
@ -419,7 +419,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aObj, JSContext* aCx)
|
|||||||
// exceptions.
|
// exceptions.
|
||||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||||
|
|
||||||
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
|
JSObject* global = JS_GetGlobalForObject(aCx, obj);
|
||||||
NS_ASSERTION(global, "What?! No global!");
|
NS_ASSERTION(global, "What?! No global!");
|
||||||
|
|
||||||
nsRefPtr<IDBFactory> factory;
|
nsRefPtr<IDBFactory> factory;
|
||||||
@ -429,8 +429,8 @@ IndexedDatabaseManager::InitWindowless(const jsval& aObj, JSContext* aCx)
|
|||||||
|
|
||||||
NS_ASSERTION(factory, "This should never fail for chrome!");
|
NS_ASSERTION(factory, "This should never fail for chrome!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> indexedDBVal(aCx);
|
jsval indexedDBVal;
|
||||||
rv = nsContentUtils::WrapNative(aCx, obj, factory, indexedDBVal.address());
|
rv = nsContentUtils::WrapNative(aCx, obj, factory, &indexedDBVal);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (!JS_DefineProperty(aCx, obj, "indexedDB", indexedDBVal, nullptr,
|
if (!JS_DefineProperty(aCx, obj, "indexedDB", indexedDBVal, nullptr,
|
||||||
@ -438,7 +438,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aObj, JSContext* aCx)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JSObject*> keyrangeObj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
|
JSObject* keyrangeObj = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
||||||
NS_ENSURE_TRUE(keyrangeObj, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(keyrangeObj, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (!IDBKeyRange::DefineConstructors(aCx, keyrangeObj)) {
|
if (!IDBKeyRange::DefineConstructors(aCx, keyrangeObj)) {
|
||||||
|
@ -133,7 +133,7 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(aVal)) {
|
if (!JSVAL_IS_PRIMITIVE(aVal)) {
|
||||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aVal));
|
JSObject* obj = JSVAL_TO_OBJECT(aVal);
|
||||||
if (JS_IsArrayObject(aCx, obj)) {
|
if (JS_IsArrayObject(aCx, obj)) {
|
||||||
aTypeOffset += eMaxType;
|
aTypeOffset += eMaxType;
|
||||||
|
|
||||||
@ -151,8 +151,8 @@ Key::EncodeJSValInternal(JSContext* aCx, const jsval aVal,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t index = 0; index < length; index++) {
|
for (uint32_t index = 0; index < length; index++) {
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
if (!JS_GetElement(aCx, obj, index, val.address())) {
|
if (!JS_GetElement(aCx, obj, index, &val)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
|
|||||||
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
|
NS_ENSURE_TRUE(aRecursionDepth < MaxRecursionDepth, NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
|
||||||
|
|
||||||
if (*aPos - aTypeOffset >= eArray) {
|
if (*aPos - aTypeOffset >= eArray) {
|
||||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
|
JSObject* array = JS_NewArrayObject(aCx, 0, nullptr);
|
||||||
if (!array) {
|
if (!array) {
|
||||||
NS_WARNING("Failed to make array!");
|
NS_WARNING("Failed to make array!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
@ -206,14 +206,14 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
|
|||||||
|
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
while (aPos < aEnd && *aPos - aTypeOffset != eTerminator) {
|
while (aPos < aEnd && *aPos - aTypeOffset != eTerminator) {
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
nsresult rv = DecodeJSValInternal(aPos, aEnd, aCx, aTypeOffset,
|
nsresult rv = DecodeJSValInternal(aPos, aEnd, aCx, aTypeOffset,
|
||||||
val.address(), aRecursionDepth + 1);
|
&val, aRecursionDepth + 1);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
aTypeOffset = 0;
|
aTypeOffset = 0;
|
||||||
|
|
||||||
if (!JS_SetElement(aCx, array, index++, val.address())) {
|
if (!JS_SetElement(aCx, array, index++, &val)) {
|
||||||
NS_WARNING("Failed to set array element!");
|
NS_WARNING("Failed to set array element!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
|||||||
KeyPathTokenizer tokenizer(aKeyPathString, '.');
|
KeyPathTokenizer tokenizer(aKeyPathString, '.');
|
||||||
|
|
||||||
nsString targetObjectPropName;
|
nsString targetObjectPropName;
|
||||||
JS::Rooted<JSObject*> targetObject(aCx, nullptr);
|
JSObject* targetObject = nullptr;
|
||||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_IS_PRIMITIVE(aValue) ? nullptr :
|
JSObject* obj = JSVAL_IS_PRIMITIVE(aValue) ? nullptr :
|
||||||
JSVAL_TO_OBJECT(aValue));
|
JSVAL_TO_OBJECT(aValue);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
const nsDependentSubstring& token = tokenizer.nextToken();
|
const nsDependentSubstring& token = tokenizer.nextToken();
|
||||||
@ -116,9 +116,9 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
|||||||
|
|
||||||
if (hasProp) {
|
if (hasProp) {
|
||||||
// Get if the property exists...
|
// Get if the property exists...
|
||||||
JS::Rooted<JS::Value> intermediate(aCx);
|
jsval intermediate;
|
||||||
JSBool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen,
|
JSBool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen,
|
||||||
intermediate.address());
|
&intermediate);
|
||||||
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||||
|
|
||||||
// Treat explicitly undefined as an error.
|
// Treat explicitly undefined as an error.
|
||||||
@ -203,10 +203,10 @@ GetJSValFromKeyPathString(JSContext* aCx,
|
|||||||
if (targetObject) {
|
if (targetObject) {
|
||||||
// If this fails, we lose, and the web page sees a magical property
|
// If this fails, we lose, and the web page sees a magical property
|
||||||
// appear on the object :-(
|
// appear on the object :-(
|
||||||
JS::Rooted<JS::Value> succeeded(aCx);
|
jsval succeeded;
|
||||||
if (!JS_DeleteUCProperty2(aCx, targetObject,
|
if (!JS_DeleteUCProperty2(aCx, targetObject,
|
||||||
targetObjectPropName.get(),
|
targetObjectPropName.get(),
|
||||||
targetObjectPropName.Length(), succeeded.address())) {
|
targetObjectPropName.Length(), &succeeded)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
NS_ASSERTION(JSVAL_IS_BOOLEAN(succeeded), "Wtf?");
|
NS_ASSERTION(JSVAL_IS_BOOLEAN(succeeded), "Wtf?");
|
||||||
@ -232,7 +232,7 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)
|
|||||||
if (!JSVAL_IS_PRIMITIVE(aValue) &&
|
if (!JSVAL_IS_PRIMITIVE(aValue) &&
|
||||||
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(aValue))) {
|
JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(aValue))) {
|
||||||
|
|
||||||
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aValue));
|
JSObject* obj = JSVAL_TO_OBJECT(aValue);
|
||||||
|
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
if (!JS_GetArrayLength(aCx, obj, &length)) {
|
if (!JS_GetArrayLength(aCx, obj, &length)) {
|
||||||
@ -246,10 +246,10 @@ KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)
|
|||||||
keyPath.SetType(ARRAY);
|
keyPath.SetType(ARRAY);
|
||||||
|
|
||||||
for (uint32_t index = 0; index < length; index++) {
|
for (uint32_t index = 0; index < length; index++) {
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
JSString* jsstr;
|
JSString* jsstr;
|
||||||
nsDependentJSString str;
|
nsDependentJSString str;
|
||||||
if (!JS_GetElement(aCx, obj, index, val.address()) ||
|
if (!JS_GetElement(aCx, obj, index, &val) ||
|
||||||
!(jsstr = JS_ValueToString(aCx, val)) ||
|
!(jsstr = JS_ValueToString(aCx, val)) ||
|
||||||
!str.init(aCx, jsstr)) {
|
!str.init(aCx, jsstr)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@ -313,12 +313,12 @@ nsresult
|
|||||||
KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, Key& aKey) const
|
KeyPath::ExtractKey(JSContext* aCx, const JS::Value& aValue, Key& aKey) const
|
||||||
{
|
{
|
||||||
uint32_t len = mStrings.Length();
|
uint32_t len = mStrings.Length();
|
||||||
JS::Rooted<JS::Value> value(aCx);
|
JS::Value value;
|
||||||
|
|
||||||
aKey.Unset();
|
aKey.Unset();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; ++i) {
|
for (uint32_t i = 0; i < len; ++i) {
|
||||||
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[i], value.address(),
|
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[i], &value,
|
||||||
DoNotCreateProperties, nullptr,
|
DoNotCreateProperties, nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@ -346,23 +346,23 @@ KeyPath::ExtractKeyAsJSVal(JSContext* aCx, const JS::Value& aValue,
|
|||||||
return GetJSValFromKeyPathString(aCx, aValue, mStrings[0], aOutVal,
|
return GetJSValFromKeyPathString(aCx, aValue, mStrings[0], aOutVal,
|
||||||
DoNotCreateProperties, nullptr, nullptr);
|
DoNotCreateProperties, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t len = mStrings.Length();
|
const uint32_t len = mStrings.Length();
|
||||||
JS::RootedObject arrayObj(aCx, JS_NewArrayObject(aCx, len, nullptr));
|
JS::RootedObject arrayObj(aCx, JS_NewArrayObject(aCx, len, nullptr));
|
||||||
if (!arrayObj) {
|
if (!arrayObj) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Rooted<JS::Value> value(aCx);
|
JS::Value value;
|
||||||
for (uint32_t i = 0; i < len; ++i) {
|
for (uint32_t i = 0; i < len; ++i) {
|
||||||
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[i], value.address(),
|
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[i], &value,
|
||||||
DoNotCreateProperties, nullptr,
|
DoNotCreateProperties, nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetElement(aCx, arrayObj, i, value.address())) {
|
if (!JS_SetElement(aCx, arrayObj, i, &value)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,11 +378,11 @@ KeyPath::ExtractOrCreateKey(JSContext* aCx, const JS::Value& aValue,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(IsString(), "This doesn't make sense!");
|
NS_ASSERTION(IsString(), "This doesn't make sense!");
|
||||||
|
|
||||||
JS::Rooted<JS::Value> value(aCx);
|
JS::Value value;
|
||||||
|
|
||||||
aKey.Unset();
|
aKey.Unset();
|
||||||
|
|
||||||
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[0], value.address(),
|
nsresult rv = GetJSValFromKeyPathString(aCx, aValue, mStrings[0], &value,
|
||||||
CreateProperties, aCallback,
|
CreateProperties, aCallback,
|
||||||
aClosure);
|
aClosure);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@ -457,20 +457,20 @@ KeyPath::ToJSVal(JSContext* aCx, JS::Value* aValue) const
|
|||||||
{
|
{
|
||||||
if (IsArray()) {
|
if (IsArray()) {
|
||||||
uint32_t len = mStrings.Length();
|
uint32_t len = mStrings.Length();
|
||||||
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, len, nullptr));
|
JSObject* array = JS_NewArrayObject(aCx, len, nullptr);
|
||||||
if (!array) {
|
if (!array) {
|
||||||
NS_WARNING("Failed to make array!");
|
NS_WARNING("Failed to make array!");
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; ++i) {
|
for (uint32_t i = 0; i < len; ++i) {
|
||||||
JS::Rooted<JS::Value> val(aCx);
|
jsval val;
|
||||||
nsString tmp(mStrings[i]);
|
nsString tmp(mStrings[i]);
|
||||||
if (!xpc::StringToJsval(aCx, tmp, val.address())) {
|
if (!xpc::StringToJsval(aCx, tmp, &val)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_SetElement(aCx, array, i, val.address())) {
|
if (!JS_SetElement(aCx, array, i, &val)) {
|
||||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,17 +384,17 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsval result;
|
||||||
|
rv = mOpenRequest->GetResult(&result);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result));
|
||||||
|
|
||||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||||
MOZ_ASSERT(xpc);
|
MOZ_ASSERT(xpc);
|
||||||
|
|
||||||
SafeAutoJSContext cx;
|
SafeAutoJSContext cx;
|
||||||
|
|
||||||
JS::Rooted<JS::Value> result(cx);
|
|
||||||
rv = mOpenRequest->GetResult(result.address());
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||||
rv = xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(result),
|
rv = xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(result),
|
||||||
getter_AddRefs(wrapper));
|
getter_AddRefs(wrapper));
|
||||||
@ -536,8 +536,8 @@ IndexedDBDatabaseParent::HandleDatabaseEvent(nsIDOMEvent* aEvent,
|
|||||||
rv = changeEvent->GetOldVersion(&oldVersion);
|
rv = changeEvent->GetOldVersion(&oldVersion);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
JS::Rooted<JS::Value> newVersionVal(cx);
|
JS::Value newVersionVal;
|
||||||
rv = changeEvent->GetNewVersion(cx, newVersionVal.address());
|
rv = changeEvent->GetNewVersion(cx, &newVersionVal);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
uint64_t newVersion;
|
uint64_t newVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user