Clean up IDBBindingUtilities.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Apr 2016 18:49:53 +0000 (18:49 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 17 Apr 2016 18:49:53 +0000 (18:49 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199643 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBAny.cpp
Source/WebCore/Modules/indexeddb/IDBAny.h
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBCursor.h
Source/WebCore/Modules/indexeddb/IDBCursor.idl
Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp
Source/WebCore/Modules/indexeddb/IDBKeyRange.h
Source/WebCore/Modules/indexeddb/IDBKeyRange.idl
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/bindings/js/IDBBindingUtilities.cpp
Source/WebCore/bindings/js/IDBBindingUtilities.h
Source/WebCore/bindings/js/JSIDBAnyCustom.cpp
Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp
Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

index 9377655..7b93fc0 100644 (file)
@@ -1,3 +1,111 @@
+2016-04-17  Brady Eidson  <beidson@apple.com>
+
+        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:
+
 2016-04-17  Darin Adler  <darin@apple.com>
 
         Remove more uses of Deprecated::ScriptXXX
index 8fabd23..a58d254 100644 (file)
@@ -78,7 +78,7 @@ IDBAny::IDBAny(const IDBKeyPath& keyPath)
 {
 }
 
-IDBAny::IDBAny(const Deprecated::ScriptValue& value)
+IDBAny::IDBAny(const JSC::Strong<JSC::Unknown>& value)
     : m_type(IDBAny::Type::ScriptValue)
     , m_scriptValue(value)
 {
@@ -133,9 +133,9 @@ RefPtr<IDBTransaction> IDBAny::idbTransaction()
     return nullptr;
 }
 
-const Deprecated::ScriptValue& IDBAny::scriptValue()
+JSC::JSValue IDBAny::scriptValue()
 {
-    return m_scriptValue;
+    return m_scriptValue.get();
 }
 
 int64_t IDBAny::integer()
index 9f1c795..6e7dc29 100644 (file)
@@ -29,7 +29,8 @@
 
 #include "IDBKeyPath.h"
 #include "ScriptWrappable.h"
-#include <bindings/ScriptValue.h>
+#include <heap/Strong.h>
+#include <runtime/JSCJSValue.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
@@ -70,7 +71,7 @@ public:
         return adoptRef(new IDBAny(keyPath));
     }
 
-    static RefPtr<IDBAny> create(const Deprecated::ScriptValue& value)
+    static RefPtr<IDBAny> create(const JSC::Strong<JSC::Unknown>& value)
     {
         return adoptRef(new IDBAny(value));
     }
@@ -108,7 +109,7 @@ public:
     RefPtr<IDBIndex> idbIndex();
     RefPtr<IDBObjectStore> idbObjectStore();
     RefPtr<IDBTransaction> idbTransaction();
-    const Deprecated::ScriptValue& scriptValue();
+    JSC::JSValue scriptValue();
     int64_t integer();
     const String& string();
     const IDBKeyPath& keyPath();
@@ -120,7 +121,7 @@ private:
     explicit IDBAny(Ref<IDBIndex>&&);
     explicit IDBAny(Ref<IDBCursor>&&);
     explicit IDBAny(const IDBKeyPath&);
-    explicit IDBAny(const Deprecated::ScriptValue&);
+    explicit IDBAny(const JSC::Strong<JSC::Unknown>&);
 
     IDBAny::Type m_type { IDBAny::Type::Undefined };
     RefPtr<IDBDatabase> m_database;
@@ -130,7 +131,7 @@ private:
     RefPtr<IDBCursorWithValue> m_cursorWithValue;
 
     const IDBKeyPath m_idbKeyPath;
-    const Deprecated::ScriptValue m_scriptValue;
+    JSC::Strong<JSC::Unknown> m_scriptValue;
     const String m_string;
     const int64_t m_integer { 0 };
 };
index 5ab0d9b..60ee4a7 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "DOMRequestState.h"
 #include "ExceptionCode.h"
 #include "IDBBindingUtilities.h"
 #include "IDBDatabaseException.h"
@@ -40,6 +39,8 @@
 #include "ScriptExecutionContext.h"
 #include <wtf/NeverDestroyed.h>
 
+using namespace JSC;
+
 namespace WebCore {
 
 const AtomicString& IDBCursor::directionNext()
@@ -157,19 +158,19 @@ const String& IDBCursor::direction() const
     return IDBCursor::directionToString(m_info.cursorDirection());
 }
 
-const Deprecated::ScriptValue& IDBCursor::key() const
+JSValue IDBCursor::key(ExecState&) const
 {
-    return m_deprecatedCurrentKey;
+    return m_currentKey.get();
 }
 
-const Deprecated::ScriptValue& IDBCursor::primaryKey() const
+JSValue IDBCursor::primaryKey(ExecState&) const
 {
-    return m_deprecatedCurrentPrimaryKey;
+    return m_currentPrimaryKey.get();
 }
 
-const Deprecated::ScriptValue& IDBCursor::value() const
+JSValue IDBCursor::value(ExecState&) const
 {
-    return m_deprecatedCurrentValue;
+    return m_currentValue.get();
 }
 
 IDBAny* IDBCursor::source()
@@ -224,7 +225,7 @@ RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::
         }
     }
 
-    auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
+    auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_currentPrimaryKey.get(), ec);
     if (ec.code)
         return nullptr;
 
