Diff
Modified: trunk/Source/WebCore/ChangeLog (199642 => 199643)
--- trunk/Source/WebCore/ChangeLog 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/ChangeLog 2016-04-17 18:49:53 UTC (rev 199643)
@@ -1,3 +1,111 @@
+2016-04-17 Brady Eidson <[email protected]>
+
+ 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 <[email protected]>
Remove more uses of Deprecated::ScriptXXX
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -78,7 +78,7 @@
{
}
-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 @@
return nullptr;
}
-const Deprecated::ScriptValue& IDBAny::scriptValue()
+JSC::JSValue IDBAny::scriptValue()
{
- return m_scriptValue;
+ return m_scriptValue.get();
}
int64_t IDBAny::integer()
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBAny.h (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBAny.h 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBAny.h 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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 @@
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 @@
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 @@
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 @@
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 };
};
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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 @@
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 @@
}
}
- 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& 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 @@
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 @@
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;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2016-04-17 18:49:53 UTC (rev 199643)
@@ -31,6 +31,7 @@
#include "ExceptionCode.h"
#include "IDBAny.h"
#include "IDBCursorInfo.h"
+#include <runtime/JSCJSValue.h>
namespace WebCore {
@@ -56,9 +57,9 @@
// 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 @@
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
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.idl 2016-04-17 18:49:53 UTC (rev 199643)
@@ -30,5 +30,5 @@
SkipVTableValidation,
JSCustomMarkFunction,
] interface IDBCursorWithValue : IDBCursor {
- readonly attribute any value;
+ [CallWith=ScriptState, ImplementationReturnType=JSValue] readonly attribute any value;
};
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -28,7 +28,6 @@
#if ENABLE(INDEXED_DATABASE)
-#include "DOMRequestState.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "IDBBindingUtilities.h"
@@ -149,9 +148,8 @@
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);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -28,7 +28,6 @@
#if ENABLE(INDEXED_DATABASE)
-#include "DOMRequestState.h"
#include "IDBAny.h"
#include "IDBBindingUtilities.h"
#include "IDBCursor.h"
@@ -160,8 +159,7 @@
{
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 @@
{
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 @@
{
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.");
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -26,13 +26,15 @@
#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 @@
{
}
-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(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::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::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::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;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.h 2016-04-17 18:49:53 UTC (rev 199643)
@@ -58,8 +58,8 @@
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; }
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.idl (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.idl 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyRange.idl 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -28,7 +28,6 @@
#if ENABLE(INDEXED_DATABASE)
-#include "DOMRequestState.h"
#include "DOMStringList.h"
#include "IDBBindingUtilities.h"
#include "IDBCursor.h"
@@ -182,8 +181,7 @@
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::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 @@
{
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.");
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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::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 @@
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()
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -301,7 +301,7 @@
{
JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
- auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
+ auto jsValue = deserializeIDBValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
if (jsValue.isUndefinedOrNull())
return { };
@@ -310,7 +310,7 @@
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 @@
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;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -1468,7 +1468,7 @@
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 @@
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;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (199642 => 199643)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -765,18 +765,18 @@
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;
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (199642 => 199643)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2012 Michael Pruett <[email protected]>
+ * 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 @@
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 @@
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 @@
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,34 +238,8 @@
return true;
}
-bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
+bool injectIDBKeyIntoScriptValue(ExecState& exec, const IDBKeyData& keyData, JSValue 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)
-{
LOG(IndexedDB, "injectIDBKeyIntoScriptValue");
ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
@@ -328,53 +266,13 @@
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)
+RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(ExecState& exec, const JSValue& 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)
-{
- ASSERT(!keyPath.isNull());
-
- if (keyPath.type() == IndexedDB::KeyPathType::Array) {
- const Vector<String>& array = keyPath.array();
Vector<RefPtr<IDBKey>> result;
result.reserveInitialCapacity(array.size());
for (auto& string : array) {
@@ -390,21 +288,10 @@
return internalCreateIDBKeyFromScriptValueAndKeyPath(&exec, value, keyPath.string());
}
-bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, const JSC::JSValue& scriptValue, const IDBKeyPath& keyPath)
+bool canInjectIDBKeyIntoScriptValue(ExecState& execState, const 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)
-{
- LOG(StorageAPI, "canInjectIDBKeyIntoScriptValue");
-
ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
@@ -417,135 +304,62 @@
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 = ""
+ const Vector<uint8_t>& 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()) };
+ return deserializeIDBValueToJSValue(exec, IDBValue(valueData));
}
-JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
+RefPtr<IDBKey> scriptValueToIDBKey(ExecState& exec, const JSValue& scriptValue)
{
- Vector<String> dummyURLs, dummyFilePaths;
- return deserializeIDBValueDataToJSValue(exec, valueData, dummyURLs, dummyFilePaths);
+ return createIDBKeyFromValue(&exec, scriptValue);
}
-Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState* requestState, PassRefPtr<SharedBuffer> prpBuffer, bool keyIsDefined)
+RefPtr<IDBKey> scriptValueToIDBKey(ScriptExecutionContext& context, 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());
+ auto* execState = context.execState();
+ return execState ? scriptValueToIDBKey(*execState, scriptValue) : nullptr;
}
-static JSValue idbValueDataToJSValue(JSC::ExecState& exec, Vector<uint8_t>&& buffer)
+Strong<Unknown> idbKeyDataToScriptValue(ScriptExecutionContext& context, const IDBKeyData& keyData)
{
- if (buffer.isEmpty())
- return jsNull();
+ RefPtr<IDBKey> key = keyData.maybeCreateIDBKey();
- RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(WTFMove(buffer));
- return serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
-}
-
-Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState* exec, Vector<uint8_t>&& buffer, bool keyIsDefined)
-{
- 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);
-}
-
-JSValue idbValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
-{
- if (!valueData.data())
- return jsUndefined();
-
- return idbValueDataToJSValue(exec, Vector<uint8_t>(*valueData.data()));
-}
-
-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()));
+ return { 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());
-}
-
static Vector<IDBKeyData> createKeyPathArray(ExecState& exec, JSValue value, const IDBIndexInfo& info)
{
Vector<IDBKeyData> keys;
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h (199642 => 199643)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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
@@ -29,51 +30,33 @@
#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)
Modified: trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp (199642 => 199643)
--- trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -98,7 +98,7 @@
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:
Modified: trunk/Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp (199642 => 199643)
--- trunk/Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -66,7 +66,7 @@
return jsUndefined();
if (!keyPathValue.isUndefinedOrNull()) {
- keyPath = idbKeyPathFromValue(&state, keyPathValue);
+ keyPath = idbKeyPathFromValue(state, keyPathValue);
if (state.hadException())
return jsUndefined();
}
Modified: trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp (199642 => 199643)
--- trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -119,7 +119,7 @@
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;
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (199642 => 199643)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-04-17 18:49:53 UTC (rev 199643)
@@ -4349,9 +4349,12 @@
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())";
}
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (199642 => 199643)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-04-17 18:49:53 UTC (rev 199643)
@@ -67,9 +67,10 @@
GetterRaisesException
GetterRaisesExceptionWithMessage
Immutable
+ImplementedAs=*
ImplementationLacksVTable
ImplementationNamespace=*
-ImplementedAs=*
+ImplementationReturnType=*
ImplicitThis
InitializedByEventConstructor
InterfaceName=*
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (199642 => 199643)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -487,4 +487,15 @@
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
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (199642 => 199643)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2016-04-17 18:49:53 UTC (rev 199643)
@@ -188,6 +188,8 @@
int timerNestingLevel() const { return m_timerNestingLevel; }
void setTimerNestingLevel(int timerNestingLevel) { m_timerNestingLevel = timerNestingLevel; }
+ JSC::ExecState* execState();
+
protected:
class AddConsoleMessageTask : public Task {
public:
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (199642 => 199643)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-17 18:39:13 UTC (rev 199642)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-17 18:49:53 UTC (rev 199643)
@@ -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 @@
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 @@
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));