⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243910 in webkit


Ignore:
Timestamp:
Apr 4, 2019, 2:59:02 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r243807 and r243824.
https://bugs.webkit.org/show_bug.cgi?id=196611

Test added is a flaky timeout on iOS Simulator, 3 tests
unskipped are flaky failures (Requested by ShawnRoberts on
#webkit).

Reverted changesets:

"Blob type cannot be stored correctly in IDB when
IDBObjectStore has autoIncrement and keyPath options"
https://bugs.webkit.org/show_bug.cgi?id=196128
https://trac.webkit.org/changeset/243807

"Follow up fix for r243807: Use MarkedArgumentBuffer instead
of Vector for JSValue"
https://bugs.webkit.org/show_bug.cgi?id=196547
https://trac.webkit.org/changeset/243824

Location:
trunk
Files:
3 deleted
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243899 r243910  
     12019-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
    1222019-04-04  Eric Carlson  <eric.carlson@apple.com>
    223
  • trunk/LayoutTests/TestExpectations

    r243883 r243910  
    359359webkit.org/b/179611 imported/w3c/web-platform-tests/xhr/send-entity-body-document.htm [ Pass Failure ]
    360360imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple.html [ Skip ]
     361imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large.html [ Skip ]
     362imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small.html [ Skip ]
    361363imported/w3c/web-platform-tests/css/cssom/interfaces.html [ Pass Timeout ]
    362364[ Debug ] imported/w3c/web-platform-tests/css/cssom-view/interfaces.html [ Skip ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r243821 r243910  
     12019-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
    1222019-04-03  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-expected.txt

    r243807 r243910  
    22PASS large typed array
    33PASS blob with large typed array
    4 PASS blob with large typed array with key generator
     4FAIL blob with large typed array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]"
    55PASS array of blobs and large typed arrays
    6 PASS array of blobs and large typed arrays with key generator
     6FAIL 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]"
    77PASS object with blobs and large typed arrays
    8 PASS object with blobs and large typed arrays with key generator
     8FAIL 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]"
    99
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-large-multiple-expected.txt

    r243807 r243910  
    11
    22PASS 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
     3FAIL 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]"
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/nested-cloning-small-expected.txt

    r243807 r243910  
    33PASS blob
    44PASS blob with small typed array
    5 PASS blob with small typed array with key generator
     5FAIL blob with small typed array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]"
    66PASS blob array
    7 PASS blob array with key generator
     7FAIL blob array with key generator assert_equals: IndexedDB result class should match put() argument expected "[object Blob]" but got "[object Null]"
    88PASS array of blobs and small typed arrays
    9 PASS array of blobs and small typed arrays with key generator
     9FAIL 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]"
    1010
  • trunk/Source/WebCore/ChangeLog

    r243908 r243910  
     12019-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
    1222019-04-04  Simon Fraser  <simon.fraser@apple.com>
    223
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r243887 r243910  
    345345    m_primaryKey = m_primaryKeyData.maybeCreateIDBKey();
    346346
    347     if (isKeyCursorWithValue()) {
     347    if (isKeyCursorWithValue())
    348348        m_value = getResult.value();
    349         m_keyPath = getResult.keyPath();
    350     }
    351349
    352350    m_gotValue = true;
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h

    r243887 r243910  
    3131#include "IDBCursorDirection.h"
    3232#include "IDBCursorInfo.h"
    33 #include "IDBKeyPath.h"
    3433#include "IDBValue.h"
    3534#include "JSValueInWrappedObject.h"
     
    6160    IDBKey* primaryKey() { return m_primaryKey.get(); };
    6261    IDBValue value() { return m_value; };
    63     const Optional<IDBKeyPath>& primaryKeyPath() { return m_keyPath; };
    6462    JSValueInWrappedObject& keyWrapper() { return m_keyWrapper; }
    6563    JSValueInWrappedObject& primaryKeyWrapper() { return m_primaryKeyWrapper; }
     
    108106    IDBKeyData m_primaryKeyData;
    109107    IDBValue m_value;
    110     Optional<IDBKeyPath> m_keyPath;
    111108
    112109    JSValueInWrappedObject m_keyWrapper;
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetAllResult.cpp

    r243807 r243910  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include <wtf/CrossThreadCopier.h>
    3231#include <wtf/HashSet.h>
    3332
    3433namespace WebCore {
     34
     35template<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}
    3544
    3645IDBGetAllResult::IDBGetAllResult(const IDBGetAllResult& that, IsolatedCopyTag)
     
    4756{
    4857    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    }
    5270}
    5371
    5472void IDBGetAllResult::addKey(IDBKeyData&& key)
    5573{
    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));
    5777}
    5878
    5979void IDBGetAllResult::addValue(IDBValue&& value)
    6080{
    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));
    6284}
    6385
    6486const Vector<IDBKeyData>& IDBGetAllResult::keys() const
    6587{
    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);
    6791}
    6892
    6993const Vector<IDBValue>& IDBGetAllResult::values() const
    7094{
    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);
    7298}
    7399
     
    77103
    78104    HashSet<String> pathSet;
    79     for (auto& value : m_values) {
     105    for (auto& value : WTF::get<Vector<IDBValue>>(m_results)) {
    80106        for (auto& path : value.blobFilePaths())
    81107            pathSet.add(path);
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetAllResult.h

    r243807 r243910  
    2929
    3030#include "IDBKeyData.h"
    31 #include "IDBKeyPath.h"
    3231#include "IDBValue.h"
    3332#include "IndexedDB.h"
     
    4443    }
    4544
    46     IDBGetAllResult(IndexedDB::GetAllType type, const Optional<IDBKeyPath>& keyPath)
     45    IDBGetAllResult(IndexedDB::GetAllType type)
    4746        : m_type(type)
    48         , m_keyPath(keyPath)
    4947    {
     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        }
    5056    }
    5157
     
    5561
    5662    IndexedDB::GetAllType type() const { return m_type; }
    57     const Optional<IDBKeyPath>& keyPath() const { return m_keyPath; }
    5863    const Vector<IDBKeyData>& keys() const;
    5964    const Vector<IDBValue>& values() const;
     
    7176
    7277    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 };
    7679};
    7780
     
    7982void IDBGetAllResult::encode(Encoder& encoder) const
    8083{
    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    }
    8298}
    8399
     
    88104        return false;
    89105
    90     if (!decoder.decode(result.m_keys))
     106    uint64_t index;
     107    if (!decoder.decode(index))
    91108        return false;
    92109
    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    }
    98132
    99133    return true;
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.cpp

    r243807 r243910  
    5858}
    5959
    60 void IDBGetResult::setValue(IDBValue&& value)
    61 {
    62     m_value = WTFMove(value);
    63 }
    64 
    6560} // namespace WebCore
    6661
  • trunk/Source/WebCore/Modules/indexeddb/IDBGetResult.h

    r243807 r243910  
    4444    }
    4545
     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
    4667    IDBGetResult(const IDBKeyData& keyData)
    4768        : m_keyData(keyData)
    4869    {
     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);
    4978    }
    5079
     
    5584    }
    5685
    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))
    5988        , m_keyData(keyData)
    60         , m_keyPath(keyPath)
     89        , m_primaryKeyData(primaryKeyData)
    6190    {
    6291    }
    6392
    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)
    7395        , m_keyData(keyData)
    7496        , m_primaryKeyData(primaryKeyData)
    75         , m_keyPath(keyPath)
    7697    {
    7798    }
     
    82103    IDBGetResult isolatedCopy() const;
    83104
    84     void setValue(IDBValue&&);
    85 
    86105    const IDBValue& value() const { return m_value; }
    87106    const IDBKeyData& keyData() const { return m_keyData; }
    88107    const IDBKeyData& primaryKeyData() const { return m_primaryKeyData; }
    89     const Optional<IDBKeyPath>& keyPath() const { return m_keyPath; }
     108    const IDBKeyPath& keyPath() const { return m_keyPath; }
    90109    bool isDefined() const { return m_isDefined; }
    91110
     
    101120    IDBKeyData m_keyData;
    102121    IDBKeyData m_primaryKeyData;
    103     Optional<IDBKeyPath> m_keyPath;
     122    IDBKeyPath m_keyPath;
    104123    bool m_isDefined { true };
    105124};
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r243887 r243910  
    395395}
    396396
    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;
     397void 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;
    408408    m_resultWrapper = { };
    409409}
     
    423423}
    424424
    425 void IDBRequest::setResultToStructuredClone(const IDBGetResult& result)
     425void IDBRequest::setResultToStructuredClone(const IDBValue& value)
    426426{
    427427    ASSERT(&originThread() == &Thread::current());
     
    435435    VM& vm = context->vm();
    436436    JSLockHolder lock(vm);
    437     m_result = result;
     437    m_result = value;
    438438    m_resultWrapper = { };
    439439}
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h

    r243887 r243910  
    3232#include "IDBActiveDOMObject.h"
    3333#include "IDBError.h"
    34 #include "IDBGetAllResult.h"
    35 #include "IDBGetResult.h"
    3634#include "IDBKeyData.h"
    3735#include "IDBResourceIdentifier.h"
     
    7977    virtual ~IDBRequest();
    8078
    81     using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, IDBKeyData, Vector<IDBKeyData>, IDBGetResult, IDBGetAllResult, uint64_t, NullResultType>;
     79    using Result = Variant<RefPtr<IDBCursor>, RefPtr<IDBDatabase>, IDBKeyData, Vector<IDBKeyData>, IDBValue, Vector<IDBValue>, uint64_t, NullResultType>;
    8280    ExceptionOr<Result> result() const;
    8381    JSValueInWrappedObject& resultWrapper() { return m_resultWrapper; }
     
    110108    void setResult(const IDBKeyData&);
    111109    void setResult(const Vector<IDBKeyData>&);
    112     void setResultToStructuredClone(const IDBGetResult&);
    113     void setResult(const IDBGetAllResult&);
     110    void setResult(const Vector<IDBValue>&);
    114111    void setResult(uint64_t);
     112    void setResultToStructuredClone(const IDBValue&);
    115113    void setResultToUndefined();
    116114
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r243887 r243910  
    990990        break;
    991991    case IndexedDB::GetAllType::Values:
    992         request.setResult(getAllResult);
     992        request.setResult(getAllResult.values());
    993993        break;
    994994    }
     
    10941094    } else {
    10951095        if (resultData.getResult().value().data().data())
    1096             request.setResultToStructuredClone(resultData.getResult());
     1096            request.setResultToStructuredClone(resultData.getResult().value());
    10971097        else
    10981098            request.setResultToUndefined();
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

    r243807 r243910  
    364364
    365365    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);
    369368        break;
    370     }
    371369    case IDBGetRecordDataType::KeyOnly:
    372370        outValue = objectStore->lowestKeyWithRecordInRange(range);
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp

    r243807 r243910  
    127127        return { };
    128128
    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));
    130130}
    131131
     
    157157    LOG(IndexedDB, "MemoryIndex::getAllRecords");
    158158
    159     result = { type, m_objectStore.info().keyPath() };
     159    result = { type };
    160160
    161161    if (!m_records)
     
    180180        auto allValues = m_records->allValuesForKey(key, targetCount - currentCount);
    181181        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
    184186                result.addValue(m_objectStore.valueForKeyRange(keyValue));
    185187        }
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp

    r243807 r243910  
    7676    else {
    7777        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) };
    7979    }
    8080}
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp

    r243807 r243910  
    311311    for (auto& index : m_indexesByName.values()) {
    312312        IndexKey indexKey;
    313         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey, m_info.keyPath(), key);
     313        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey);
    314314
    315315        if (indexKey.isNull())
     
    345345
    346346        IndexKey indexKey;
    347         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey, m_info.keyPath(), iterator.key);
     347        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey);
    348348
    349349        if (indexKey.isNull())
     
    408408void MemoryObjectStore::getAllRecords(const IDBKeyRangeData& keyRangeData, Optional<uint32_t> count, IndexedDB::GetAllType type, IDBGetAllResult& result) const
    409409{
    410     result = { type, m_info.keyPath() };
     410    result = { type };
    411411
    412412    uint32_t targetCount;
     
    425425        range.lowerKey = key;
    426426        range.lowerOpen = true;
    427         if (type == IndexedDB::GetAllType::Values)
     427
     428        if (type == IndexedDB::GetAllType::Keys)
     429            result.addKey(WTFMove(key));
     430        else
    428431            result.addValue(valueForKey(key));
    429         result.addKey(WTFMove(key));
    430432
    431433        ++currentCount;
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp

    r243807 r243910  
    195195    else {
    196196        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) };
    198198    }
    199199}
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r243807 r243910  
    3030
    3131#include "IDBBindingUtilities.h"
    32 #include "IDBCursorInfo.h"
    3332#include "IDBGetAllRecordsData.h"
    3433#include "IDBGetAllResult.h"
     
    17541753
    17551754    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);
    17591756
    17601757    if (indexKey.isNull())
     
    17761773    for (auto& index : info.indexMap().values()) {
    17771774        IndexKey indexKey;
    1778         generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey, info.keyPath(), key);
     1775        generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey);
    17791776
    17801777        if (indexKey.isNull())
     
    20082005
    20092006    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;";
    20162013
    20172014        static const char* const lowerOpenUpperOpenKeyOnly = "SELECT key FROM Records WHERE objectStoreID = ? AND key > CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
     
    20702067        }
    20712068
    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);
    20942075    }
    20952076
    20962077    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
    20972090        resultValue = { keyData };
    20982091        return IDBError { };
     
    21082101        return error;
    21092102
    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) } };
    21132104    return IDBError { };
    21142105}
     
    21252116    static const char* const lowerClosedUpperOpenKey = "SELECT key FROM Records WHERE objectStoreID = ? AND key >= CAST(? AS TEXT) AND key < CAST(? AS TEXT) ORDER BY key;";
    21262117    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;";
    21312122
    21322123    if (getAllRecordsData.getAllType == IndexedDB::GetAllType::Keys) {
     
    21932184    }
    21942185
    2195     auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier);
    2196     ASSERT(objectStoreInfo);
    2197     result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() };
     2186    result = { getAllRecordsData.getAllType };
    21982187
    21992188    uint32_t targetResults;
     
    22072196
    22082197    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 
    22182198        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);
    22242204
    22252205            ASSERT(recordID);
     
    22322212                return error;
    22332213
    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));
    22352226        }
    22362227
     
    22732264    }
    22742265
    2275     auto* objectStoreInfo = infoForObjectStore(getAllRecordsData.objectStoreIdentifier);
    2276     ASSERT(objectStoreInfo);
    2277     result = { getAllRecordsData.getAllType, objectStoreInfo->keyPath() };
    2278 
     2266    result = { getAllRecordsData.getAllType };
    22792267    uint32_t currentCount = 0;
    22802268    uint32_t targetCount = getAllRecordsData.count ? getAllRecordsData.count.value() : 0;
     
    22822270        targetCount = std::numeric_limits<uint32_t>::max();
    22832271    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
    22872276            result.addValue(cursor->currentValue() ? *cursor->currentValue() : IDBValue());
    22882277
     
    23312320        if (type == IndexedDB::IndexRecordType::Key)
    23322321            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() };
    23382324    }
    23392325
     
    23862372    }
    23872373
    2388     Vector<uint8_t> valueVector;
    2389     sql->getColumnBlobAsVector(1, valueVector);
     2374    sql->getColumnBlobAsVector(1, keyVector);
    23902375
    23912376    int64_t recordID = sql->getColumnInt64(2);
     
    23982383        return error;
    23992384
    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 };
    24032386    return IDBError { };
    24042387}
     
    25652548    m_cursors.set(cursor->identifier(), cursor);
    25662549
    2567     auto* objectStoreInfo = infoForObjectStore(info.objectStoreIdentifier());
    2568     ASSERT(objectStoreInfo);
    2569     cursor->currentData(result, objectStoreInfo->keyPath());
     2550    cursor->currentData(result);
    25702551    return IDBError { };
    25712552}
     
    26102591    }
    26112592
    2612     auto* objectStoreInfo = infoForObjectStore(cursor->objectStoreID());
    2613     ASSERT(objectStoreInfo);
    2614     cursor->currentData(result, objectStoreInfo->keyPath());
     2593    cursor->currentData(result);
    26152594    return IDBError { };
    26162595}
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp

    r243807 r243910  
    102102}
    103103
    104 void SQLiteIDBCursor::currentData(IDBGetResult& result, const Optional<IDBKeyPath>& keyPath)
     104void SQLiteIDBCursor::currentData(IDBGetResult& result)
    105105{
    106106    ASSERT(!m_fetchedRecords.isEmpty());
     
    113113    }
    114114
    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() };
    116116}
    117117
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h

    r243807 r243910  
    8080    void objectStoreRecordsChanged();
    8181
    82     void currentData(IDBGetResult&, const Optional<IDBKeyPath>&);
     82    void currentData(IDBGetResult&);
    8383
    8484private:
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r243903 r243910  
    12521252    }
    12531253
     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
    12541283    // 3.4.1 Object Store Storage Operation
    12551284    // ...If a record already exists in store ...
     
    12621291    }
    12631292
    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);
    12651297
    12661298    if (!error.isNull()) {
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp

    r243807 r243910  
    234234}
    235235
    236 IDBGetResult& IDBResultData::getResultRef()
    237 {
    238     RELEASE_ASSERT(m_getResult);
    239     return *m_getResult;
    240 }
    241 
    242236const IDBGetAllResult& IDBResultData::getAllResult() const
    243237{
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h

    r243807 r243910  
    108108
    109109    WEBCORE_EXPORT const IDBGetResult& getResult() const;
    110     WEBCORE_EXPORT IDBGetResult& getResultRef();
    111110    WEBCORE_EXPORT const IDBGetAllResult& getAllResult() const;
    112111
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r243807 r243910  
    3232#include "IDBBindingUtilities.h"
    3333
    34 #include "ExceptionCode.h"
    3534#include "IDBIndexInfo.h"
    3635#include "IDBKey.h"
     
    4342#include "JSDOMConvertDate.h"
    4443#include "JSDOMConvertNullable.h"
    45 #include "JSDOMExceptionHandling.h"
    4644#include "JSFile.h"
    4745#include "Logging.h"
     
    327325        return false;
    328326
    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 
    335327    if (!set(exec, parent, keyPathElements.last(), toJS(exec, *exec.lexicalGlobalObject(), key.get())))
    336328        return false;
     
    420412}
    421413
    422 static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info, Optional<IDBKeyPath> objectStoreKeyPath, const IDBKeyData& objectStoreKey)
     414static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info)
    423415{
    424416    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 
    429417        auto idbKey = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, string);
    430418        if (!idbKey)
     
    441429        Vector<IDBKeyData> keys;
    442430        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());
    451435        }
    452436        return keys;
     
    456440}
    457441
    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);
     442void generateIndexKeyForValue(ExecState& exec, const IDBIndexInfo& info, JSValue value, IndexKey& outKey)
     443{
     444    auto keyDatas = createKeyPathArray(exec, value, info);
     445
    461446    if (keyDatas.isEmpty())
    462447        return;
     
    465450}
    466451
    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 
    483452} // namespace WebCore
    484453
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h

    r243807 r243910  
    5151bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
    5252
    53 void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey, const Optional<IDBKeyPath>&, const IDBKeyData&);
     53void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
    5454
    5555Ref<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
    5656
    57 JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&, Vector<std::pair<String, String>>&);
    5857JSC::JSValue deserializeIDBValueToJSValue(JSC::ExecState&, const IDBValue&);
    5958JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBValue&);
     
    6160JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const IDBKeyData&);
    6261
    63 Optional<JSC::JSValue> deserializeIDBValueWithKeyInjection(JSC::ExecState&, const IDBValue&, const IDBKeyData&, const Optional<IDBKeyPath>&);
    6462}
    6563
  • trunk/Source/WebCore/bindings/js/JSIDBCursorWithValueCustom.cpp

    r243807 r243910  
    3939{
    4040    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());
    4342    });
    4443}
  • trunk/Source/WebCore/bindings/js/JSIDBRequestCustom.cpp

    r243824 r243910  
    5858        }, [&state] (Vector<IDBKeyData> keyDatas) {
    5959            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);
    8064        }, [] (uint64_t number) {
    8165            return toJS<IDLUnsignedLongLong>(number);
Note: See TracChangeset for help on using the changeset viewer.