| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 stack.push_back(array); | 214 stack.push_back(array); |
| 215 | 215 |
| 216 IDBKey::KeyArray subkeys; | 216 IDBKey::KeyArray subkeys; |
| 217 uint32_t length = array->Length(); | 217 uint32_t length = array->Length(); |
| 218 v8::TryCatch block(isolate); | 218 v8::TryCatch block(isolate); |
| 219 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 219 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 220 for (uint32_t i = 0; i < length; ++i) { | 220 for (uint32_t i = 0; i < length; ++i) { |
| 221 if (!V8CallBoolean(array->HasOwnProperty(context, i))) | 221 if (!V8CallBoolean(array->HasOwnProperty(context, i))) |
| 222 return nullptr; | 222 return nullptr; |
| 223 v8::Local<v8::Value> item; | 223 v8::Local<v8::Value> item; |
| 224 if (!V8Call(array->Get(context, i), item, block)) { | 224 if (!array->Get(context, i).ToLocal(&item)) { |
| 225 exception_state.RethrowV8Exception(block.Exception()); | 225 exception_state.RethrowV8Exception(block.Exception()); |
| 226 return nullptr; | 226 return nullptr; |
| 227 } | 227 } |
| 228 IDBKey* subkey = | 228 IDBKey* subkey = |
| 229 CreateIDBKeyFromValue(isolate, item, stack, exception_state); | 229 CreateIDBKeyFromValue(isolate, item, stack, exception_state); |
| 230 if (!subkey) | 230 if (!subkey) |
| 231 subkeys.push_back(IDBKey::CreateInvalid()); | 231 subkeys.push_back(IDBKey::CreateInvalid()); |
| 232 else | 232 else |
| 233 subkeys.push_back(subkey); | 233 subkeys.push_back(subkey); |
| 234 } | 234 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 v8_value = | 336 v8_value = |
| 337 v8::Date::New(isolate, V8File::toImpl(object)->lastModifiedDate()); | 337 v8::Date::New(isolate, V8File::toImpl(object)->lastModifiedDate()); |
| 338 continue; | 338 continue; |
| 339 } | 339 } |
| 340 // Fall through. | 340 // Fall through. |
| 341 } | 341 } |
| 342 | 342 |
| 343 v8::Local<v8::String> key = V8String(isolate, element); | 343 v8::Local<v8::String> key = V8String(isolate, element); |
| 344 if (!V8CallBoolean(object->HasOwnProperty(context, key))) | 344 if (!V8CallBoolean(object->HasOwnProperty(context, key))) |
| 345 return nullptr; | 345 return nullptr; |
| 346 if (!V8Call(object->Get(context, key), v8_value, block)) { | 346 if (!object->Get(context, key).ToLocal(&v8_value)) { |
| 347 exception_state.RethrowV8Exception(block.Exception()); | 347 exception_state.RethrowV8Exception(block.Exception()); |
| 348 return nullptr; | 348 return nullptr; |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 return CreateIDBKeyFromValue(isolate, v8_value, exception_state); | 351 return CreateIDBKeyFromValue(isolate, v8_value, exception_state); |
| 352 } | 352 } |
| 353 | 353 |
| 354 static IDBKey* CreateIDBKeyFromValueAndKeyPath( | 354 static IDBKey* CreateIDBKeyFromValueAndKeyPath( |
| 355 v8::Isolate* isolate, | 355 v8::Isolate* isolate, |
| 356 v8::Local<v8::Value> value, | 356 v8::Local<v8::Value> value, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // keys. | 515 // keys. |
| 516 for (size_t i = 0; i < key_path_elements.size() - 1; ++i) { | 516 for (size_t i = 0; i < key_path_elements.size() - 1; ++i) { |
| 517 if (!value->IsObject()) | 517 if (!value->IsObject()) |
| 518 return false; | 518 return false; |
| 519 | 519 |
| 520 const String& key_path_element = key_path_elements[i]; | 520 const String& key_path_element = key_path_elements[i]; |
| 521 DCHECK(!IsImplicitProperty(isolate, value, key_path_element)); | 521 DCHECK(!IsImplicitProperty(isolate, value, key_path_element)); |
| 522 v8::Local<v8::Object> object = value.As<v8::Object>(); | 522 v8::Local<v8::Object> object = value.As<v8::Object>(); |
| 523 v8::Local<v8::String> property = V8String(isolate, key_path_element); | 523 v8::Local<v8::String> property = V8String(isolate, key_path_element); |
| 524 bool has_own_property; | 524 bool has_own_property; |
| 525 if (!V8Call(object->HasOwnProperty(context, property), has_own_property)) | 525 if (!object->HasOwnProperty(context, property).To(&has_own_property)) |
| 526 return false; | 526 return false; |
| 527 if (has_own_property) { | 527 if (has_own_property) { |
| 528 if (!object->Get(context, property).ToLocal(&value)) | 528 if (!object->Get(context, property).ToLocal(&value)) |
| 529 return false; | 529 return false; |
| 530 } else { | 530 } else { |
| 531 value = v8::Object::New(isolate); | 531 value = v8::Object::New(isolate); |
| 532 if (!V8CallBoolean(object->CreateDataProperty(context, property, value))) | 532 if (!V8CallBoolean(object->CreateDataProperty(context, property, value))) |
| 533 return false; | 533 return false; |
| 534 } | 534 } |
| 535 } | 535 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 if (IsImplicitProperty(isolate, current, key_path_element)) | 578 if (IsImplicitProperty(isolate, current, key_path_element)) |
| 579 return false; | 579 return false; |
| 580 // Can't set properties on non-objects. | 580 // Can't set properties on non-objects. |
| 581 if (!current->IsObject()) | 581 if (!current->IsObject()) |
| 582 return false; | 582 return false; |
| 583 v8::Local<v8::Object> object = current.As<v8::Object>(); | 583 v8::Local<v8::Object> object = current.As<v8::Object>(); |
| 584 v8::Local<v8::String> property = V8String(isolate, key_path_element); | 584 v8::Local<v8::String> property = V8String(isolate, key_path_element); |
| 585 // If the value lacks an "own" property, it can be added - either as | 585 // If the value lacks an "own" property, it can be added - either as |
| 586 // an intermediate object or as the final value. | 586 // an intermediate object or as the final value. |
| 587 bool has_own_property; | 587 bool has_own_property; |
| 588 if (!V8Call(object->HasOwnProperty(context, property), has_own_property)) | 588 if (!object->HasOwnProperty(context, property).To(&has_own_property)) |
| 589 return false; | 589 return false; |
| 590 if (!has_own_property) | 590 if (!has_own_property) |
| 591 return true; | 591 return true; |
| 592 // Otherwise, get it and keep traversing. | 592 // Otherwise, get it and keep traversing. |
| 593 if (!object->Get(context, property).ToLocal(¤t)) | 593 if (!object->Get(context, property).ToLocal(¤t)) |
| 594 return false; | 594 return false; |
| 595 } | 595 } |
| 596 return true; | 596 return true; |
| 597 } | 597 } |
| 598 | 598 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 if (expected_key && expected_key->IsEqual(value->PrimaryKey())) | 667 if (expected_key && expected_key->IsEqual(value->PrimaryKey())) |
| 668 return; | 668 return; |
| 669 | 669 |
| 670 bool injected = InjectV8KeyIntoV8Value( | 670 bool injected = InjectV8KeyIntoV8Value( |
| 671 isolate, key_value.V8Value(), script_value.V8Value(), value->KeyPath()); | 671 isolate, key_value.V8Value(), script_value.V8Value(), value->KeyPath()); |
| 672 DCHECK(injected); | 672 DCHECK(injected); |
| 673 } | 673 } |
| 674 #endif | 674 #endif |
| 675 | 675 |
| 676 } // namespace blink | 676 } // namespace blink |
| OLD | NEW |