@@ -280,10 +281,9 @@ void IDBCursor::continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessa
 
 void IDBCursor::continueFunction(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCodeWithMessage& ec)
 {
-    DOMRequestState requestState(&context);
     RefPtr<IDBKey> key;
     if (!keyValue.jsValue().isUndefined())
-        key = scriptValueToIDBKey(&requestState, keyValue);
+        key = scriptValueToIDBKey(context, keyValue);
 
     continueFunction(key.get(), ec);
 }
@@ -380,7 +380,7 @@ RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext& co
         return nullptr;
     }
 
-    auto request = effectiveObjectStore().modernDelete(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec);
+    auto request = effectiveObjectStore().modernDelete(context, m_currentPrimaryKey.get(), ec);
     if (ec.code)
         return nullptr;
 
@@ -400,25 +400,25 @@ void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
         return;
 
     if (!getResult.isDefined()) {
-        m_deprecatedCurrentKey = { };
+        m_currentKey = { };
         m_currentKeyData = { };
-        m_deprecatedCurrentPrimaryKey = { };
+        m_currentPrimaryKey = { };
         m_currentPrimaryKeyData = { };
-        m_deprecatedCurrentValue = { };
+        m_currentValue = { };
 
         m_gotValue = false;
         return;
     }
 
-    m_deprecatedCurrentKey = idbKeyDataToScriptValue(context, getResult.keyData());
+    m_currentKey = idbKeyDataToScriptValue(*context, getResult.keyData());
     m_currentKeyData = getResult.keyData();
-    m_deprecatedCurrentPrimaryKey = idbKeyDataToScriptValue(context, getResult.primaryKeyData());
+    m_currentPrimaryKey = idbKeyDataToScriptValue(*context, getResult.primaryKeyData());
     m_currentPrimaryKeyData = getResult.primaryKeyData();
 
     if (isKeyCursor())
-        m_deprecatedCurrentValue = { };
+        m_currentValue = { };
     else
-        m_deprecatedCurrentValue = deserializeIDBValue(*context, getResult.value());
+        m_currentValue = deserializeIDBValueToJSValue(*context, getResult.value());
 
     m_gotValue = true;
 }
index 84f8b97..cbf7785 100644 (file)
@@ -31,6 +31,7 @@
 #include "ExceptionCode.h"
 #include "IDBAny.h"
 #include "IDBCursorInfo.h"
+#include <runtime/JSCJSValue.h>
 
 namespace WebCore {
 
@@ -56,9 +57,9 @@ public:
 
     // Implement the IDL
     const String& direction() const;
-    const Deprecated::ScriptValue& key() const;
-    const Deprecated::ScriptValue& primaryKey() const;
-    const Deprecated::ScriptValue& value() const;
+    JSC::JSValue key(JSC::ExecState&) const;
+    JSC::JSValue primaryKey(JSC::ExecState&) const;
+    JSC::JSValue value(JSC::ExecState&) const;
     IDBAny* source();
 
     RefPtr<WebCore::IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCodeWithMessage&);
@@ -111,11 +112,9 @@ private:
     IDBKeyData m_currentKeyData;
     IDBKeyData m_currentPrimaryKeyData;
 
-    // FIXME: When ditching Legacy IDB and combining this implementation with the abstract IDBCursor,
-    // these Deprecated::ScriptValue members should be JSValues instead.
-    Deprecated::ScriptValue m_deprecatedCurrentKey;
-    Deprecated::ScriptValue m_deprecatedCurrentPrimaryKey;
-    Deprecated::ScriptValue m_deprecatedCurrentValue;
+    JSC::Strong<JSC::Unknown> m_currentKey;
+    JSC::Strong<JSC::Unknown> m_currentPrimaryKey;
+    JSC::Strong<JSC::Unknown> m_currentValue;
 };
 
 } // namespace WebCore
index 046f905..177ad4d 100644 (file)
@@ -32,8 +32,8 @@
 ] interface IDBCursor {
     readonly attribute IDBAny source;
     readonly attribute DOMString direction;
-    readonly attribute any key;
-    readonly attribute any primaryKey;
+    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any key;
+    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any primaryKey;
 
     [CallWith=ScriptState, RaisesExceptionWithMessage] IDBRequest update(any value);
     [RaisesExceptionWithMessage] void advance([EnforceRange] unsigned long count);
index 852e147..c6c37cd 100644 (file)
@@ -30,5 +30,5 @@
     SkipVTableValidation,
     JSCustomMarkFunction,
 ] interface IDBCursorWithValue : IDBCursor {
-    readonly attribute any value;
+    [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any value;
 };
index 368ec0a..742fc95 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "DOMRequestState.h"
 #include "Document.h"
 #include "ExceptionCode.h"
 #include "IDBBindingUtilities.h"
@@ -149,9 +148,8 @@ RefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext& cont
 
 short IDBFactory::cmp(ScriptExecutionContext& context, const Deprecated::ScriptValue& firstValue, const Deprecated::ScriptValue& secondValue, ExceptionCodeWithMessage& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue);
-    RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue);
+    RefPtr<IDBKey> first = scriptValueToIDBKey(context, firstValue);
+    RefPtr<IDBKey> second = scriptValueToIDBKey(context, secondValue);
 
     ASSERT(first);
     ASSERT(second);
index c647317..ed8da98 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "DOMRequestState.h"
 #include "IDBAny.h"
 #include "IDBBindingUtilities.h"
 #include "IDBCursor.h"
