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

Changeset 199643 in webkit


Ignore:
Timestamp:
Apr 17, 2016, 11:49:53 AM (10 years ago)
Author:
beidson@apple.com
Message:

Clean up IDBBindingUtilities.
https://bugs.webkit.org/show_bug.cgi?id=156472

Reviewed by Alex Christensen.

No new tests (No change in behavior).

  • Get rid of a whole bunch of unused functions (since we got rid of Legacy IDB).
  • Make more functions deal in ExecState/ScriptExecutionContexts instead of DOMRequestState.
  • Make more functions deal in JSValue (as JSC::Strong<JSC::Unknown>) instead of Deprecated::ScriptValue.
  • bindings/scripts/IDLAttributes.txt: Add a new attribute to signify that an implementation returns JSValues instead of Deprecated::ScriptState
  • bindings/scripts/CodeGeneratorJS.pm:

(NativeToJSValue): Use that new attribute.

  • Modules/indexeddb/IDBAny.cpp:

(WebCore::IDBAny::IDBAny):
(WebCore::IDBAny::scriptValue):

  • Modules/indexeddb/IDBAny.h:

(WebCore::IDBAny::create):

  • Modules/indexeddb/IDBCursor.cpp:

(WebCore::IDBCursor::key):
(WebCore::IDBCursor::primaryKey):
(WebCore::IDBCursor::value):
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::continueFunction):
(WebCore::IDBCursor::deleteFunction):
(WebCore::IDBCursor::setGetResult):

  • Modules/indexeddb/IDBCursor.h:
  • Modules/indexeddb/IDBCursor.idl:
  • Modules/indexeddb/IDBCursorWithValue.idl:
  • Modules/indexeddb/IDBFactory.cpp:

(WebCore::IDBFactory::cmp):

  • Modules/indexeddb/IDBIndex.cpp:

(WebCore::IDBIndex::count):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::getKey):

  • Modules/indexeddb/IDBKeyRange.cpp:

(WebCore::IDBKeyRange::lowerValue):
(WebCore::IDBKeyRange::upperValue):
(WebCore::IDBKeyRange::only):
(WebCore::IDBKeyRange::lowerBound):
(WebCore::IDBKeyRange::upperBound):
(WebCore::IDBKeyRange::bound):

  • Modules/indexeddb/IDBKeyRange.h:
  • Modules/indexeddb/IDBKeyRange.idl:
  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::modernDelete):
(WebCore::IDBObjectStore::count):

  • Modules/indexeddb/IDBRequest.cpp:

(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):

  • Modules/indexeddb/server/MemoryObjectStore.cpp:

(WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord):
(WebCore::IDBServer::MemoryObjectStore::populateIndexWithExistingRecords):

  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::updateOneIndexForAddRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord):

  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::idbKeyPathFromValue):
(WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::injectIDBKeyIntoScriptValue):
(WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath):
(WebCore::canInjectIDBKeyIntoScriptValue):
(WebCore::deserializeIDBValueToJSValue):
(WebCore::deserializeIDBValueDataToJSValue):
(WebCore::scriptValueToIDBKey):
(WebCore::idbKeyDataToScriptValue):
(WebCore::idbKeyDataToJSValue): Deleted.
(WebCore::createIDBKeyFromScriptValueAndKeyPath): Deleted.
(WebCore::deserializeIDBValue): Deleted.
(WebCore::deserializeIDBValueData): Deleted.
(WebCore::deserializeIDBValueBuffer): Deleted.
(WebCore::idbValueDataToJSValue): Deleted.
(WebCore::idbKeyToScriptValue): Deleted.

  • bindings/js/IDBBindingUtilities.h:
  • bindings/js/JSIDBAnyCustom.cpp:

(WebCore::toJS):

  • bindings/js/JSIDBDatabaseCustom.cpp:

(WebCore::JSIDBDatabase::createObjectStore):

  • bindings/js/JSIDBObjectStoreCustom.cpp:

(WebCore::JSIDBObjectStore::createIndex):

  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::execState):

  • dom/ScriptExecutionContext.h:
  • inspector/InspectorIndexedDBAgent.cpp:
