Changeset 243910 in webkit
- Timestamp:
- Apr 4, 2019, 2:59:02 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 31 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small-expected.txt (modified) (1 diff)
-
LayoutTests/storage/indexeddb/modern/objectstore-autoincrement-types-expected.txt (deleted)
-
LayoutTests/storage/indexeddb/modern/objectstore-autoincrement-types.html (deleted)
-
LayoutTests/storage/indexeddb/modern/resources/objectstore-autoincrement-types.js (deleted)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/IDBCursor.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/IDBCursor.h (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/IDBGetAllResult.h (modified) (6 diffs)
-
Source/WebCore/Modules/indexeddb/IDBGetResult.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/IDBGetResult.h (modified) (4 diffs)
-
Source/WebCore/Modules/indexeddb/IDBRequest.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/IDBRequest.h (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (modified) (17 diffs)
-
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp (modified) (1 diff)
-
Source/WebCore/Modules/indexeddb/shared/IDBResultData.h (modified) (1 diff)
-
Source/WebCore/bindings/js/IDBBindingUtilities.cpp (modified) (7 diffs)
-
Source/WebCore/bindings/js/IDBBindingUtilities.h (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp (modified) (1 diff)
-
Source/WebCore/bindings/js/JSIDBRequestCustom.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243899 r243910 1 2019-04-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r243807 and r243824. 4 https://bugs.webkit.org/show_bug.cgi?id=196611 5 6 Test added is a flaky timeout on iOS Simulator, 3 tests 7 unskipped are flaky failures (Requested by ShawnRoberts on 8 #webkit). 9 10 Reverted changesets: 11 12 "Blob type cannot be stored correctly in IDB when 13 IDBObjectStore has autoIncrement and keyPath options" 14 https://bugs.webkit.org/show_bug.cgi?id=196128 15 https://trac.webkit.org/changeset/243807 16 17 "Follow up fix for r243807: Use MarkedArgumentBuffer instead 18 of Vector for JSValue" 19 https://bugs.webkit.org/show_bug.cgi?id=196547 20 https://trac.webkit.org/changeset/243824 21 1 22 2019-04-04 Eric Carlson <eric.carlson@apple.com> 2 23 -
trunk/LayoutTests/TestExpectations
r243883 r243910 359 359 webkit.org/b/179611 imported/w3c/web-platform-tests/xhr/send-entity-body-document.htm [ Pass Failure ] 360 360 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple.html [ Skip ] 361 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large.html [ Skip ] 362 imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small.html [ Skip ] 361 363 imported/w3c/web-platform-tests/css/cssom/interfaces.html [ Pass Timeout ] 362 364 [ Debug ] imported/w3c/web-platform-tests/css/cssom-view/interfaces.html [ Skip ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r243821 r243910 1 2019-04-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r243807 and r243824. 4 https://bugs.webkit.org/show_bug.cgi?id=196611 5 6 Test added is a flaky timeout on iOS Simulator, 3 tests 7 unskipped are flaky failures (Requested by ShawnRoberts on 8 #webkit). 9 10 Reverted changesets: 11 12 "Blob type cannot be stored correctly in IDB when 13 IDBObjectStore has autoIncrement and keyPath options" 14 https://bugs.webkit.org/show_bug.cgi?id=196128 15 https://trac.webkit.org/changeset/243807 16 17 "Follow up fix for r243807: Use MarkedArgumentBuffer instead 18 of Vector for JSValue" 19 https://bugs.webkit.org/show_bug.cgi?id=196547 20 https://trac.webkit.org/changeset/243824 21 1 22 2019-04-03 Chris Dumez <cdumez@apple.com> 2 23 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-expected.txt
r243807 r243910 2 2 PASS large typed array 3 3 PASS blob with large typed array 4 PASS blob with large typed array with key generator 4 FAIL blob with large typed array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 5 5 PASS array of blobs and large typed arrays 6 PASS array of blobs and large typed arrays with key generator 6 FAIL array of blobs and large typed arrays with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 7 7 PASS object with blobs and large typed arrays 8 PASS object with blobs and large typed arrays with key generator 8 FAIL object with blobs and large typed arrays with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 9 9 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple-expected.txt
r243807 r243910 1 1 2 2 PASS multiple requests of objects with blobs and large typed arrays 3 PASS multiple requests of objects with blobs and large typed arrays with key generator 3 FAIL multiple requests of objects with blobs and large typed arrays with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small-expected.txt
r243807 r243910 3 3 PASS blob 4 4 PASS blob with small typed array 5 PASS blob with small typed array with key generator 5 FAIL blob with small typed array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 6 6 PASS blob array 7 PASS blob array with key generator 7 FAIL blob array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 8 8 PASS array of blobs and small typed arrays 9 PASS array of blobs and small typed arrays with key generator 9 FAIL array of blobs and small typed arrays with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]" 10 10 -
trunk/Source/WebCore/ChangeLog
r243908 r243910 1 2019-04-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r243807 and r243824. 4 https://bugs.webkit.org/show_bug.cgi?id=196611 5 6 Test added is a flaky timeout on iOS Simulator, 3 tests 7 unskipped are flaky failures (Requested by ShawnRoberts on 8 #webkit). 9 10 Reverted changesets: 11 12 "Blob type cannot be stored correctly in IDB when 13 IDBObjectStore has autoIncrement and keyPath options" 14 https://bugs.webkit.org/show_bug.cgi?id=196128 15 https://trac.webkit.org/changeset/243807 16 17 "Follow up fix for r243807: Use MarkedArgumentBuffer instead 18 of Vector for JSValue" 19 https://bugs.webkit.org/show_bug.cgi?id=196547 20 https://trac.webkit.org/changeset/243824 21 1 22 2019-04-04 Simon Fraser <simon.fraser@apple.com> 2 23 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp
r243887 r243910 345 345 m_primaryKey = m_primaryKeyData.maybeCreateIDBKey(); 346 346 347 if (isKeyCursorWithValue()) {347 if (isKeyCursorWithValue()) 348 348 m_value = getResult.value(); 349 m_keyPath = getResult.keyPath();350 }351 349 352 350 m_gotValue = true; -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h
r243887 r243910 31 31 #include "IDBCursorDirection.h" 32 32 #include "IDBCursorInfo.h" 33 #include "IDBKeyPath.h"34 33 #include "IDBValue.h" 35 34 #include "JSValueInWrappedObject.h" … … 61 60 IDBKey* primaryKey() { return m_primaryKey.get(); }; 62 61 IDBValue value() { return m_value; }; 63 const Optional<IDBKeyPath>& primaryKeyPath() { return m_keyPath; };64 62 JSValueInWrappedObject& keyWrapper() { return m_keyWrapper; } 65 63 JSValueInWrappedObject& primaryKeyWrapper() { return m_primaryKeyWrapper; } … … 108 106 IDBKeyData m_primaryKeyData; 109 107 IDBValue m_value; 110 Optional<IDBKeyPath> m_keyPath;111 108 112 109 JSValueInWrappedObject m_keyWrapper; -
trunk/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp
r243807 r243910 29 29 #if ENABLE(INDEXED_DATABASE) 30 30 31 #include <wtf/CrossThreadCopier.h>32 31 #include <wtf/HashSet.h> 33 32 34 33 namespace WebCore { 34 35 template<typename T> void isolatedCopyOfVariant(const WTF::Variant<Vector<IDBKeyData>, Vector<IDBValue>, std::nullptr_t>& source, WTF::Variant<Vector<IDBKeyData>, Vector<IDBValue>, std::nullptr_t>& target) 36 { 37 target = Vector<T>(); 38 auto& sourceVector = WTF::get<Vector<T>>(source); 39 auto& targetVector = WTF::get<Vector<T>>(target); 40 targetVector.reserveInitialCapacity(sourceVector.size()); 41 for (auto& element : sourceVector) 42 targetVector.uncheckedAppend(element.isolatedCopy()); 43 } 35 44 36 45 IDBGetAllResult::IDBGetAllResult(const IDBGetAllResult& that, IsolatedCopyTag) … … 47 56 { 48 57 destination.m_type = source.m_type; 49 destination.m_keys = crossThreadCopy(source.m_keys); 50 destination.m_values = crossThreadCopy(source.m_values); 51 destination.m_keyPath = WebCore::isolatedCopy(source.m_keyPath); 58 59 if (WTF::holds_alternative<std::nullptr_t>(source.m_results)) 60 return; 61 62 switch (source.m_type) { 63 case IndexedDB::GetAllType::Keys: 64 isolatedCopyOfVariant<IDBKeyData>(source.m_results, destination.m_results); 65 break; 66 case IndexedDB::GetAllType::Values: 67 isolatedCopyOfVariant<IDBValue>(source.m_results, destination.m_results); 68 break; 69 } 52 70 } 53 71 54 72 void IDBGetAllResult::addKey(IDBKeyData&& key) 55 73 { 56 m_keys.append(WTFMove(key)); 74 ASSERT(m_type == IndexedDB::GetAllType::Keys); 75 ASSERT(WTF::holds_alternative<Vector<IDBKeyData>>(m_results)); 76 WTF::get<Vector<IDBKeyData>>(m_results).append(WTFMove(key)); 57 77 } 58 78 59 79 void IDBGetAllResult::addValue(IDBValue&& value) 60 80 { 61 m_values.append(WTFMove(value)); 81 ASSERT(m_type == IndexedDB::GetAllType::Values); 82 ASSERT(WTF::holds_alternative<Vector<IDBValue>>(m_results)); 83 WTF::get<Vector<IDBValue>>(m_results).append(WTFMove(value)); 62 84 } 63 85 64 86 const Vector<IDBKeyData>& IDBGetAllResult::keys() const 65 87 { 66 return m_keys; 88 ASSERT(m_type == IndexedDB::GetAllType::Keys); 89 ASSERT(WTF::holds_alternative<Vector<IDBKeyData>>(m_results)); 90 return WTF::get<Vector<IDBKeyData>>(m_results); 67 91 } 68 92 69 93 const Vector<IDBValue>& IDBGetAllResult::values() const 70 94 { 71 return m_values; 95 ASSERT(m_type == IndexedDB::GetAllType::Values); 96 ASSERT(WTF::holds_alternative<Vector<IDBValue>>(m_results)); 97 return WTF::get<Vector<IDBValue>>(m_results); 72 98 } 73 99 … … 77 103 78 104 HashSet<String> pathSet; 79 for (auto& value : m_values) {105 for (auto& value : WTF::get<Vector<IDBValue>>(m_results)) { 80 106 for (auto& path : value.blobFilePaths()) 81 107 pathSet.add(path); -
trunk/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h
r243807 r243910 29 29 30 30 #include "IDBKeyData.h" 31 #include "IDBKeyPath.h"32 31 #include "IDBValue.h" 33 32 #include "IndexedDB.h" … … 44 43 } 45 44 46 IDBGetAllResult(IndexedDB::GetAllType type , const Optional<IDBKeyPath>& keyPath)45 IDBGetAllResult(IndexedDB::GetAllType type) 47 46 : m_type(type) 48 , m_keyPath(keyPath)49 47 { 48 switch (m_type) { 49 case IndexedDB::GetAllType::Keys: 50 m_results = Vector<IDBKeyData>(); 51 break; 52 case IndexedDB::GetAllType::Values: 53 m_results = Vector<IDBValue>(); 54 break; 55 } 50 56 } 51 57 … … 55 61 56 62 IndexedDB::GetAllType type() const { return m_type; } 57 const Optional<IDBKeyPath>& keyPath() const { return m_keyPath; }58 63 const Vector<IDBKeyData>& keys() const; 59 64 const Vector<IDBValue>& values() const; … … 71 76 72 77 IndexedDB::GetAllType m_type { IndexedDB::GetAllType::Keys }; 73 Vector<IDBKeyData> m_keys; 74 Vector<IDBValue> m_values; 75 Optional<IDBKeyPath> m_keyPath; 78 WTF::Variant<Vector<IDBKeyData>, Vector<IDBValue>, std::nullptr_t> m_results { nullptr }; 76 79 }; 77 80 … … 79 82 void IDBGetAllResult::encode(Encoder& encoder) const 80 83 { 81 encoder << m_type << m_keys << m_values << m_keyPath; 84 encoder << m_type << static_cast<uint64_t>(m_results.index()); 85 86 switch (m_results.index()) { 87 case 0: 88 encoder << WTF::get<Vector<IDBKeyData>>(m_results); 89 break; 90 case 1: 91 encoder << WTF::get<Vector<IDBValue>>(m_results); 92 break; 93 case 2: 94 break; 95 default: 96 RELEASE_ASSERT_NOT_REACHED(); 97 } 82 98 } 83 99 … … 88 104 return false; 89 105 90 if (!decoder.decode(result.m_keys)) 106 uint64_t index; 107 if (!decoder.decode(index)) 91 108 return false; 92 109 93 if (!decoder.decode(result.m_values)) 94 return false; 95 96 if (!decoder.decode(result.m_keyPath)) 97 return false; 110 switch (index) { 111 case 0: { 112 result.m_results = Vector<IDBKeyData>(); 113 if (!decoder.decode(WTF::get<Vector<IDBKeyData>>(result.m_results))) 114 return false; 115 break; 116 } 117 case 1: { 118 result.m_results = Vector<IDBValue>(); 119 Optional<Vector<IDBValue>> optional; 120 decoder >> optional; 121 if (!optional) 122 return false; 123 WTF::get<Vector<IDBValue>>(result.m_results) = WTFMove(*optional); 124 break; 125 } 126 case 2: 127 result.m_results = nullptr; 128 break; 129 default: 130 RELEASE_ASSERT_NOT_REACHED(); 131 } 98 132 99 133 return true; -
trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp
r243807 r243910 58 58 } 59 59 60 void IDBGetResult::setValue(IDBValue&& value)61 {62 m_value = WTFMove(value);63 }64 65 60 } // namespace WebCore 66 61 -
trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h
r243807 r243910 44 44 } 45 45 46 IDBGetResult(const IDBValue& value, const IDBKeyData& currentPrimaryKey) 47 : m_value(value) 48 , m_primaryKeyData(currentPrimaryKey) 49 { 50 } 51 52 IDBGetResult(const ThreadSafeDataBuffer& buffer) 53 : m_value(buffer) 54 { 55 } 56 57 IDBGetResult(IDBValue&& buffer) 58 : m_value(WTFMove(buffer)) 59 { 60 } 61 62 IDBGetResult(IDBKey& key) 63 : m_keyData(&key) 64 { 65 } 66 46 67 IDBGetResult(const IDBKeyData& keyData) 47 68 : m_keyData(keyData) 48 69 { 70 } 71 72 IDBGetResult(SharedBuffer* buffer, IDBKey& key, const IDBKeyPath& path) 73 : m_keyData(&key) 74 , m_keyPath(path) 75 { 76 if (buffer) 77 dataFromBuffer(*buffer); 49 78 } 50 79 … … 55 84 } 56 85 57 IDBGetResult(const IDBKeyData& keyData, const ThreadSafeDataBuffer& buffer, const Optional<IDBKeyPath>& keyPath)58 : m_value( buffer)86 IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData, IDBValue&& value) 87 : m_value(WTFMove(value)) 59 88 , m_keyData(keyData) 60 , m_ keyPath(keyPath)89 , m_primaryKeyData(primaryKeyData) 61 90 { 62 91 } 63 92 64 IDBGetResult(const IDBKeyData& keyData, IDBValue&& value, const Optional<IDBKeyPath>& keyPath) 65 : m_value(WTFMove(value)) 66 , m_keyData(keyData) 67 , m_keyPath(keyPath) 68 { 69 } 70 71 IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData, IDBValue&& value, const Optional<IDBKeyPath>& keyPath) 72 : m_value(WTFMove(value)) 93 IDBGetResult(const IDBKeyData& keyData, const IDBKeyData& primaryKeyData, const IDBValue& value) 94 : m_value(value) 73 95 , m_keyData(keyData) 74 96 , m_primaryKeyData(primaryKeyData) 75 , m_keyPath(keyPath)76 97 { 77 98 } … … 82 103 IDBGetResult isolatedCopy() const; 83 104 84 void setValue(IDBValue&&);85 86 105 const IDBValue& value() const { return m_value; } 87 106 const IDBKeyData& keyData() const { return m_keyData; } 88 107 const IDBKeyData& primaryKeyData() const { return m_primaryKeyData; } 89 const Optional<IDBKeyPath>& keyPath() const { return m_keyPath; }108 const IDBKeyPath& keyPath() const { return m_keyPath; } 90 109 bool isDefined() const { return m_isDefined; } 91 110 … … 101 120 IDBKeyData m_keyData; 102 121 IDBKeyData m_primaryKeyData; 103 Optional<IDBKeyPath>m_keyPath;122 IDBKeyPath m_keyPath; 104 123 bool m_isDefined { true }; 105 124 }; -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r243887 r243910 395 395 } 396 396 397 void IDBRequest::setResult(const IDBGetAllResult& result)398 { 399 ASSERT(&originThread() == &Thread::current()); 400 401 auto* context = scriptExecutionContext(); 402 if (!context) 403 return; 404 405 VM& vm = context->vm(); 406 JSLockHolder lock(vm); 407 m_result = result;397 void IDBRequest::setResult(const Vector<IDBValue>& values) 398 { 399 ASSERT(&originThread() == &Thread::current()); 400 401 auto* context = scriptExecutionContext(); 402 if (!context) 403 return; 404 405 VM& vm = context->vm(); 406 JSLockHolder lock(vm); 407 m_result = values; 408 408 m_resultWrapper = { }; 409 409 } … … 423 423 } 424 424 425 void IDBRequest::setResultToStructuredClone(const IDB GetResult& result)425 void IDBRequest::setResultToStructuredClone(const IDBValue& value) 426 426 { 427 427 ASSERT(&originThread() == &Thread::current()); … … 435 435 VM& vm = context->vm(); 436 436 JSLockHolder lock(vm); 437 m_result = result;437 m_result = value; 438 438 m_resultWrapper = { }; 439 439 } -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h
r243887 r243910 32 32 #include "IDBActiveDOMObject.h" 33 33 #include "IDBError.h" 34 #include "IDBGetAllResult.h"35 #include "IDBGetResult.h"36 34 #include "IDBKeyData.h" 37 35 #include "IDBResourceIdentifier.h" … … 79 77 virtual ~IDBRequest(); 80 78 81 using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, IDBKeyData, Vector<IDBKeyData>, IDB GetResult, IDBGetAllResult, uint64_t, NullResultType>;79 using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, IDBKeyData, Vector<IDBKeyData>, IDBValue, Vector<IDBValue>, uint64_t, NullResultType>; 82 80 ExceptionOr<Result> result() const; 83 81 JSValueInWrappedObject& resultWrapper() { return m_resultWrapper; } … … 110 108 void setResult(const IDBKeyData&); 111 109 void setResult(const Vector<IDBKeyData>&); 112 void setResultToStructuredClone(const IDBGetResult&); 113 void setResult(const IDBGetAllResult&); 110 void setResult(const Vector<IDBValue>&); 114 111 void setResult(uint64_t); 112 void setResultToStructuredClone(const IDBValue&); 115 113 void setResultToUndefined(); 116 114 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r243887 r243910 990 990 break; 991 991 case IndexedDB::GetAllType::Values: 992 request.setResult(getAllResult );992 request.setResult(getAllResult.values()); 993 993 break; 994 994 } … … 1094 1094 } else { 1095 1095 if (resultData.getResult().value().data().data()) 1096 request.setResultToStructuredClone(resultData.getResult() );1096 request.setResultToStructuredClone(resultData.getResult().value()); 1097 1097 else 1098 1098 request.setResultToUndefined(); -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
r243807 r243910 364 364 365 365 switch (type) { 366 case IDBGetRecordDataType::KeyAndValue: { 367 auto key = objectStore->lowestKeyWithRecordInRange(range); 368 outValue = { key, key.isNull() ? ThreadSafeDataBuffer() : objectStore->valueForKey(key), objectStore->info().keyPath() }; 366 case IDBGetRecordDataType::KeyAndValue: 367 outValue = objectStore->valueForKeyRange(range); 369 368 break; 370 }371 369 case IDBGetRecordDataType::KeyOnly: 372 370 outValue = objectStore->lowestKeyWithRecordInRange(range); -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp
r243807 r243910 127 127 return { }; 128 128 129 return type == IndexedDB::IndexRecordType::Key ? IDBGetResult(*keyValue) : IDBGetResult( *keyValue, m_objectStore.valueForKeyRange(*keyValue), m_objectStore.info().keyPath());129 return type == IndexedDB::IndexRecordType::Key ? IDBGetResult(*keyValue) : IDBGetResult(m_objectStore.valueForKeyRange(*keyValue)); 130 130 } 131 131 … … 157 157 LOG(IndexedDB, "MemoryIndex::getAllRecords"); 158 158 159 result = { type , m_objectStore.info().keyPath()};159 result = { type }; 160 160 161 161 if (!m_records) … … 180 180 auto allValues = m_records->allValuesForKey(key, targetCount - currentCount); 181 181 for (auto& keyValue : allValues) { 182 result.addKey(IDBKeyData(keyValue)); 183 if (type == IndexedDB::GetAllType::Values) 182 if (type == IndexedDB::GetAllType::Keys) { 183 IDBKeyData keyCopy { keyValue }; 184 result.addKey(WTFMove(keyCopy)); 185 } else 184 186 result.addValue(m_objectStore.valueForKeyRange(keyValue)); 185 187 } -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp
r243807 r243910 76 76 else { 77 77 IDBValue value = { m_index.objectStore().valueForKey(m_currentPrimaryKey), { }, { }, { } }; 78 getResult = { m_currentKey, m_currentPrimaryKey, WTFMove(value) , m_index.objectStore().info().keyPath()};78 getResult = { m_currentKey, m_currentPrimaryKey, WTFMove(value) }; 79 79 } 80 80 } -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp
r243807 r243910 311 311 for (auto& index : m_indexesByName.values()) { 312 312 IndexKey indexKey; 313 generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey , m_info.keyPath(), key);313 generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey); 314 314 315 315 if (indexKey.isNull()) … … 345 345 346 346 IndexKey indexKey; 347 generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey , m_info.keyPath(), iterator.key);347 generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey); 348 348 349 349 if (indexKey.isNull()) … … 408 408 void MemoryObjectStore::getAllRecords(const IDBKeyRangeData& keyRangeData, Optional<uint32_t> count, IndexedDB::GetAllType type, IDBGetAllResult& result) const 409 409 { 410 result = { type , m_info.keyPath()};410 result = { type }; 411 411 412 412 uint32_t targetCount; … … 425 425 range.lowerKey = key; 426 426 range.lowerOpen = true; 427 if (type == IndexedDB::GetAllType::Values) 427 428 if (type == IndexedDB::GetAllType::Keys) 429 result.addKey(WTFMove(key)); 430 else 428 431 result.addValue(valueForKey(key)); 429 result.addKey(WTFMove(key));430 432 431 433 ++currentCount; -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp
r243807 r243910 195 195 else { 196 196 IDBValue value = { m_objectStore.valueForKeyRange(m_currentPositionKey), { }, { }, { } }; 197 data = { m_currentPositionKey, m_currentPositionKey, WTFMove(value) , m_objectStore.info().keyPath()};197 data = { m_currentPositionKey, m_currentPositionKey, WTFMove(value) }; 198 198 } 199 199 } -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r243807 r243910 30 30 31 31 #include "IDBBindingUtilities.h" 32 #include "IDBCursorInfo.h"33 32 #include "IDBGetAllRecordsData.h" 34 33 #include "IDBGetAllResult.h" … … 1754 1753 1755 1754 IndexKey indexKey; 1756 auto* objectStoreInfo = infoForObjectStore(info.objectStoreIdentifier()); 1757 ASSERT(objectStoreInfo); 1758 generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue, indexKey, objectStoreInfo->keyPath(), key); 1755 generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue, indexKey); 1759 1756 1760 1757 if (indexKey.isNull()) … … 1776 1773 for (auto& index : info.indexMap().values()) { 1777 1774 IndexKey indexKey; 1778 generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey , info.keyPath(), key);1775 generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey); 1779 1776 1780 1777 if (indexKey.isNull()) … … 2008 2005 2009 2006 int64_t recordID = 0; 2010 ThreadSafeDataBuffer keyResultBuffer, valueResultBuffer;2011 { 2012 static const char* const lowerOpenUpperOpen = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";2013 static const char* const lowerOpenUpperClosed = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";2014 static const char* const lowerClosedUpperOpen = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";2015 static const char* const lowerClosedUpperClosed = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";2007 ThreadSafeDataBuffer resultBuffer; 2008 { 2009 static const char* const lowerOpenUpperOpen = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; 2010 static const char* const lowerOpenUpperClosed = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;"; 2011 static const char* const lowerClosedUpperOpen = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; 2012 static const char* const lowerClosedUpperClosed = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;"; 2016 2013 2017 2014 static const char* const lowerOpenUpperOpenKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; … … 2070 2067 } 2071 2068 2072 Vector<uint8_t> keyBuffer; 2073 sql->getColumnBlobAsVector(0, keyBuffer); 2074 keyResultBuffer = ThreadSafeDataBuffer::create(WTFMove(keyBuffer)); 2075 2076 if (type == IDBGetRecordDataType::KeyAndValue) { 2077 Vector<uint8_t> valueBuffer; 2078 sql->getColumnBlobAsVector(1, valueBuffer); 2079 valueResultBuffer = ThreadSafeDataBuffer::create(WTFMove(valueBuffer)); 2080 recordID = sql->getColumnInt64(2); 2081 } 2082 } 2083 2084 auto* keyVector = keyResultBuffer.data(); 2085 if (!keyVector) { 2086 LOG_ERROR("Unable to deserialize key data from database for IDBObjectStore"); 2087 return IDBError { UnknownError, "Error extracting key data from database executing IDBObjectStore get"_s }; 2088 } 2089 2090 IDBKeyData keyData; 2091 if (!deserializeIDBKeyData(keyVector->data(), keyVector->size(), keyData)) { 2092 LOG_ERROR("Unable to deserialize key data from database for IDBObjectStore"); 2093 return IDBError { UnknownError, "Error extracting key data from database executing IDBObjectStore get"_s }; 2069 Vector<uint8_t> buffer; 2070 sql->getColumnBlobAsVector(0, buffer); 2071 resultBuffer = ThreadSafeDataBuffer::create(WTFMove(buffer)); 2072 2073 if (type == IDBGetRecordDataType::KeyAndValue) 2074 recordID = sql->getColumnInt64(1); 2094 2075 } 2095 2076 2096 2077 if (type == IDBGetRecordDataType::KeyOnly) { 2078 auto* vector = resultBuffer.data(); 2079 if (!vector) { 2080 LOG_ERROR("Unable to deserialize key data from database for IDBObjectStore.getKey()"); 2081 return IDBError { UnknownError, "Error extracting key data from database executing IDBObjectStore.getKey()"_s }; 2082 } 2083 2084 IDBKeyData keyData; 2085 if (!deserializeIDBKeyData(vector->data(), vector->size(), keyData)) { 2086 LOG_ERROR("Unable to deserialize key data from database for IDBObjectStore.getKey()"); 2087 return IDBError { UnknownError, "Error extracting key data from database executing IDBObjectStore.getKey()"_s }; 2088 } 2089 2097 2090 resultValue = { keyData }; 2098 2091 return IDBError { }; … … 2108 2101 return error; 2109 2102 2110 auto* objectStoreInfo = infoForObjectStore(objectStoreID); 2111 ASSERT(objectStoreInfo); 2112 resultValue = { keyData, { valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath()}; 2103 resultValue = { { resultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) } }; 2113 2104 return IDBError { }; 2114 2105 } … … 2125 2116 static const char* const lowerClosedUpperOpenKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; 2126 2117 static const char* const lowerClosedUpperClosedKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;"; 2127 static const char* const lowerOpenUpperOpenValue = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";2128 static const char* const lowerOpenUpperClosedValue = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";2129 static const char* const lowerClosedUpperOpenValue = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";2130 static const char* const lowerClosedUpperClosedValue = "SELECT key,value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;";2118 static const char* const lowerOpenUpperOpenValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; 2119 static const char* const lowerOpenUpperClosedValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;"; 2120 static const char* const lowerClosedUpperOpenValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;"; 2121 static const char* const lowerClosedUpperClosedValue = "SELECT value, ROWID FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key <= CAST(? AS TEXT) ORDER BY key;"; 2131 2122 2132 2123 if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Keys) { … … 2193 2184 } 2194 2185 2195 auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier); 2196 ASSERT(objectStoreInfo); 2197 result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() }; 2186 result = { getAllRecordsData.getAllType }; 2198 2187 2199 2188 uint32_t targetResults; … … 2207 2196 2208 2197 while (sqlResult == SQLITE_ROW && returnedResults < targetResults) { 2209 Vector<uint8_t> keyBuffer;2210 IDBKeyData keyData;2211 sql->getColumnBlobAsVector(0, keyBuffer);2212 if (!deserializeIDBKeyData(keyBuffer.data(), keyBuffer.size(), keyData)) {2213 LOG_ERROR("Unable to deserialize key data from database while getting all records");2214 return IDBError { UnknownError, "Unable to deserialize key data while getting all records"_s };2215 }2216 result.addKey(WTFMove(keyData));2217 2218 2198 if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Values) { 2219 Vector<uint8_t> valueBuffer;2220 sql->getColumnBlobAsVector( 1, valueBuffer);2221 ThreadSafeDataBuffer valueResultBuffer = ThreadSafeDataBuffer::create(WTFMove(valueBuffer));2222 2223 auto recordID = sql->getColumnInt64( 2);2199 Vector<uint8_t> buffer; 2200 sql->getColumnBlobAsVector(0, buffer); 2201 ThreadSafeDataBuffer resultBuffer = ThreadSafeDataBuffer::create(WTFMove(buffer)); 2202 2203 auto recordID = sql->getColumnInt64(1); 2224 2204 2225 2205 ASSERT(recordID); … … 2232 2212 return error; 2233 2213 2234 result.addValue({ valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }); 2214 result.addValue({ resultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }); 2215 } else { 2216 Vector<uint8_t> keyData; 2217 IDBKeyData key; 2218 sql->getColumnBlobAsVector(0, keyData); 2219 2220 if (!deserializeIDBKeyData(keyData.data(), keyData.size(), key)) { 2221 LOG_ERROR("Unable to deserialize key data from database while getting all key records"); 2222 return IDBError { UnknownError, "Unable to deserialize key data while getting all key records"_s }; 2223 } 2224 2225 result.addKey(WTFMove(key)); 2235 2226 } 2236 2227 … … 2273 2264 } 2274 2265 2275 auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier); 2276 ASSERT(objectStoreInfo); 2277 result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() }; 2278 2266 result = { getAllRecordsData.getAllType }; 2279 2267 uint32_t currentCount = 0; 2280 2268 uint32_t targetCount = getAllRecordsData.count ? getAllRecordsData.count.value() : 0; … … 2282 2270 targetCount = std::numeric_limits<uint32_t>::max(); 2283 2271 while (!cursor->didComplete() && !cursor->didError() && currentCount < targetCount) { 2284 IDBKeyData keyCopy = cursor->currentPrimaryKey(); 2285 result.addKey(WTFMove(keyCopy)); 2286 if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Values) 2272 if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Keys) { 2273 IDBKeyData keyCopy = cursor->currentPrimaryKey(); 2274 result.addKey(WTFMove(keyCopy)); 2275 } else 2287 2276 result.addValue(cursor->currentValue() ? *cursor->currentValue() : IDBValue()); 2288 2277 … … 2331 2320 if (type == IndexedDB::IndexRecordType::Key) 2332 2321 getResult = { cursor->currentPrimaryKey() }; 2333 else { 2334 auto* objectStoreInfo = infoForObjectStore(objectStoreID); 2335 ASSERT(objectStoreInfo); 2336 getResult = { cursor->currentPrimaryKey(), cursor->currentPrimaryKey(), cursor->currentValue() ? *cursor->currentValue() : IDBValue(), objectStoreInfo->keyPath() }; 2337 } 2322 else 2323 getResult = { cursor->currentValue() ? *cursor->currentValue() : IDBValue(), cursor->currentPrimaryKey() }; 2338 2324 } 2339 2325 … … 2386 2372 } 2387 2373 2388 Vector<uint8_t> valueVector; 2389 sql->getColumnBlobAsVector(1, valueVector); 2374 sql->getColumnBlobAsVector(1, keyVector); 2390 2375 2391 2376 int64_t recordID = sql->getColumnInt64(2); … … 2398 2383 return error; 2399 2384 2400 auto* objectStoreInfo = infoForObjectStore(objectStoreID); 2401 ASSERT(objectStoreInfo); 2402 getResult = { objectStoreKey, objectStoreKey, { ThreadSafeDataBuffer::create(WTFMove(valueVector)), WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath() }; 2385 getResult = { { ThreadSafeDataBuffer::create(WTFMove(keyVector)), WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreKey }; 2403 2386 return IDBError { }; 2404 2387 } … … 2565 2548 m_cursors.set(cursor->identifier(), cursor); 2566 2549 2567 auto* objectStoreInfo = infoForObjectStore(info.objectStoreIdentifier()); 2568 ASSERT(objectStoreInfo); 2569 cursor->currentData(result, objectStoreInfo->keyPath()); 2550 cursor->currentData(result); 2570 2551 return IDBError { }; 2571 2552 } … … 2610 2591 } 2611 2592 2612 auto* objectStoreInfo = infoForObjectStore(cursor->objectStoreID()); 2613 ASSERT(objectStoreInfo); 2614 cursor->currentData(result, objectStoreInfo->keyPath()); 2593 cursor->currentData(result); 2615 2594 return IDBError { }; 2616 2595 } -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
r243807 r243910 102 102 } 103 103 104 void SQLiteIDBCursor::currentData(IDBGetResult& result , const Optional<IDBKeyPath>& keyPath)104 void SQLiteIDBCursor::currentData(IDBGetResult& result) 105 105 { 106 106 ASSERT(!m_fetchedRecords.isEmpty()); … … 113 113 } 114 114 115 result = { currentRecord.record.key, currentRecord.record.primaryKey, currentRecord.record.value ? *currentRecord.record.value : IDBValue() , keyPath};115 result = { currentRecord.record.key, currentRecord.record.primaryKey, currentRecord.record.value ? *currentRecord.record.value : IDBValue() }; 116 116 } 117 117 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h
r243807 r243910 80 80 void objectStoreRecordsChanged(); 81 81 82 void currentData(IDBGetResult& , const Optional<IDBKeyPath>&);82 void currentData(IDBGetResult&); 83 83 84 84 private: -
trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
r243903 r243910 1252 1252 } 1253 1253 1254 // 3.4.1.2 Object Store Storage Operation 1255 // If ObjectStore has a key path and the key is autogenerated, then inject the key into the value 1256 // using steps to assign a key to a value using a key path. 1257 ThreadSafeDataBuffer injectedRecordValue; 1258 if (usedKeyIsGenerated && objectStoreInfo->keyPath()) { 1259 VM& vm = databaseThreadVM(); 1260 JSLockHolder locker(vm); 1261 auto scope = DECLARE_THROW_SCOPE(vm); 1262 1263 auto value = deserializeIDBValueToJSValue(databaseThreadExecState(), originalRecordValue.data()); 1264 if (value.isUndefined()) { 1265 postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to deserialize record value for record key injection"_s), usedKey)); 1266 return; 1267 } 1268 1269 if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value, objectStoreInfo->keyPath().value())) { 1270 postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to inject record key into record value"_s), usedKey)); 1271 return; 1272 } 1273 1274 auto serializedValue = SerializedScriptValue::create(databaseThreadExecState(), value); 1275 if (UNLIKELY(scope.exception())) { 1276 postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(ConstraintError, "Unable to serialize record value after injecting record key"_s), usedKey)); 1277 return; 1278 } 1279 1280 injectedRecordValue = ThreadSafeDataBuffer::copyVector(serializedValue->data()); 1281 } 1282 1254 1283 // 3.4.1 Object Store Storage Operation 1255 1284 // ...If a record already exists in store ... … … 1262 1291 } 1263 1292 1264 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue); 1293 if (injectedRecordValue.data()) 1294 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, { injectedRecordValue, originalRecordValue.blobURLs(), originalRecordValue.sessionID(), originalRecordValue.blobFilePaths() }); 1295 else 1296 error = m_backingStore->addRecord(transactionIdentifier, *objectStoreInfo, usedKey, originalRecordValue); 1265 1297 1266 1298 if (!error.isNull()) { -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp
r243807 r243910 234 234 } 235 235 236 IDBGetResult& IDBResultData::getResultRef()237 {238 RELEASE_ASSERT(m_getResult);239 return *m_getResult;240 }241 242 236 const IDBGetAllResult& IDBResultData::getAllResult() const 243 237 { -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h
r243807 r243910 108 108 109 109 WEBCORE_EXPORT const IDBGetResult& getResult() const; 110 WEBCORE_EXPORT IDBGetResult& getResultRef();111 110 WEBCORE_EXPORT const IDBGetAllResult& getAllResult() const; 112 111 -
trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp
r243807 r243910 32 32 #include "IDBBindingUtilities.h" 33 33 34 #include "ExceptionCode.h"35 34 #include "IDBIndexInfo.h" 36 35 #include "IDBKey.h" … … 43 42 #include "JSDOMConvertDate.h" 44 43 #include "JSDOMConvertNullable.h" 45 #include "JSDOMExceptionHandling.h"46 44 #include "JSFile.h" 47 45 #include "Logging.h" … … 327 325 return false; 328 326 329 // Do not set if object already has the correct property value.330 auto jsKey = toJS(exec, *exec.lexicalGlobalObject(), key.get());331 JSValue existingKey;332 if (get(exec, parent, keyPathElements.last(), existingKey) && existingKey == jsKey)333 return true;334 335 327 if (!set(exec, parent, keyPathElements.last(), toJS(exec, *exec.lexicalGlobalObject(), key.get()))) 336 328 return false; … … 420 412 } 421 413 422 static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info , Optional<IDBKeyPath> objectStoreKeyPath, const IDBKeyData& objectStoreKey)414 static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info) 423 415 { 424 416 auto visitor = WTF::makeVisitor([&](const String& string) -> Vector<IDBKeyData> { 425 // Value doesn't contain auto-generated key, so we need to manually add key if it is possibly auto-generated.426 if (objectStoreKeyPath && WTF::holds_alternative<String>(objectStoreKeyPath.value()) && IDBKeyPath(string) == objectStoreKeyPath.value())427 return { objectStoreKey };428 429 417 auto idbKey = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, string); 430 418 if (!idbKey) … … 441 429 Vector<IDBKeyData> keys; 442 430 for (auto& entry : vector) { 443 if (objectStoreKeyPath && WTF::holds_alternative<String>(objectStoreKeyPath.value()) && IDBKeyPath(entry) == objectStoreKeyPath.value()) 444 keys.append(objectStoreKey); 445 else { 446 auto key = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, entry); 447 if (!key || !key->isValid()) 448 return { }; 449 keys.append(key.get()); 450 } 431 auto key = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, entry); 432 if (!key || !key->isValid()) 433 return { }; 434 keys.append(key.get()); 451 435 } 452 436 return keys; … … 456 440 } 457 441 458 void generateIndexKeyForValue(ExecState& exec, const IDBIndexInfo& info, JSValue value, IndexKey& outKey, const Optional<IDBKeyPath>& objectStoreKeyPath, const IDBKeyData& objectStoreKey) 459 { 460 auto keyDatas = createKeyPathArray(exec, value, info, objectStoreKeyPath, objectStoreKey); 442 void generateIndexKeyForValue(ExecState& exec, const IDBIndexInfo& info, JSValue value, IndexKey& outKey) 443 { 444 auto keyDatas = createKeyPathArray(exec, value, info); 445 461 446 if (keyDatas.isEmpty()) 462 447 return; … … 465 450 } 466 451 467 Optional<JSC::JSValue> deserializeIDBValueWithKeyInjection(ExecState& state, const IDBValue& value, const IDBKeyData& key, const Optional<IDBKeyPath>& keyPath)468 {469 auto jsValue = deserializeIDBValueToJSValue(state, value);470 if (jsValue.isUndefined() || !keyPath || !WTF::holds_alternative<String>(keyPath.value()) || !isIDBKeyPathValid(keyPath.value()))471 return jsValue;472 473 JSLockHolder locker(state.vm());474 if (!injectIDBKeyIntoScriptValue(state, key, jsValue, keyPath.value())) {475 auto throwScope = DECLARE_THROW_SCOPE(state.vm());476 propagateException(state, throwScope, Exception(UnknownError, "Cannot inject key into script value"_s));477 return WTF::nullopt;478 }479 480 return jsValue;481 }482 483 452 } // namespace WebCore 484 453 -
trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h
r243807 r243910 51 51 bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&); 52 52 53 void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey , const Optional<IDBKeyPath>&, const IDBKeyData&);53 void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey); 54 54 55 55 Ref<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&); 56 56 57 JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&, Vector<std::pair<String, String>>&);58 57 JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&); 59 58 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBValue&); … … 61 60 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBKeyData&); 62 61 63 Optional<JSC::JSValue> deserializeIDBValueWithKeyInjection(JSC::ExecState&, const IDBValue&, const IDBKeyData&, const Optional<IDBKeyPath>&);64 62 } 65 63 -
trunk/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp
r243807 r243910 39 39 { 40 40 return cachedPropertyValue(state, *this, wrapped().valueWrapper(), [&] { 41 auto result = deserializeIDBValueWithKeyInjection(state, wrapped().value(), wrapped().primaryKey(), wrapped().primaryKeyPath()); 42 return result ? result.value() : jsNull(); 41 return deserializeIDBValueToJSValue(state, wrapped().value()); 43 42 }); 44 43 } -
trunk/Source/WebCore/bindings/js/JSIDBRequestCustom.cpp
r243824 r243910 58 58 }, [&state] (Vector<IDBKeyData> keyDatas) { 59 59 return toJS<IDLSequence<IDLIDBKeyData>>(state, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), keyDatas); 60 }, [&state] (IDBGetResult getResult) { 61 auto result = deserializeIDBValueWithKeyInjection(state, getResult.value(), getResult.keyData(), getResult.keyPath()); 62 return result ? result.value() : jsNull(); 63 }, [&state] (IDBGetAllResult getAllResult) { 64 auto& keys = getAllResult.keys(); 65 auto& values = getAllResult.values(); 66 auto& keyPath = getAllResult.keyPath(); 67 auto scope = DECLARE_THROW_SCOPE(state.vm()); 68 JSC::MarkedArgumentBuffer list; 69 for (unsigned i = 0; i < values.size(); i ++) { 70 auto result = deserializeIDBValueWithKeyInjection(state, values[i], keys[i], keyPath); 71 if (!result) 72 return jsNull(); 73 list.append(result.value()); 74 if (UNLIKELY(list.hasOverflowed())) { 75 propagateException(state, scope, Exception(UnknownError)); 76 return jsNull(); 77 } 78 } 79 return JSValue(JSC::constructArray(&state, nullptr, state.lexicalGlobalObject(), list)); 60 }, [&state] (IDBValue value) { 61 return toJS<IDLIDBValue>(state, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), value); 62 }, [&state] (Vector<IDBValue> values) { 63 return toJS<IDLSequence<IDLIDBValue>>(state, *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), values); 80 64 }, [] (uint64_t number) { 81 65 return toJS<IDLUnsignedLongLong>(number);
Note:
See TracChangeset
for help on using the changeset viewer.