@@ -160,8 +159,7 @@ RefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext& context, const Deprec
 {
     LOG(IndexedDB, "IDBIndex::count");
 
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key.");
@@ -242,8 +240,7 @@ RefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext& context, const Deprecat
 {
     LOG(IndexedDB, "IDBIndex::get");
 
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key.");
@@ -287,8 +284,7 @@ RefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext& context, const Depre
 {
     LOG(IndexedDB, "IDBIndex::getKey");
 
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key.");
index 9e1945d..a0d195b 100644 (file)
 #include "config.h"
 #include "IDBKeyRange.h"
 
-#include "DOMRequestState.h"
 #include "IDBBindingUtilities.h"
 #include "IDBDatabaseException.h"
 #include "IDBKey.h"
+#include "IDBKeyData.h"
 
 #if ENABLE(INDEXED_DATABASE)
 
+using namespace JSC;
+
 namespace WebCore {
 
 Ref<IDBKeyRange> IDBKeyRange::create(RefPtr<IDBKey>&& key)
@@ -49,16 +51,14 @@ IDBKeyRange::IDBKeyRange(RefPtr<IDBKey>&& lower, RefPtr<IDBKey>&& upper, LowerBo
 {
 }
 
-Deprecated::ScriptValue IDBKeyRange::lowerValue(ScriptExecutionContext& context) const
+JSValue IDBKeyRange::lowerValue(ScriptExecutionContext& context) const
 {
-    DOMRequestState requestState(&context);
-    return idbKeyToScriptValue(&requestState, m_lower);
+    return idbKeyDataToScriptValue(context, IDBKeyData(m_lower.get())).get();
 }
 
-Deprecated::ScriptValue IDBKeyRange::upperValue(ScriptExecutionContext& context) const
+JSValue IDBKeyRange::upperValue(ScriptExecutionContext& context) const
 {
-    DOMRequestState requestState(&context);
-    return idbKeyToScriptValue(&requestState, m_upper);
+    return idbKeyDataToScriptValue(context, IDBKeyData(m_upper.get())).get();
 }
 
 RefPtr<IDBKeyRange> IDBKeyRange::only(RefPtr<IDBKey>&& key, ExceptionCode& ec)
@@ -73,8 +73,7 @@ RefPtr<IDBKeyRange> IDBKeyRange::only(RefPtr<IDBKey>&& key, ExceptionCode& ec)
 
 RefPtr<IDBKeyRange> IDBKeyRange::only(ScriptExecutionContext& context, const Deprecated::ScriptValue& keyValue, ExceptionCode& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue);
+    RefPtr<IDBKey> key = scriptValueToIDBKey(context, keyValue);
     if (!key || !key->isValid()) {
         ec = IDBDatabaseException::DataError;
         return nullptr;
@@ -85,8 +84,7 @@ RefPtr<IDBKeyRange> IDBKeyRange::only(ScriptExecutionContext& context, const Dep
 
 RefPtr<IDBKeyRange> IDBKeyRange::lowerBound(ScriptExecutionContext& context, const Deprecated::ScriptValue& boundValue, bool open, ExceptionCode& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue);
+    RefPtr<IDBKey> bound = scriptValueToIDBKey(context, boundValue);
     if (!bound || !bound->isValid()) {
         ec = IDBDatabaseException::DataError;
         return nullptr;
@@ -97,8 +95,7 @@ RefPtr<IDBKeyRange> IDBKeyRange::lowerBound(ScriptExecutionContext& context, con
 
 RefPtr<IDBKeyRange> IDBKeyRange::upperBound(ScriptExecutionContext& context, const Deprecated::ScriptValue& boundValue, bool open, ExceptionCode& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> bound = scriptValueToIDBKey(&requestState, boundValue);
+    RefPtr<IDBKey> bound = scriptValueToIDBKey(context, boundValue);
     if (!bound || !bound->isValid()) {
         ec = IDBDatabaseException::DataError;
         return nullptr;
@@ -109,9 +106,8 @@ RefPtr<IDBKeyRange> IDBKeyRange::upperBound(ScriptExecutionContext& context, con
 
 RefPtr<IDBKeyRange> IDBKeyRange::bound(ScriptExecutionContext& context, const Deprecated::ScriptValue& lowerValue, const Deprecated::ScriptValue& upperValue, bool lowerOpen, bool upperOpen, ExceptionCode& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> lower = scriptValueToIDBKey(&requestState, lowerValue);
-    RefPtr<IDBKey> upper = scriptValueToIDBKey(&requestState, upperValue);
+    RefPtr<IDBKey> lower = scriptValueToIDBKey(context, lowerValue);
+    RefPtr<IDBKey> upper = scriptValueToIDBKey(context, upperValue);
 
     if (!lower || !lower->isValid() || !upper || !upper->isValid()) {
         ec = IDBDatabaseException::DataError;
index 1bda7f7..430ffc2 100644 (file)
@@ -58,8 +58,8 @@ public:
     IDBKey* lower() const { return m_lower.get(); }
     IDBKey* upper() const { return m_upper.get(); }
 
-    Deprecated::ScriptValue lowerValue(ScriptExecutionContext&) const;
-    Deprecated::ScriptValue upperValue(ScriptExecutionContext&) const;
+    JSC::JSValue lowerValue(ScriptExecutionContext&) const;
+    JSC::JSValue upperValue(ScriptExecutionContext&) const;
     bool lowerOpen() const { return m_lowerType == LowerBoundOpen; }
     bool upperOpen() const { return m_upperType == UpperBoundOpen; }
 
index f0600ff..104220d 100644 (file)
@@ -28,8 +28,8 @@
     ImplementationLacksVTable,
     EnabledAtRuntime=IndexedDB,
 ] interface IDBKeyRange {
-    [ImplementedAs=lowerValue,CallWith=ScriptExecutionContext] readonly attribute any lower;
-    [ImplementedAs=upperValue,CallWith=ScriptExecutionContext] readonly attribute any upper;
+    [ImplementedAs=lowerValue, CallWith=ScriptExecutionContext, ImplementationReturnType=JSValue] readonly attribute any lower;
+    [ImplementedAs=upperValue, CallWith=ScriptExecutionContext, ImplementationReturnType=JSValue] readonly attribute any upper;
     readonly attribute boolean lowerOpen;
     readonly attribute boolean upperOpen;
 
index 8ed5b09..71f017f 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
-#include "DOMRequestState.h"
 #include "DOMStringList.h"
 #include "IDBBindingUtilities.h"
 #include "IDBCursor.h"
@@ -182,8 +181,7 @@ RefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, const De
         return nullptr;
     }
 
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The parameter is not a valid key.");
@@ -399,8 +397,7 @@ RefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& contex
 
 RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext& context, JSC::JSValue key, ExceptionCodeWithMessage& ec)
 {
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.");
@@ -594,8 +591,7 @@ RefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext& context, const
 {
     LOG(IndexedDB, "IDBObjectStore::count");
 
-    DOMRequestState requestState(&context);
-    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
+    RefPtr<IDBKey> idbKey = scriptValueToIDBKey(context, key);
     if (!idbKey || idbKey->type() == KeyType::Invalid) {
         ec.code = IDBDatabaseException::DataError;
         ec.message = ASCIILiteral("Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.");
index 63623a6..e764405 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(INDEXED_DATABASE)
 
 #include "DOMError.h"
-#include "DOMRequestState.h"
 #include "Event.h"
 #include "EventQueue.h"
 #include "IDBBindingUtilities.h"
@@ -326,19 +325,19 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 
 void IDBRequest::setResult(const IDBKeyData* keyData)
 {
-    if (!keyData) {
+    auto* context = scriptExecutionContext();
+    if (!context || !keyData) {
         m_result = nullptr;
         return;
     }
 
-    Deprecated::ScriptValue value = idbKeyDataToScriptValue(scriptExecutionContext(), *keyData);
-    m_result = IDBAny::create(WTFMove(value));
+    m_result = IDBAny::create(idbKeyDataToScriptValue(*context, *keyData));
 }
 
 void IDBRequest::setResult(uint64_t number)
 {
     ASSERT(scriptExecutionContext());
-    m_result = IDBAny::create(Deprecated::ScriptValue(scriptExecutionContext()->vm(), JSC::JSValue(number)));
+    m_result = IDBAny::create(JSC::Strong<JSC::Unknown>(scriptExecutionContext()->vm(), JSC::JSValue(number)));
 }
 
 void IDBRequest::setResultToStructuredClone(const IDBValue& value)
@@ -349,8 +348,7 @@ void IDBRequest::setResultToStructuredClone(const IDBValue& value)
     if (!context)
         return;
 
-    Deprecated::ScriptValue scriptValue = deserializeIDBValue(*context, value);
-    m_result = IDBAny::create(WTFMove(scriptValue));
+    m_result = IDBAny::create(deserializeIDBValueToJSValue(*context, value));
 }
 
 void IDBRequest::setResultToUndefined()
index 8b8cd75..df64f2d 100644 (file)
@@ -301,7 +301,7 @@ IDBError MemoryObjectStore::updateIndexesForPutRecord(const IDBKeyData& key, con
 {
     JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
 
-    auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
+    auto jsValue = deserializeIDBValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
     if (jsValue.isUndefinedOrNull())
         return { };
 
@@ -310,7 +310,7 @@ IDBError MemoryObjectStore::updateIndexesForPutRecord(const IDBKeyData& key, con
 
     for (auto& index : m_indexesByName.values()) {
         IndexKey indexKey;
-        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey);
+        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue.get(), indexKey);
 
         if (indexKey.isNull())
             continue;
@@ -339,12 +339,12 @@ IDBError MemoryObjectStore::populateIndexWithExistingRecords(MemoryIndex& index)
     JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
 
     for (auto iterator : *m_keyValueStore) {
-        auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), iterator.value);
+        auto jsValue = deserializeIDBValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), iterator.value);
         if (jsValue.isUndefinedOrNull())
             return { };
 
         IndexKey indexKey;
-        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey);
+        generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue.get(), indexKey);
 
         if (indexKey.isNull())
             continue;
index 282a213..fdd1ef5 100644 (file)
@@ -1468,7 +1468,7 @@ IDBError SQLiteIDBBackingStore::updateOneIndexForAddRecord(const IDBIndexInfo& i
         return { };
 
     IndexKey indexKey;
-    generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue, indexKey);
+    generateIndexKeyForValue(*m_globalObject->globalExec(), info, jsValue.get(), indexKey);
 
     if (indexKey.isNull())
         return { };
@@ -1488,7 +1488,7 @@ IDBError SQLiteIDBBackingStore::updateAllIndexesForAddRecord(const IDBObjectStor
     bool anyRecordsSucceeded = false;
     for (auto& index : info.indexMap().values()) {
         IndexKey indexKey;
-        generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue, indexKey);
+        generateIndexKeyForValue(*m_globalObject->globalExec(), index, jsValue.get(), indexKey);
 
         if (indexKey.isNull())
             continue;
index 623227a..beb8644 100644 (file)
@@ -765,18 +765,18 @@ void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBRe
     if (usedKeyIsGenerated && !objectStoreInfo->keyPath().isNull()) {
         JSLockHolder locker(databaseThreadVM());
 
-        JSValue value = deserializeIDBValueDataToJSValue(databaseThreadExecState(), originalRecordValue.data());
-        if (value.isUndefined()) {
+        auto value = deserializeIDBValueDataToJSValue(databaseThreadExecState(), originalRecordValue.data());
+        if (value.get().isUndefined()) {
             m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to deserialize record value for record key injection")), usedKey));
             return;
         }
 
-        if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value, objectStoreInfo->keyPath())) {
+        if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value.get(), objectStoreInfo->keyPath())) {
             m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to inject record key into record value")), usedKey));
             return;
         }
 
-        auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
+        auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value.get(), nullptr, nullptr);
         if (databaseThreadExecState().hadException()) {
             m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
             return;
index bcffd82..0fc13bb 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2012 Michael Pruett <michael@68k.org>
+ * Copyright (C) 2014, 2015, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,7 +30,6 @@
 #if ENABLE(INDEXED_DATABASE)
 #include "IDBBindingUtilities.h"
 
-#include "DOMRequestState.h"
 #include "IDBIndexInfo.h"
 #include "IDBKey.h"
 #include "IDBKeyData.h"
@@ -38,6 +38,7 @@
 #include "IndexKey.h"
 #include "JSDOMBinding.h"
 #include "Logging.h"
+#include "ScriptExecutionContext.h"
 #include "SharedBuffer.h"
 #include "ThreadSafeDataBuffer.h"
 
@@ -78,43 +79,6 @@ static bool set(ExecState* exec, JSValue& object, const String& keyPathElement,
     return true;
 }
 
-JSValue idbKeyDataToJSValue(JSC::ExecState& exec, const IDBKeyData& keyData)
-{
-    if (keyData.isNull())
-        return jsUndefined();
-
-    Locker<JSLock> locker(exec.vm().apiLock());
-
-    switch (keyData.type()) {
-    case KeyType::Array:
-        {
-            const Vector<IDBKeyData>& inArray = keyData.array();
-            size_t size = inArray.size();
-            JSArray* outArray = constructEmptyArray(&exec, 0, exec.lexicalGlobalObject(), size);
-            for (size_t i = 0; i < size; ++i) {
-                auto& arrayKey = inArray.at(i);
-                outArray->putDirectIndex(&exec, i, idbKeyDataToJSValue(exec, arrayKey));
-            }
-            return JSValue(outArray);
-        }
-    case KeyType::String:
-        return jsStringWithCache(&exec, keyData.string());
-    case KeyType::Date:
-        return jsDateOrNull(&exec, keyData.date());
-    case KeyType::Number:
-        return jsNumber(keyData.number());
-    case KeyType::Min:
-    case KeyType::Max:
-    case KeyType::Invalid:
-        ASSERT_NOT_REACHED();
-        return jsUndefined();
-    }
-
-    ASSERT_NOT_REACHED();
-    return jsUndefined();
-
-}
-
 static JSValue idbKeyToJSValue(ExecState* exec, JSGlobalObject* globalObject, IDBKey* key)
 {
     if (!key || !exec) {
@@ -202,13 +166,13 @@ static RefPtr<IDBKey> createIDBKeyFromValue(ExecState* exec, JSValue value)
     return IDBKey::createInvalid();
 }
 
-IDBKeyPath idbKeyPathFromValue(ExecState* exec, JSValue keyPathValue)
+IDBKeyPath idbKeyPathFromValue(ExecState& exec, JSValue keyPathValue)
 {
     IDBKeyPath keyPath;
     if (isJSArray(keyPathValue))
-        keyPath = IDBKeyPath(toNativeArray<String>(exec, keyPathValue));
+        keyPath = IDBKeyPath(toNativeArray<String>(&exec, keyPathValue));
     else
-        keyPath = IDBKeyPath(keyPathValue.toString(exec)->value(exec));
+        keyPath = IDBKeyPath(keyPathValue.toString(&exec)->value(&exec));
     return keyPath;
 }
 
@@ -224,7 +188,7 @@ static JSValue getNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Ve
     return currentValue;
 }
 
-static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const JSC::JSValue& value, const String& keyPath)
+static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const JSValue& value, const String& keyPath)
 {
     Vector<String> keyPathElements;
     IDBKeyPathParseError error;
@@ -274,33 +238,7 @@ static bool canInjectNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const
     return true;
 }
 
-bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
-{
-    LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
-
-    ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
-
-    Vector<String> keyPathElements;
-    IDBKeyPathParseError error;
-    IDBParseKeyPath(keyPath.string(), keyPathElements, error);
-    ASSERT(error == IDBKeyPathParseError::None);
-
-    if (keyPathElements.isEmpty())
-        return false;
-
-    ExecState* exec = requestState->exec();
-
-    JSValue parent = ensureNthValueOnKeyPath(exec, value.jsValue(), keyPathElements, keyPathElements.size() - 1);
-    if (parent.isUndefined())
-        return false;
-
-    if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
-        return false;
-
-    return true;
-}
-
-bool injectIDBKeyIntoScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData, JSC::JSValue value, const IDBKeyPath& keyPath)
+bool injectIDBKeyIntoScriptValue(ExecState& exec, const IDBKeyData& keyData, JSValue value, const IDBKeyPath& keyPath)
 {
     LOG(IndexedDB, "injectIDBKeyIntoScriptValue");
 
@@ -328,48 +266,8 @@ bool injectIDBKeyIntoScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData
     return true;
 }
 
-RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
-{
-    LOG(StorageAPI, "createIDBKeyFromScriptValueAndKeyPath");
-    ASSERT(!keyPath.isNull());
 
-    if (keyPath.type() == IndexedDB::KeyPathType::Array) {
-        Vector<RefPtr<IDBKey>> result;
-        const Vector<String>& array = keyPath.array();
-        for (size_t i = 0; i < array.size(); i++) {
-            RefPtr<IDBKey> key = internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, array[i]);
-            if (!key)
-                return nullptr;
-            result.append(key);
-        }
-        return IDBKey::createArray(result);
-    }
-
-    ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
-    return internalCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath.string());
-}
-
-RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
-{
-    ASSERT(!keyPath.isNull());
-
-    if (keyPath.type() == IndexedDB::KeyPathType::Array) {
-        Vector<RefPtr<IDBKey>> result;
-        const Vector<String>& array = keyPath.array();
-        for (size_t i = 0; i < array.size(); i++) {
-            RefPtr<IDBKey> key = internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, array[i]);
-            if (!key)
-                return nullptr;
-            result.append(key);
-        }
-        return IDBKey::createArray(result);
-    }
-
-    ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
-    return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
-}
-
-RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSC::JSValue& value, const IDBKeyPath& keyPath)
+RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSValue& value, const IDBKeyPath& keyPath)
 {
     ASSERT(!keyPath.isNull());
 
@@ -390,18 +288,7 @@ RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const
     return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
 }
 
-bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
-{
-    LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
-
-    JSC::ExecState* exec = requestState->exec();
-    if (!exec)
-        return false;
-
-    return canInjectIDBKeyIntoScriptValue(*exec, scriptValue, keyPath);
-}
-
-bool canInjectIDBKeyIntoScriptValue(JSC::ExecState& execState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
+bool canInjectIDBKeyIntoScriptValue(ExecState& execState, const JSValue& scriptValue, const IDBKeyPath& keyPath)
 {
     LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
 
@@ -417,133 +304,60 @@ bool canInjectIDBKeyIntoScriptValue(JSC::ExecState& execState, const JSC::JSValu
     return canInjectNthValueOnKeyPath(&execState, scriptValue, keyPathElements, keyPathElements.size() - 1);
 }
 
-Deprecated::ScriptValue deserializeIDBValue(DOMRequestState* requestState, PassRefPtr<SerializedScriptValue> prpValue)
-{
-    ExecState* exec = requestState->exec();
-    RefPtr<SerializedScriptValue> serializedValue = prpValue;
-    JSValue result;
-    if (serializedValue)
-        result = serializedValue->deserialize(exec, exec->lexicalGlobalObject(), 0);
-    else
-        result = jsNull();
-    return Deprecated::ScriptValue(exec->vm(), result);
-}
 
-static JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData, const Vector<String> blobURLs, const Vector<String> blobFilePaths)
+static Strong<Unknown> deserializeIDBValueToJSValue(ExecState& exec, const IDBValue& value)
 {
-    if (!valueData.data())
-        return jsUndefined();
+    if (!value.data().data())
+        return { exec.vm(), jsUndefined() };
 
-    const Vector<uint8_t>& data = *valueData.data();
+    const Vector<uint8_t>& data = *value.data().data();
     JSValue result;
     if (data.size()) {
         RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(Vector<uint8_t>(data));
 
         exec.vm().apiLock().lock();
-        result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, blobURLs, blobFilePaths);
+        result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing, value.blobURLs(), value.blobFilePaths());
         exec.vm().apiLock().unlock();
     } else
         result = jsNull();
 
-    return result;
+    return { exec.vm(), result };
 }
 
-Deprecated::ScriptValue deserializeIDBValueData(ScriptExecutionContext& context, const ThreadSafeDataBuffer& valueData)
+Strong<Unknown> deserializeIDBValueToJSValue(ScriptExecutionContext& context, const IDBValue& value)
 {
-    DOMRequestState state(&context);
-    auto* execState = state.exec();
-
+    auto* execState = context.execState();
     if (!execState)
         return { };
 
-    return { execState->vm(), deserializeIDBValueDataToJSValue(*execState, valueData) };
+    return deserializeIDBValueToJSValue(*execState, value);
 }
 
-Deprecated::ScriptValue deserializeIDBValue(ScriptExecutionContext& context, const IDBValue& value)
+Strong<Unknown> deserializeIDBValueDataToJSValue(ExecState& exec, const ThreadSafeDataBuffer& valueData)
 {
-    DOMRequestState state(&context);
-    auto* execState = state.exec();
-
-    if (!execState)
-        return { };
-
-    return { execState->vm(), deserializeIDBValueDataToJSValue(*execState, value.data(), value.blobURLs(), value.blobFilePaths()) };
-}
-
-JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
-{
-    Vector<String> dummyURLs, dummyFilePaths;
-    return deserializeIDBValueDataToJSValue(exec, valueData, dummyURLs, dummyFilePaths);
+    return deserializeIDBValueToJSValue(exec, IDBValue(valueData));
 }
 
-Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState* requestState, PassRefPtr<SharedBuffer> prpBuffer, bool keyIsDefined)
+RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSValue& scriptValue)
 {
-    if (prpBuffer) {
-        Vector<uint8_t> value;
-        value.append(prpBuffer->data(), prpBuffer->size());
-        return deserializeIDBValueBuffer(requestState->exec(), WTFMove(value), keyIsDefined);
-    }
-
-    return Deprecated::ScriptValue(requestState->exec()->vm(), jsNull());
-}
-
-static JSValue idbValueDataToJSValue(JSC::ExecState& exec, Vector<uint8_t>&& buffer)
-{
-    if (buffer.isEmpty())
-        return jsNull();
-
-    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(WTFMove(buffer));
-    return serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
+    return createIDBKeyFromValue(&exec, scriptValue);
 }
 
-Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState* exec, Vector<uint8_t>&& buffer, bool keyIsDefined)
+RefPtr<IDBKey> scriptValueToIDBKey(ScriptExecutionContext& context, const JSValue& scriptValue)
 {
-    ASSERT(exec);
-
-    // If the key doesn't exist, then the value must be undefined (as opposed to null).
-    if (!keyIsDefined) {
-        // We either shouldn't have a buffer or it should be of size 0.
-        ASSERT(!buffer.size());
-        return Deprecated::ScriptValue(exec->vm(), jsUndefined());
-    }
-
-    JSValue result = idbValueDataToJSValue(*exec, WTFMove(buffer));
-    return Deprecated::ScriptValue(exec->vm(), result);
+    auto* execState = context.execState();
+    return execState ? scriptValueToIDBKey(*execState, scriptValue) : nullptr;
 }
 