Location:
trunk/Source/WebCore
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199642 r199643  
     12016-04-17  Brady Eidson  <beidson@apple.com>
     2
     3        Clean up IDBBindingUtilities.
     4        https://bugs.webkit.org/show_bug.cgi?id=156472
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests (No change in behavior).
     9
     10        - Get rid of a whole bunch of unused functions (since we got rid of Legacy IDB).
     11        - Make more functions deal in ExecState/ScriptExecutionContexts instead of DOMRequestState.
     12        - Make more functions deal in JSValue (as JSC::Strong<JSC::Unknown>) instead of Deprecated::ScriptValue.
     13
     14        * bindings/scripts/IDLAttributes.txt: Add a new attribute to signify that an implementation returns
     15          JSValues instead of Deprecated::ScriptState
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        (NativeToJSValue): Use that new attribute.
     18       
     19        * Modules/indexeddb/IDBAny.cpp:
     20        (WebCore::IDBAny::IDBAny):
     21        (WebCore::IDBAny::scriptValue):
     22        * Modules/indexeddb/IDBAny.h:
     23        (WebCore::IDBAny::create):
     24       
     25        * Modules/indexeddb/IDBCursor.cpp:
     26        (WebCore::IDBCursor::key):
     27        (WebCore::IDBCursor::primaryKey):
     28        (WebCore::IDBCursor::value):
     29        (WebCore::IDBCursor::update):
     30        (WebCore::IDBCursor::continueFunction):
     31        (WebCore::IDBCursor::deleteFunction):
     32        (WebCore::IDBCursor::setGetResult):
     33        * Modules/indexeddb/IDBCursor.h:
     34        * Modules/indexeddb/IDBCursor.idl:
     35        * Modules/indexeddb/IDBCursorWithValue.idl:
     36       
     37        * Modules/indexeddb/IDBFactory.cpp:
     38        (WebCore::IDBFactory::cmp):
     39       
     40        * Modules/indexeddb/IDBIndex.cpp:
     41        (WebCore::IDBIndex::count):
     42        (WebCore::IDBIndex::get):
     43        (WebCore::IDBIndex::getKey):
     44       
     45        * Modules/indexeddb/IDBKeyRange.cpp:
     46        (WebCore::IDBKeyRange::lowerValue):
     47        (WebCore::IDBKeyRange::upperValue):
     48        (WebCore::IDBKeyRange::only):
     49        (WebCore::IDBKeyRange::lowerBound):
     50        (WebCore::IDBKeyRange::upperBound):
     51        (WebCore::IDBKeyRange::bound):
     52        * Modules/indexeddb/IDBKeyRange.h:
     53        * Modules/indexeddb/IDBKeyRange.idl:
     54       
     55        * Modules/indexeddb/IDBObjectStore.cpp:
     56        (WebCore::IDBObjectStore::get):
     57        (WebCore::IDBObjectStore::modernDelete):
     58        (WebCore::IDBObjectStore::count):
     59       
     60        * Modules/indexeddb/IDBRequest.cpp:
     61        (WebCore::IDBRequest::setResult):
     62        (WebCore::IDBRequest::setResultToStructuredClone):
     63       
     64        * Modules/indexeddb/server/MemoryObjectStore.cpp:
     65        (WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord):
     66        (WebCore::IDBServer::MemoryObjectStore::populateIndexWithExistingRecords):
     67       
     68        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     69        (WebCore::IDBServer::SQLiteIDBBackingStore::updateOneIndexForAddRecord):
     70        (WebCore::IDBServer::SQLiteIDBBackingStore::updateAllIndexesForAddRecord):
     71       
     72        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     73        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
     74       
     75        * bindings/js/IDBBindingUtilities.cpp:
     76        (WebCore::idbKeyPathFromValue):
     77        (WebCore::internalCreateIDBKeyFromScriptValueAndKeyPath):
     78        (WebCore::injectIDBKeyIntoScriptValue):
     79        (WebCore::maybeCreateIDBKeyFromScriptValueAndKeyPath):
     80        (WebCore::canInjectIDBKeyIntoScriptValue):
     81        (WebCore::deserializeIDBValueToJSValue):
     82        (WebCore::deserializeIDBValueDataToJSValue):
     83        (WebCore::scriptValueToIDBKey):
     84        (WebCore::idbKeyDataToScriptValue):
     85        (WebCore::idbKeyDataToJSValue): Deleted.
     86        (WebCore::createIDBKeyFromScriptValueAndKeyPath): Deleted.
     87        (WebCore::deserializeIDBValue): Deleted.
     88        (WebCore::deserializeIDBValueData): Deleted.
     89        (WebCore::deserializeIDBValueBuffer): Deleted.
     90        (WebCore::idbValueDataToJSValue): Deleted.
     91        (WebCore::idbKeyToScriptValue): Deleted.
     92        * bindings/js/IDBBindingUtilities.h:
     93
     94        * bindings/js/JSIDBAnyCustom.cpp:
     95        (WebCore::toJS):
     96
     97        * bindings/js/JSIDBDatabaseCustom.cpp:
     98        (WebCore::JSIDBDatabase::createObjectStore):
     99
     100        * bindings/js/JSIDBObjectStoreCustom.cpp:
     101        (WebCore::JSIDBObjectStore::createIndex):
     102
     103        * dom/ScriptExecutionContext.cpp:
     104        (WebCore::ScriptExecutionContext::execState):
     105        * dom/ScriptExecutionContext.h:
     106
     107        * inspector/InspectorIndexedDBAgent.cpp:
     108
    11092016-04-17  Darin Adler  <darin@apple.com>
    2110
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp

    r199323 r199643  
    7979}
    8080
    81 IDBAny::IDBAny(const Deprecated::ScriptValue& value)
     81IDBAny::IDBAny(const JSC::Strong<JSC::Unknown>& value)
    8282    : m_type(IDBAny::Type::ScriptValue)
    8383    , m_scriptValue(value)
     
    134134}
    135135
    136 const Deprecated::ScriptValue& IDBAny::scriptValue()
     136JSC::JSValue IDBAny::scriptValue()
    137137{
    138     return m_scriptValue;
     138    return m_scriptValue.get();
    139139}
    140140
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.h

    r199323 r199643  
    3030#include "IDBKeyPath.h"
    3131#include "ScriptWrappable.h"
    32 #include <bindings/ScriptValue.h>
     32#include <heap/Strong.h>
     33#include <runtime/JSCJSValue.h>
    3334#include <wtf/RefCounted.h>
    3435
     
    7172    }
    7273
    73     static RefPtr<IDBAny> create(const Deprecated::ScriptValue& value)
     74    static RefPtr<IDBAny> create(const JSC::Strong<JSC::Unknown>& value)
    7475    {
    7576        return adoptRef(new IDBAny(value));
     
    109110    RefPtr<IDBObjectStore> idbObjectStore();
    110111    RefPtr<IDBTransaction> idbTransaction();
    111     const Deprecated::ScriptValue& scriptValue();
     112    JSC::JSValue scriptValue();
    112113    int64_t integer();
    113114    const String& string();
     
    121122    explicit IDBAny(Ref<IDBCursor>&&);
    122123    explicit IDBAny(const IDBKeyPath&);
    123     explicit IDBAny(const Deprecated::ScriptValue&);
     124    explicit IDBAny(const JSC::Strong<JSC::Unknown>&);
    124125
    125126    IDBAny::Type m_type { IDBAny::Type::Undefined };
     
    131132
    132133    const IDBKeyPath m_idbKeyPath;
    133     const Deprecated::ScriptValue m_scriptValue;
     134    JSC::Strong<JSC::Unknown> m_scriptValue;
    134135    const String m_string;
    135136    const int64_t m_integer { 0 };
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r199524 r199643  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "DOMRequestState.h"
    3231#include "ExceptionCode.h"
    3332#include "IDBBindingUtilities.h"
     
    4140#include <wtf/NeverDestroyed.h>
    4241
     42using namespace JSC;
     43
    4344namespace WebCore {
    4445
     
    158159}
    159160
    160 const Deprecated::ScriptValue& IDBCursor::key() const
    161 {
    162     return m_deprecatedCurrentKey;
    163 }
    164 
    165 const Deprecated::ScriptValue& IDBCursor::primaryKey() const
    166 {
    167     return m_deprecatedCurrentPrimaryKey;
    168 }
    169 
    170 const Deprecated::ScriptValue& IDBCursor::value() const
    171 {
    172     return m_deprecatedCurrentValue;
     161JSValue IDBCursor::key(ExecState&) const
     162{
     163    return m_currentKey.get();
     164}
     165
     166JSValue IDBCursor::primaryKey(ExecState&) const
     167{
     168    return m_currentPrimaryKey.get();
     169}
     170
     171JSValue IDBCursor::value(ExecState&) const
     172{
     173    return m_currentValue.get();
    173174}
    174175
     
    225226    }
    226227
    227     auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
     228    auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_currentPrimaryKey.get(), ec);
    228229    if (ec.code)
    229230        return nullptr;
     
    281282void IDBCursor::continueFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCodeWithMessage& ec)
    282283{
    283     DOMRequestState requestState(&context);
    284284    RefPtr<IDBKey> key;
    285285    if (!keyValue.jsValue().isUndefined())
    286         key = scriptValueToIDBKey(&requestState, keyValue);
     286        key = scriptValueToIDBKey(context, keyValue);
    287287
    288288    continueFunction(key.get(), ec);
     
    381381    }
    382382
    383     auto request = effectiveObjectStore().modernDelete(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec);
     383    auto request = effectiveObjectStore().modernDelete(context, m_currentPrimaryKey.get(), ec);
    384384    if (ec.code)
    385385        return nullptr;
     
    401401
    402402    if (!getResult.isDefined()) {
    403         m_deprecatedCurrentKey = { };
     403        m_currentKey = { };
    404404        m_currentKeyData = { };
    405         m_deprecatedCurrentPrimaryKey = { };
     405        m_currentPrimaryKey = { };
    406406        m_currentPrimaryKeyData = { };
    407         m_deprecatedCurrentValue = { };
     407        m_currentValue = { };
    408408
    409409        m_gotValue = false;
     
    411411    }
    412412
    413     m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData());
     413    m_currentKey = idbKeyDataToScriptValue(*context, getResult.keyData());
    414414    m_currentKeyData = getResult.keyData();
    415     m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData());
     415    m_currentPrimaryKey = idbKeyDataToScriptValue(*context, getResult.primaryKeyData());
    416416    m_currentPrimaryKeyData = getResult.primaryKeyData();
    417417
    418418    if (isKeyCursor())
    419         m_deprecatedCurrentValue = { };
     419        m_currentValue = { };
    420420    else
    421         m_deprecatedCurrentValue = deserializeIDBValue(*context, getResult.value());
     421        m_currentValue = deserializeIDBValueToJSValue(*context, getResult.value());
    422422
    423423    m_gotValue = true;
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h

    r199323 r199643  
    3232#include "IDBAny.h"
    3333#include "IDBCursorInfo.h"
     34#include <runtime/JSCJSValue.h>
    3435
    3536namespace WebCore {
     
    5758    // Implement the IDL
    5859    const String& direction() const;
    59     const Deprecated::ScriptValue& key() const;
    60     const Deprecated::ScriptValue& primaryKey() const;
    61     const Deprecated::ScriptValue& value() const;
     60    JSC::JSValue key(JSC::ExecState&) const;
     61    JSC::JSValue primaryKey(JSC::ExecState&) const;
     62    JSC::JSValue value(JSC::ExecState&) const;
    6263    IDBAny* source();
    6364
     
    112113    IDBKeyData m_currentPrimaryKeyData;
    113114
    114     // FIXME: When ditching Legacy IDB and combining this implementation with the abstract IDBCursor,
    115     // these Deprecated::ScriptValue members should be JSValues instead.
    116     Deprecated::ScriptValue m_deprecatedCurrentKey;
    117     Deprecated::ScriptValue m_deprecatedCurrentPrimaryKey;
    118     Deprecated::ScriptValue m_deprecatedCurrentValue;
     115    JSC::Strong<JSC::Unknown> m_currentKey;
     116    JSC::Strong<JSC::Unknown> m_currentPrimaryKey;
     117    JSC::Strong<JSC::Unknown> m_currentValue;
    119118};
    120119
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl

    r199323 r199643  
    3333    readonly attribute IDBAny source;
    3434    readonly attribute DOMString direction;
    35     readonly attribute any key;
    36     readonly attribute any primaryKey;
     35    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any key;
     36    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any primaryKey;
    3737
    3838    [CallWith=ScriptState, RaisesExceptionWithMessage] IDBRequest update(any value);
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl

    r199323 r199643  
    3131    JSCustomMarkFunction,
    3232] interface IDBCursorWithValue : IDBCursor {
    33     readonly attribute any value;
     33    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any value;
    3434};
  • trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp

    r199323 r199643  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "DOMRequestState.h"
    3231#include "Document.h"
    3332#include "ExceptionCode.h"
     
    150149short IDBFactory::cmp(ScriptExecutionContext& context, const Deprecated::ScriptValue& firstValue, const Deprecated::ScriptValue& secondValue, ExceptionCodeWithMessage& ec)
    151150{
    152     DOMRequestState requestState(&context);
    153     RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue);
    154     RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue);
     151    RefPtr<IDBKey> first = scriptValueToIDBKey(context, firstValue);
     152    RefPtr<IDBKey> second = scriptValueToIDBKey(context, secondValue);
    155153
    156154    ASSERT(first);
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp

    r199323 r199643  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "DOMRequestState.h"
    3231#include "IDBAny.h"
    3332#include "IDBBindingUtilities.h"
     
    161160    LOG(IndexedDB, "IDBIndex::count");
    162161
    163     DOMRequestState requestState(&context);
    164     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     162    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    165163    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    166164        ec.code = IDBDatabaseException::DataError;
     
    243241    LOG(IndexedDB, "IDBIndex::get");
    244242
    245     DOMRequestState requestState(&context);
    246     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     243    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    247244    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    248245        ec.code = IDBDatabaseException::DataError;
     
    288285    LOG(IndexedDB, "IDBIndex::getKey");
    289286
    290     DOMRequestState requestState(&context);
    291     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     287    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    292288    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    293289        ec.code = IDBDatabaseException::DataError;
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp

    r199323 r199643  
    2727#include "IDBKeyRange.h"
    2828
    29 #include "DOMRequestState.h"
    3029#include "IDBBindingUtilities.h"
    3130#include "IDBDatabaseException.h"
    3231#include "IDBKey.h"
     32#include "IDBKeyData.h"
    3333
    3434#if ENABLE(INDEXED_DATABASE)
     35
     36using namespace JSC;
    3537
    3638namespace WebCore {
     
    5052}
    5153
    52 Deprecated::ScriptValue IDBKeyRange::lowerValue(ScriptExecutionContext& context) const
     54JSValue IDBKeyRange::lowerValue(ScriptExecutionContext& context) const
    5355{
    54     DOMRequestState requestState(&context);
    55     return idbKeyToScriptValue(&requestState, m_lower);
     56    return idbKeyDataToScriptValue(context, IDBKeyData(m_lower.get())).get();
    5657}
    5758
    58 Deprecated::ScriptValue IDBKeyRange::upperValue(ScriptExecutionContext& context) const
     59JSValue IDBKeyRange::upperValue(ScriptExecutionContext& context) const
    5960{
    60     DOMRequestState requestState(&context);
    61     return idbKeyToScriptValue(&requestState, m_upper);
     61    return idbKeyDataToScriptValue(context, IDBKeyData(m_upper.get())).get();
    6262}
    6363
     
    7474RefPtr<IDBKeyRange> IDBKeyRange::only(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCode& ec)
    7575{
    76     DOMRequestState requestState(&context);
    77     RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue);
     76    RefPtr<IDBKey> key = scriptValueToIDBKey(context, keyValue);
    7877    if (!key || !key->isValid()) {
    7978        ec = IDBDatabaseException::DataError;
     
    8685RefPtr<IDBKeyRange> IDBKeyRange::lowerBound(ScriptExecutionContext& context, const Deprecated::ScriptValue& boundValue, bool open, ExceptionCode& ec)
    8786{
    88     DOMRequestState requestState(&context);
    89     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue);
     87    RefPtr<IDBKey> bound = scriptValueToIDBKey(context, boundValue);
    9088    if (!bound || !bound->isValid()) {
    9189        ec = IDBDatabaseException::DataError;
     
    9896RefPtr<IDBKeyRange> IDBKeyRange::upperBound(ScriptExecutionContext& context, const Deprecated::ScriptValue& boundValue, bool open, ExceptionCode& ec)
    9997{
    100     DOMRequestState requestState(&context);
    101     RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue);
     98    RefPtr<IDBKey> bound = scriptValueToIDBKey(context, boundValue);
    10299    if (!bound || !bound->isValid()) {
    103100        ec = IDBDatabaseException::DataError;
     
    110107RefPtr<IDBKeyRange> IDBKeyRange::bound(ScriptExecutionContext& context, const Deprecated::ScriptValue& lowerValue, const Deprecated::ScriptValue& upperValue, bool lowerOpen, bool upperOpen, ExceptionCode& ec)
    111108{
    112     DOMRequestState requestState(&context);
    113     RefPtr<IDBKey> lower = scriptValueToIDBKey(&requestState, lowerValue);
    114     RefPtr<IDBKey> upper = scriptValueToIDBKey(&requestState, upperValue);
     109    RefPtr<IDBKey> lower = scriptValueToIDBKey(context, lowerValue);
     110    RefPtr<IDBKey> upper = scriptValueToIDBKey(context, upperValue);
    115111
    116112    if (!lower || !lower->isValid() || !upper || !upper->isValid()) {
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h

    r199323 r199643  
    5959    IDBKey* upper() const { return m_upper.get(); }
    6060
    61     Deprecated::ScriptValue lowerValue(ScriptExecutionContext&) const;
    62     Deprecated::ScriptValue upperValue(ScriptExecutionContext&) const;
     61    JSC::JSValue lowerValue(ScriptExecutionContext&) const;
     62    JSC::JSValue upperValue(ScriptExecutionContext&) const;
    6363    bool lowerOpen() const { return m_lowerType == LowerBoundOpen; }
    6464    bool upperOpen() const { return m_upperType == UpperBoundOpen; }
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.idl

    r199323 r199643  
    2929    EnabledAtRuntime=IndexedDB,
    3030] interface IDBKeyRange {
    31     [ImplementedAs=lowerValue,CallWith=ScriptExecutionContext] readonly attribute any lower;
    32     [ImplementedAs=upperValue,CallWith=ScriptExecutionContext] readonly attribute any upper;
     31    [ImplementedAs=lowerValue, CallWith=ScriptExecutionContext, ImplementationReturnType=JSValue] readonly attribute any lower;
     32    [ImplementedAs=upperValue, CallWith=ScriptExecutionContext, ImplementationReturnType=JSValue] readonly attribute any upper;
    3333    readonly attribute boolean lowerOpen;
    3434    readonly attribute boolean upperOpen;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r199323 r199643  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "DOMRequestState.h"
    3231#include "DOMStringList.h"
    3332#include "IDBBindingUtilities.h"
     
    183182    }
    184183
    185     DOMRequestState requestState(&context);
    186     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     184    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    187185    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    188186        ec.code = IDBDatabaseException::DataError;
     
    400398RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext& context, JSC::JSValue key, ExceptionCodeWithMessage& ec)
    401399{
    402     DOMRequestState requestState(&context);
    403     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     400    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    404401    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    405402        ec.code = IDBDatabaseException::DataError;
     
    595592    LOG(IndexedDB, "IDBObjectStore::count");
    596593
    597     DOMRequestState requestState(&context);
    598     RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
     594    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
    599595    if (!idbKey || idbKey->type() == KeyType::Invalid) {
    600596        ec.code = IDBDatabaseException::DataError;
  • trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp

    r199581 r199643  
    3030
    3131#include "DOMError.h"
    32 #include "DOMRequestState.h"
    3332#include "Event.h"
    3433#include "EventQueue.h"
     
    327326void IDBRequest::setResult(const IDBKeyData* keyData)
    328327{
    329     if (!keyData) {
     328    auto* context = scriptExecutionContext();
     329    if (!context || !keyData) {
    330330        m_result = nullptr;
    331331        return;
    332332    }
    333333
    334     Deprecated::ScriptValue value = idbKeyDataToScriptValue(scriptExecutionContext(), *keyData);
    335     m_result = IDBAny::create(WTFMove(value));
     334    m_result = IDBAny::create(idbKeyDataToScriptValue(*context, *keyData));
    336335}
    337336
     
    339338{
    340339    ASSERT(scriptExecutionContext());
    341     m_result = IDBAny::create(Deprecated::ScriptValue(scriptExecutionContext()->vm(), JSC::JSValue(number)));
     340    m_result = IDBAny::create(JSC::Strong<JSC::Unknown>(scriptExecutionContext()->vm(), JSC::JSValue(number)));
    342341}
    343342
     
    350349        return;
    351350
    352     Deprecated::ScriptValue scriptValue = deserializeIDBValue(*context, value);
    353     m_result = IDBAny::create(WTFMove(scriptValue));
     351    m_result = IDBAny::create(deserializeIDBValueToJSValue(*context, value));
    354352}
    355353
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp

    r199323 r199643  
    302302    JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
    303303
    304     auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
     304    auto jsValue = deserializeIDBValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
    305305    if (jsValue.isUndefinedOrNull())
    306306        return { };
     
    311311    for (auto& index : m_indexesByName.values()) {
    312312        IndexKey indexKey;
    313         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey);
     313        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue.get(), indexKey);
    314314
    315315        if (indexKey.isNull())
     
    340340
    341341    for (auto iterator : *m_keyValueStore) {
    342         auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), iterator.value);
     342        auto jsValue = deserializeIDBValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), iterator.value);
    343343        if (jsValue.isUndefinedOrNull())
    344344            return { };
    345345
    346346        IndexKey indexKey;
    347         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey);
     347        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue.get(), indexKey);
    348348
    349349        if (indexKey.isNull())
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r199524 r199643  
    14691469
    14701470    IndexKey indexKey;
    1471     generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue, indexKey);
     1471    generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue.get(), indexKey);
    14721472
    14731473    if (indexKey.isNull())
     
    14891489    for (auto& index : info.indexMap().values()) {
    14901490        IndexKey indexKey;
    1491         generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey);
     1491        generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue.get(), indexKey);
    14921492
    14931493        if (indexKey.isNull())
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r199250 r199643  
    766766        JSLockHolder locker(databaseThreadVM());
    767767
    768         JSValue value = deserializeIDBValueDataToJSValue(databaseThreadExecState(), originalRecordValue.data());
    769         if (value.isUndefined()) {
     768        auto value = deserializeIDBValueDataToJSValue(databaseThreadExecState(), originalRecordValue.data());
     769        if (value.get().isUndefined()) {
    770770            m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to deserialize record value for record key injection")), usedKey));
    771771            return;
    772772        }
    773773
    774         if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value, objectStoreInfo->keyPath())) {
     774        if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value.get(), objectStoreInfo->keyPath())) {
    775775            m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to inject record key into record value")), usedKey));
    776776            return;
    777777        }
    778778
    779         auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
     779        auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value.get(), nullptr, nullptr);
    780780        if (databaseThreadExecState().hadException()) {
    781781            m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r199524 r199643  
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 * Copyright (C) 2012 Michael Pruett <michael@68k.org>
     4 * Copyright (C) 2014, 2015, 2016 Apple Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    3031#include "IDBBindingUtilities.h"
    3132
    32 #include "DOMRequestState.h"
    3333#include "IDBIndexInfo.h"
    3434#include "IDBKey.h"
     
    3939#include "JSDOMBinding.h"
    4040#include "Logging.h"
     41#include "ScriptExecutionContext.h"
    4142#include "SharedBuffer.h"
    4243#include "ThreadSafeDataBuffer.h"
     
    7778    asObject(object)->putDirect(exec->vm(), identifier, jsValue);
    7879    return true;
    79 }
    80 
    81 JSValue idbKeyDataToJSValue(JSC::ExecState& exec, const IDBKeyData& keyData)
    82 {
    83     if (keyData.isNull())
    84         return jsUndefined();
    85 
    86     Locker<JSLock> locker(exec.vm().apiLock());
    87 
    88     switch (keyData.type()) {
    89     case KeyType::Array:
    90         {
    91             const Vector<IDBKeyData>& inArray = keyData.array();
    92             size_t size = inArray.size();
    93             JSArray* outArray = constructEmptyArray(&exec, 0, exec.lexicalGlobalObject(), size);
    94             for (size_t i = 0; i < size; ++i) {
    95                 auto& arrayKey = inArray.at(i);
    96                 outArray->putDirectIndex(&exec, i, idbKeyDataToJSValue(exec, arrayKey));
    97             }
    98             return JSValue(outArray);
    99         }
    100     case KeyType::String:
    101         return jsStringWithCache(&exec, keyData.string());
    102     case KeyType::Date:
    103         return jsDateOrNull(&exec, keyData.date());
    104     case KeyType::Number:
    105         return jsNumber(keyData.number());
    106     case KeyType::Min:
    107     case KeyType::Max:
    108     case KeyType::Invalid:
    109         ASSERT_NOT_REACHED();
    110         return jsUndefined();
    111     }
    112 
    113     ASSERT_NOT_REACHED();
    114     return jsUndefined();
    115 
    11680}
    11781
     
    203167}
    204168
    205 IDBKeyPath idbKeyPathFromValue(ExecState* exec, JSValue keyPathValue)
     169IDBKeyPath idbKeyPathFromValue(ExecState& exec, JSValue keyPathValue)
    206170{
    207171    IDBKeyPath keyPath;
    208172    if (isJSArray(keyPathValue))
    209         keyPath = IDBKeyPath(toNativeArray<String>(exec, keyPathValue));
     173        keyPath = IDBKeyPath(toNativeArray<String>(&exec, keyPathValue));
    210174    else
    211         keyPath = IDBKeyPath(keyPathValue.toString(exec)->value(exec));
     175        keyPath = IDBKeyPath(keyPathValue.toString(&exec)->value(&exec));
    212176    return keyPath;
    213177}
     
    225189}
    226190
    227 static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const JSC::JSValue& value, const String& keyPath)
     191static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const JSValue& value, const String& keyPath)
    228192{
    229193    Vector<String> keyPathElements;
     
    275239}
    276240
    277 bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
    278 {
    279     LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
     241bool injectIDBKeyIntoScriptValue(ExecState& exec, const IDBKeyData& keyData, JSValue value, const IDBKeyPath& keyPath)
     242{
     243    LOG(IndexedDB, "injectIDBKeyIntoScriptValue");
    280244
    281245    ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
     
    289253        return false;
    290254
    291     ExecState* exec = requestState->exec();
    292 
    293     JSValue parent = ensureNthValueOnKeyPath(exec, value.jsValue(), keyPathElements, keyPathElements.size() - 1);
    294     if (parent.isUndefined())
    295         return false;
    296 
    297     if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
    298         return false;
    299 
    300     return true;
    301 }
    302 
    303 bool injectIDBKeyIntoScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData, JSC::JSValue value, const IDBKeyPath& keyPath)
    304 {
    305     LOG(IndexedDB, "injectIDBKeyIntoScriptValue");
    306 
    307     ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
    308 
    309     Vector<String> keyPathElements;
    310     IDBKeyPathParseError error;
    311     IDBParseKeyPath(keyPath.string(), keyPathElements, error);
    312     ASSERT(error == IDBKeyPathParseError::None);
    313 
    314     if (keyPathElements.isEmpty())
    315         return false;
    316 
    317255    JSValue parent = ensureNthValueOnKeyPath(&exec, value, keyPathElements, keyPathElements.size() - 1);
    318256    if (parent.isUndefined())
     
    329267}
    330268
    331 RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
    332 {
    333     LOG(StorageAPI, "createIDBKeyFromScriptValueAndKeyPath");
    334     ASSERT(!keyPath.isNull());
    335 
    336     if (keyPath.type() == IndexedDB::KeyPathType::Array) {
    337         Vector<RefPtr<IDBKey>> result;
    338         const Vector<String>& array = keyPath.array();
    339         for (size_t i = 0; i < array.size(); i++) {
    340             RefPtr<IDBKey> key = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, array[i]);
    341             if (!key)
    342                 return nullptr;
    343             result.append(key);
    344         }
    345         return IDBKey::createArray(result);
    346     }
    347 
    348     ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
    349     return internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath.string());
    350 }
    351 
    352 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
    353 {
    354     ASSERT(!keyPath.isNull());
    355 
    356     if (keyPath.type() == IndexedDB::KeyPathType::Array) {
    357         Vector<RefPtr<IDBKey>> result;
    358         const Vector<String>& array = keyPath.array();
    359         for (size_t i = 0; i < array.size(); i++) {
    360             RefPtr<IDBKey> key = internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, array[i]);
    361             if (!key)
    362                 return nullptr;
    363             result.append(key);
    364         }
    365         return IDBKey::createArray(result);
    366     }
    367 
    368     ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
    369     return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
    370 }
    371 
    372 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSC::JSValue& value, const IDBKeyPath& keyPath)
     269
     270RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSValue& value, const IDBKeyPath& keyPath)
    373271{
    374272    ASSERT(!keyPath.isNull());
     
    391289}
    392290
    393 bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
    394 {
    395     LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
    396 
    397     JSC::ExecState* exec = requestState->exec();
    398     if (!exec)
    399         return false;
    400 
    401     return canInjectIDBKeyIntoScriptValue(*exec, scriptValue, keyPath);
    402 }
    403 
    404 bool canInjectIDBKeyIntoScriptValue(JSC::ExecState& execState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
     291bool canInjectIDBKeyIntoScriptValue(ExecState& execState, const JSValue& scriptValue, const IDBKeyPath& keyPath)
    405292{
    406293    LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
     
    418305}
    419306
    420 Deprecated::ScriptValue deserializeIDBValue(DOMRequestState* requestState, PassRefPtr<SerializedScriptValue> prpValue)
    421 {
    422     ExecState* exec = requestState->exec();
    423     RefPtr<SerializedScriptValue> serializedValue = prpValue;
    424     JSValue result;
    425     if (serializedValue)
    426         result = serializedValue->deserialize(exec, exec->lexicalGlobalObject(), 0);
    427     else
    428         result = jsNull();
    429     return Deprecated::ScriptValue(exec->vm(), result);
    430 }
    431 
    432 static JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData, const Vector<String> blobURLs, const Vector<String> blobFilePaths)
    433 {
    434     if (!valueData.data())
    435         return jsUndefined();
    436 
    437     const Vector<uint8_t>& data = *valueData.data();
     307
     308static Strong<Unknown> deserializeIDBValueToJSValue(ExecState& exec, const IDBValue& value)
     309{
     310    if (!value.data().data())
     311        return { exec.vm(), jsUndefined() };
     312
     313    const Vector<uint8_t>& data = *value.data().data();
    438314    JSValue result;
    439315    if (data.size()) {
     
    441317
    442318        exec.vm().apiLock().lock();
    443         result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, blobURLs, blobFilePaths);
     319        result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, value.blobURLs(), value.blobFilePaths());
    444320        exec.vm().apiLock().unlock();
    445321    } else
    446322        result = jsNull();
    447323
    448     return result;
    449 }
    450 
    451 Deprecated::ScriptValue deserializeIDBValueData(ScriptExecutionContext& context, const ThreadSafeDataBuffer& valueData)
    452 {
    453     DOMRequestState state(&context);
    454     auto* execState = state.exec();
    455 
     324    return { exec.vm(), result };
     325}
     326
     327Strong<Unknown> deserializeIDBValueToJSValue(ScriptExecutionContext& context, const IDBValue& value)
     328{
     329    auto* execState = context.execState();
    456330    if (!execState)
    457331        return { };
    458332
    459     return { execState->vm(), deserializeIDBValueDataToJSValue(*execState, valueData) };
    460 }
    461 
    462 Deprecated::ScriptValue deserializeIDBValue(ScriptExecutionContext& context, const IDBValue& value)
    463 {
    464     DOMRequestState state(&context);
    465     auto* execState = state.exec();
    466 
    467     if (!execState)
    468         return { };
    469 
    470     return { execState->vm(), deserializeIDBValueDataToJSValue(*execState, value.data(), value.blobURLs(), value.blobFilePaths()) };
    471 }
    472 
    473 JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
    474 {
    475     Vector<String> dummyURLs, dummyFilePaths;
    476     return deserializeIDBValueDataToJSValue(exec, valueData, dummyURLs, dummyFilePaths);
    477 }
    478 
    479 Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState* requestState, PassRefPtr<SharedBuffer> prpBuffer, bool keyIsDefined)
    480 {
    481     if (prpBuffer) {
    482         Vector<uint8_t> value;
    483         value.append(prpBuffer->data(), prpBuffer->size());
    484         return deserializeIDBValueBuffer(requestState->exec(), WTFMove(value), keyIsDefined);
    485     }
    486 
    487     return Deprecated::ScriptValue(requestState->exec()->vm(), jsNull());
    488 }
    489 
    490 static JSValue idbValueDataToJSValue(JSC::ExecState& exec, Vector<uint8_t>&& buffer)
    491 {
    492     if (buffer.isEmpty())
    493         return jsNull();
    494 
    495     RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(WTFMove(buffer));
    496     return serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
    497 }
    498 
    499 Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState* exec, Vector<uint8_t>&& buffer, bool keyIsDefined)
    500 {
    501     ASSERT(exec);
    502 
    503     // If the key doesn't exist, then the value must be undefined (as opposed to null).
    504     if (!keyIsDefined) {
    505         // We either shouldn't have a buffer or it should be of size 0.
    506         ASSERT(!buffer.size());
    507         return Deprecated::ScriptValue(exec->vm(), jsUndefined());
    508     }
    509 
    510     JSValue result = idbValueDataToJSValue(*exec, WTFMove(buffer));
    511     return Deprecated::ScriptValue(exec->vm(), result);
    512 }
    513 
    514 JSValue idbValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
    515 {
    516     if (!valueData.data())
    517         return jsUndefined();
    518 
    519     return idbValueDataToJSValue(exec, Vector<uint8_t>(*valueData.data()));
    520 }
    521 
    522 Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key)
    523 {
    524     ExecState* exec = requestState->exec();
     333    return deserializeIDBValueToJSValue(*execState, value);
     334}
     335
     336Strong<Unknown> deserializeIDBValueDataToJSValue(ExecState& exec, const ThreadSafeDataBuffer& valueData)
     337{
     338    return deserializeIDBValueToJSValue(exec, IDBValue(valueData));
     339}
     340
     341RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSValue& scriptValue)
     342{
     343    return createIDBKeyFromValue(&exec, scriptValue);
     344}
     345
     346RefPtr<IDBKey> scriptValueToIDBKey(ScriptExecutionContext& context, const JSValue& scriptValue)
     347{
     348    auto* execState = context.execState();
     349    return execState ? scriptValueToIDBKey(*execState, scriptValue) : nullptr;
     350}
     351
     352Strong<Unknown> idbKeyDataToScriptValue(ScriptExecutionContext& context, const IDBKeyData& keyData)
     353{
     354    RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
     355
     356    ExecState* exec = context.execState();
    525357    if (!exec)
    526358        return { };
    527359
    528     return Deprecated::ScriptValue(exec->vm(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()));
    529 }
    530 
    531 RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* requestState, const JSC::JSValue& scriptValue)
    532 {
    533     ExecState* exec = requestState->exec();
    534     return createIDBKeyFromValue(exec, scriptValue);
    535 }
    536 
    537 RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSC::JSValue& scriptValue)
    538 {
    539     return createIDBKeyFromValue(&exec, scriptValue);
    540 }
    541 
    542 Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext* context, const IDBKeyData& keyData)
    543 {
    544     RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
    545     DOMRequestState requestState(context);
    546     return idbKeyToScriptValue(&requestState, key.get());
     360    return { exec->vm(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()) };
    547361}
    548362
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h

    r199524 r199643  
    11/*
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
     3 * Copyright (C) 2014, 2015, 2016 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3031
    3132#include "Dictionary.h"
    32 #include <bindings/ScriptValue.h>
    3333#include <wtf/Forward.h>
    3434
    3535namespace WebCore {
    3636
    37 class DOMRequestState;
    3837class IDBIndexInfo;
    3938class IDBKey;
     
    4241class IDBValue;
    4342class IndexKey;
    44 class SharedBuffer;
    4543class ThreadSafeDataBuffer;
    4644
    47 IDBKeyPath idbKeyPathFromValue(JSC::ExecState*, JSC::JSValue);
     45IDBKeyPath idbKeyPathFromValue(JSC::ExecState&, JSC::JSValue);
    4846
    49 bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey>, Deprecated::ScriptValue&, const IDBKeyPath&);
     47RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
     48bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
    5049bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
    5150
    52 RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(JSC::ExecState*, const Deprecated::ScriptValue&, const IDBKeyPath&);
    53 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const Deprecated::ScriptValue&, const IDBKeyPath&);
    54 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
     51JSC::Strong<JSC::Unknown> idbKeyDataToScriptValue(ScriptExecutionContext&, const IDBKeyData&);
     52void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
    5553
    56 bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const JSC::JSValue&, const IDBKeyPath&);
    57 bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
     54JSC::Strong<JSC::Unknown> deserializeIDBValueToJSValue(ScriptExecutionContext&, const IDBValue&);
     55JSC::Strong<JSC::Unknown> deserializeIDBValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
    5856
    59 Deprecated::ScriptValue deserializeIDBValue(DOMRequestState*, PassRefPtr<SerializedScriptValue>);
    60 Deprecated::ScriptValue deserializeIDBValueData(ScriptExecutionContext&, const ThreadSafeDataBuffer& valueData);
    61 Deprecated::ScriptValue deserializeIDBValue(ScriptExecutionContext&, const IDBValue&);
    62 Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState*, PassRefPtr<SharedBuffer>, bool keyIsDefined);
    63 WEBCORE_EXPORT Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState*, Vector<uint8_t>&&, bool keyIsDefined);
    64 
    65 JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
    66 
    67 Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
    68 RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState*, const JSC::JSValue&);
     57RefPtr<IDBKey> scriptValueToIDBKey(ScriptExecutionContext&, const JSC::JSValue&);
    6958RefPtr<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
    70 
    71 Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext*, const IDBKeyData&);
    72 
    73 JSC::JSValue idbValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
    74 void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
    75 JSC::JSValue idbKeyDataToJSValue(JSC::ExecState&, const IDBKeyData&);
    7659
    7760}
  • trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp

    r199323 r199643  
    9999        return toJS(exec, globalObject, idbAny->idbTransaction());
    100100    case IDBAny::Type::ScriptValue:
    101         return idbAny->scriptValue().jsValue();
     101        return idbAny->scriptValue();
    102102    case IDBAny::Type::String:
    103103        return jsStringWithCache(exec, idbAny->string());
  • trunk/Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp

    r199323 r199643  
    6767
    6868        if (!keyPathValue.isUndefinedOrNull()) {
    69             keyPath = idbKeyPathFromValue(&state, keyPathValue);
     69            keyPath = idbKeyPathFromValue(state, keyPathValue);
    7070            if (state.hadException())
    7171                return jsUndefined();
  • trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp

    r199323 r199643  
    120120    JSValue keyPathValue = state.argument(1);
    121121    if (!keyPathValue.isUndefinedOrNull())
    122         keyPath = idbKeyPathFromValue(&state, keyPathValue);
     122        keyPath = idbKeyPathFromValue(state, keyPathValue);
    123123    else {
    124124        ExceptionCodeWithMessage ec;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r199323 r199643  
    43504350    }
    43514351
     4352    my $returnType = $signature->extendedAttributes->{"ImplementationReturnType"};
    43524353    if ($type eq "any") {
    43534354        if ($interfaceName eq "Document") {
    43544355            AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional);
     4356        } elsif (defined $returnType and $returnType eq "JSValue") {
     4357            return "$value";
    43554358        } else {
    43564359            return "($value.hasNoValue() ? jsNull() : $value.jsValue())";
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r199587 r199643  
    6868GetterRaisesExceptionWithMessage
    6969Immutable
     70ImplementedAs=*
    7071ImplementationLacksVTable
    7172ImplementationNamespace=*
    72 ImplementedAs=*
     73ImplementationReturnType=*
    7374ImplicitThis
    7475InitializedByEventConstructor
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r199323 r199643  
    488488}
    489489
     490JSC::ExecState* ScriptExecutionContext::execState()
     491{
     492    if (is<Document>(*this)) {
     493        Document& document = downcast<Document>(*this);
     494        return execStateFromPage(mainThreadNormalWorld(), document.page());
     495    }
     496
     497    WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(this);
     498    return execStateFromWorkerGlobalScope(workerGlobalScope);
     499}
     500
    490501} // namespace WebCore
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r199323 r199643  
    189189    void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
    190190
     191    JSC::ExecState* execState();
     192
    191193protected:
    192194    class AddConsoleMessageTask : public Task {
  • trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

    r199642 r199643  
    4545#include "ExceptionCode.h"
    4646#include "Frame.h"
     47#include "IDBBindingUtilities.h"
    4748#include "IDBCursor.h"
    4849#include "IDBCursorWithValue.h"
     
    335336    }
    336337
    337     void handleEvent(ScriptExecutionContext*, Event* event) override
     338    void handleEvent(ScriptExecutionContext* context, Event* event) override
    338339    {
    339340        if (event->type() != eventNames().successEvent) {
     
    382383        }
    383384
     385        JSC::ExecState* state = context ? context->execState() : nullptr;
     386        if (!state)
     387            return;
     388
    384389        RefPtr<DataEntry> dataEntry = DataEntry::create()
    385             .setKey(m_injectedScript.wrapObject(idbCursor->key(), String(), true))
    386             .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(), String(), true))
    387             .setValue(m_injectedScript.wrapObject(idbCursor->value(), String(), true))
     390            .setKey(m_injectedScript.wrapObject(idbCursor->key(*state), String(), true))
     391            .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(*state), String(), true))
     392            .setValue(m_injectedScript.wrapObject(idbCursor->value(*state), String(), true))
    388393            .release();
    389394        m_result->addItem(WTFMove(dataEntry));
Note: See TracChangeset for help on using the changeset viewer.