-JSValue idbValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
+Strong<Unknown> idbKeyDataToScriptValue(ScriptExecutionContext& context, const IDBKeyData& keyData)
 {
-    if (!valueData.data())
-        return jsUndefined();
-
-    return idbValueDataToJSValue(exec, Vector<uint8_t>(*valueData.data()));
-}
+    RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
 
-Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key)
-{
-    ExecState* exec = requestState->exec();
+    ExecState* exec = context.execState();
     if (!exec)
         return { };
 
-    return Deprecated::ScriptValue(exec->vm(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()));
-}
-
-RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState* requestState, const JSC::JSValue& scriptValue)
-{
-    ExecState* exec = requestState->exec();
-    return createIDBKeyFromValue(exec, scriptValue);
-}
-
-RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSC::JSValue& scriptValue)
-{
-    return createIDBKeyFromValue(&exec, scriptValue);
-}
-
-Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext* context, const IDBKeyData& keyData)
-{
-    RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
-    DOMRequestState requestState(context);
-    return idbKeyToScriptValue(&requestState, key.get());
+    return { exec->vm(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()) };
 }
 
 static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info)
index 1150bcd..8ced22d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2014, 2015, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #if ENABLE(INDEXED_DATABASE)
 
 #include "Dictionary.h"
-#include <bindings/ScriptValue.h>
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
-class DOMRequestState;
 class IDBIndexInfo;
 class IDBKey;
 class IDBKeyData;
 class IDBKeyPath;
 class IDBValue;
 class IndexKey;
-class SharedBuffer;
 class ThreadSafeDataBuffer;
 
-IDBKeyPath idbKeyPathFromValue(JSC::ExecState*, JSC::JSValue);
+IDBKeyPath idbKeyPathFromValue(JSC::ExecState&, JSC::JSValue);
 
-bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey>, Deprecated::ScriptValue&, const IDBKeyPath&);
-bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
-
-RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(JSC::ExecState*, const Deprecated::ScriptValue&, const IDBKeyPath&);
-RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const Deprecated::ScriptValue&, const IDBKeyPath&);
 RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
-
-bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const JSC::JSValue&, const IDBKeyPath&);
 bool canInjectIDBKeyIntoScriptValue(JSC::ExecState&, const JSC::JSValue&, const IDBKeyPath&);
+bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
 
-Deprecated::ScriptValue deserializeIDBValue(DOMRequestState*, PassRefPtr<SerializedScriptValue>);
-Deprecated::ScriptValue deserializeIDBValueData(ScriptExecutionContext&, const ThreadSafeDataBuffer& valueData);
-Deprecated::ScriptValue deserializeIDBValue(ScriptExecutionContext&, const IDBValue&);
-Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState*, PassRefPtr<SharedBuffer>, bool keyIsDefined);
-WEBCORE_EXPORT Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState*, Vector<uint8_t>&&, bool keyIsDefined);
+JSC::Strong<JSC::Unknown> idbKeyDataToScriptValue(ScriptExecutionContext&, const IDBKeyData&);
+void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
 
-JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
+JSC::Strong<JSC::Unknown> deserializeIDBValueToJSValue(ScriptExecutionContext&, const IDBValue&);
+JSC::Strong<JSC::Unknown> deserializeIDBValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
 
-Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
-RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState*, const JSC::JSValue&);
+RefPtr<IDBKey> scriptValueToIDBKey(ScriptExecutionContext&, const JSC::JSValue&);
 RefPtr<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
 
-Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext*, const IDBKeyData&);
-
-JSC::JSValue idbValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
-void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
-JSC::JSValue idbKeyDataToJSValue(JSC::ExecState&, const IDBKeyData&);
-
 }
 
 #endif // ENABLE(INDEXED_DATABASE)
index 7d6f3d9..b7fa9ef 100644 (file)
@@ -98,7 +98,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, IDBAny* idbAny)
     case IDBAny::Type::IDBTransaction:
         return toJS(exec, globalObject, idbAny->idbTransaction());
     case IDBAny::Type::ScriptValue:
-        return idbAny->scriptValue().jsValue();
+        return idbAny->scriptValue();
     case IDBAny::Type::String:
         return jsStringWithCache(exec, idbAny->string());
     case IDBAny::Type::Integer:
index d7f581a..4adefe0 100644 (file)
@@ -66,7 +66,7 @@ JSValue JSIDBDatabase::createObjectStore(ExecState& state)
             return jsUndefined();
 
         if (!keyPathValue.isUndefinedOrNull()) {
-            keyPath = idbKeyPathFromValue(&state, keyPathValue);
+            keyPath = idbKeyPathFromValue(state, keyPathValue);
             if (state.hadException())
                 return jsUndefined();
         }
index 744d9a3..41d7c8c 100644 (file)
@@ -119,7 +119,7 @@ JSValue JSIDBObjectStore::createIndex(ExecState& state)
     IDBKeyPath keyPath;
     JSValue keyPathValue = state.argument(1);
     if (!keyPathValue.isUndefinedOrNull())
-        keyPath = idbKeyPathFromValue(&state, keyPathValue);
+        keyPath = idbKeyPathFromValue(state, keyPathValue);
     else {
         ExceptionCodeWithMessage ec;
         ec.code = IDBDatabaseException::SyntaxError;
index 11d5b55..870efc5 100644 (file)
@@ -4349,9 +4349,12 @@ sub NativeToJSValue
         return "jsArray(state, $thisValue->globalObject(), $value)";
     }
 
+    my $returnType = $signature->extendedAttributes->{"ImplementationReturnType"};
     if ($type eq "any") {
         if ($interfaceName eq "Document") {
             AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional);
+        } elsif (defined $returnType and $returnType eq "JSValue") {
+            return "$value";
         } else {
             return "($value.hasNoValue() ? jsNull() : $value.jsValue())";
         }
index afad90d..b82708a 100644 (file)
@@ -67,9 +67,10 @@ GenerateIsReachable=|Impl|ImplWebGLRenderingContext|ImplDocument|ImplElementRoot
 GetterRaisesException
 GetterRaisesExceptionWithMessage
 Immutable
+ImplementedAs=*
 ImplementationLacksVTable
 ImplementationNamespace=*
-ImplementedAs=*
+ImplementationReturnType=*
 ImplicitThis
 InitializedByEventConstructor
 InterfaceName=*
index 7ba26d9..afaf2c3 100644 (file)
@@ -487,4 +487,15 @@ bool ScriptExecutionContext::hasPendingActivity() const
     return false;
 }
 
+JSC::ExecState* ScriptExecutionContext::execState()
+{
+    if (is<Document>(*this)) {
+        Document& document = downcast<Document>(*this);
+        return execStateFromPage(mainThreadNormalWorld(), document.page());
+    }
+
+    WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(this);
+    return execStateFromWorkerGlobalScope(workerGlobalScope);
+}
+
 } // namespace WebCore
index a664eb9..10515c5 100644 (file)
@@ -188,6 +188,8 @@ public:
     int timerNestingLevel() const { return m_timerNestingLevel; }
     void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
 
+    JSC::ExecState* execState();
+
 protected:
     class AddConsoleMessageTask : public Task {
     public:
index 759ae42..95e2a7d 100644 (file)
@@ -44,6 +44,7 @@
 #include "EventTarget.h"
 #include "ExceptionCode.h"
 #include "Frame.h"
+#include "IDBBindingUtilities.h"
 #include "IDBCursor.h"
 #include "IDBCursorWithValue.h"
 #include "IDBDatabase.h"
@@ -334,7 +335,7 @@ public:
         return this == &other;
     }
 
-    void handleEvent(ScriptExecutionContext*, Event* event) override
+    void handleEvent(ScriptExecutionContext* context, Event* event) override
     {
         if (event->type() != eventNames().successEvent) {
             m_requestCallback->sendFailure("Unexpected event type.");
@@ -381,10 +382,14 @@ public:
             return;
         }
 
+        JSC::ExecState* state = context ? context->execState() : nullptr;
+        if (!state)
+            return;
+
         RefPtr<DataEntry> dataEntry = DataEntry::create()
-            .setKey(m_injectedScript.wrapObject(idbCursor->key(), String(), true))
-            .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(), String(), true))
-            .setValue(m_injectedScript.wrapObject(idbCursor->value(), String(), true))
+            .setKey(m_injectedScript.wrapObject(idbCursor->key(*state), String(), true))
+            .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(*state), String(), true))
+            .setValue(m_injectedScript.wrapObject(idbCursor->value(*state), String(), true))
             .release();
         m_result->addItem(WTFMove(dataEntry));