Diff
Modified: trunk/Source/WebCore/ChangeLog (128378 => 128379)
--- trunk/Source/WebCore/ChangeLog 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/ChangeLog 2012-09-12 23:20:22 UTC (rev 128379)
@@ -1,3 +1,49 @@
+2012-09-12 Alec Flett <alecfl...@chromium.org>
+
+ IndexedDB: Use ScriptValue instead of SerializedScriptValue when possible
+ https://bugs.webkit.org/show_bug.cgi?id=94023
+
+ Reviewed by Kentaro Hara.
+
+ Transition the put/add/update methods to accept direct ScriptValue
+ objects rather than SerializedScriptValues, to eliminate lots of
+ redundant deserialization/serialization steps while storing
+ values.
+
+ Also see https://bugs.webkit.org/show_bug.cgi?id=95409 for
+ followup get/openCursor work, following this.
+
+ No new tests, this is a performance refactor of core IDB
+ functionality. Most existing tests cover correctness. Tests that
+ might fail include:
+
+ storage/indexeddb/objectstore-basics.html
+ storage/indexeddb/keypath-basics.html
+ storage/indexeddb/index-basics.html
+
+ * Modules/indexeddb/IDBCursor.cpp:
+ (WebCore::IDBCursor::update):
+ * Modules/indexeddb/IDBCursor.h:
+ (IDBCursor):
+ * Modules/indexeddb/IDBCursor.idl:
+ * Modules/indexeddb/IDBObjectStore.cpp:
+ (WebCore::generateIndexKeysForValue):
+ (WebCore::IDBObjectStore::add):
+ (WebCore::IDBObjectStore::put):
+ (WebCore):
+ * Modules/indexeddb/IDBObjectStore.h:
+ (WebCore::IDBObjectStore::add):
+ (WebCore::IDBObjectStore::put):
+ (IDBObjectStore):
+ * Modules/indexeddb/IDBObjectStore.idl:
+ * bindings/v8/IDBBindingUtilities.cpp:
+ (WebCore):
+ (WebCore::createIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::deserializeIDBValue):
+ (WebCore::canInjectIDBKeyIntoScriptValue):
+ * bindings/v8/IDBBindingUtilities.h:
+ (WebCore):
+
2012-09-12 Chris Fleizach <cfleiz...@apple.com>
AX: svg:image not accessible
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2012-09-12 23:20:22 UTC (rev 128379)
@@ -125,10 +125,9 @@
return m_source.get();
}
-PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, ExceptionCode& ec)
+PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec)
{
IDB_TRACE("IDBCursor::update");
- RefPtr<SerializedScriptValue> value = prpValue;
if (!m_gotValue || isKeyCursor()) {
ec = IDBDatabaseException::IDB_INVALID_STATE_ERR;
@@ -142,17 +141,12 @@
ec = IDBDatabaseException::READ_ONLY_ERR;
return 0;
}
- if (value->blobURLs().size() > 0) {
- // FIXME: Add Blob/File/FileList support
- ec = IDBDatabaseException::IDB_DATA_CLONE_ERR;
- return 0;
- }
RefPtr<IDBObjectStore> objectStore = effectiveObjectStore();
const IDBKeyPath& keyPath = objectStore->metadata().keyPath;
const bool usesInLineKeys = !keyPath.isNull();
if (usesInLineKeys) {
- RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath);
+ RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath);
if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) {
ec = IDBDatabaseException::DATA_ERR;
return 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2012-09-12 23:20:22 UTC (rev 128379)
@@ -75,7 +75,7 @@
PassRefPtr<IDBAny> value();
IDBAny* source() const;
- PassRefPtr<IDBRequest> update(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, ExceptionCode&);
+ PassRefPtr<IDBRequest> update(ScriptExecutionContext*, ScriptValue&, ExceptionCode&);
void advance(unsigned long, ExceptionCode&);
void continueFunction(PassRefPtr<IDBKey>, ExceptionCode&);
PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.idl 2012-09-12 23:20:22 UTC (rev 128379)
@@ -39,7 +39,7 @@
readonly attribute IDBKey primaryKey;
readonly attribute IDBAny source;
- [CallWith=ScriptExecutionContext] IDBRequest update(in SerializedScriptValue value)
+ [CallWith=ScriptExecutionContext] IDBRequest update(in any value)
raises (IDBDatabaseException);
void advance(in unsigned long count)
raises (IDBDatabaseException);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2012-09-12 23:20:22 UTC (rev 128379)
@@ -105,11 +105,11 @@
}
static void generateIndexKeysForValue(const IDBIndexMetadata& indexMetadata,
- PassRefPtr<SerializedScriptValue> objectValue,
+ const ScriptValue& objectValue,
IDBObjectStore::IndexKeys* indexKeys)
{
ASSERT(indexKeys);
- RefPtr<IDBKey> indexKey = createIDBKeyFromSerializedValueAndKeyPath(objectValue, indexMetadata.keyPath);
+ RefPtr<IDBKey> indexKey = createIDBKeyFromScriptValueAndKeyPath(objectValue, indexMetadata.keyPath);
if (!indexKey)
return;
@@ -129,22 +129,21 @@
}
}
-PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
+PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
IDB_TRACE("IDBObjectStore::add");
return put(IDBObjectStoreBackendInterface::AddOnly, IDBAny::create(this), context, value, key, ec);
}
-PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
+PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> key, ExceptionCode& ec)
{
IDB_TRACE("IDBObjectStore::put");
return put(IDBObjectStoreBackendInterface::AddOrUpdate, IDBAny::create(this), context, value, key, ec);
}
-PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> prpValue, PassRefPtr<IDBKey> prpKey, ExceptionCode& ec)
+PassRefPtr<IDBRequest> IDBObjectStore::put(IDBObjectStoreBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptExecutionContext* context, ScriptValue& value, PassRefPtr<IDBKey> prpKey, ExceptionCode& ec)
{
IDB_TRACE("IDBObjectStore::put");
- RefPtr<SerializedScriptValue> value = prpValue;
RefPtr<IDBKey> key = prpKey;
if (m_deleted) {
ec = IDBDatabaseException::IDB_INVALID_STATE_ERR;
@@ -158,7 +157,15 @@
ec = IDBDatabaseException::READ_ONLY_ERR;
return 0;
}
- if (value->blobURLs().size() > 0) {
+
+ ScriptState* state = ScriptState::current();
+ RefPtr<SerializedScriptValue> serializedValue = value.serialize(state);
+ if (state->hadException()) {
+ ec = IDBDatabaseException::IDB_DATA_CLONE_ERR;
+ return 0;
+ }
+
+ if (serializedValue->blobURLs().size() > 0) {
// FIXME: Add Blob/File/FileList support
ec = IDBDatabaseException::IDB_DATA_CLONE_ERR;
return 0;
@@ -177,7 +184,7 @@
return 0;
}
if (usesInLineKeys) {
- RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(value, keyPath);
+ RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value, keyPath);
if (keyPathKey && !keyPathKey->isValid()) {
ec = IDBDatabaseException::DATA_ERR;
return 0;
@@ -187,9 +194,7 @@
return 0;
}
if (hasKeyGenerator && !keyPathKey) {
- RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1);
- RefPtr<SerializedScriptValue> valueAfterInjection = injectIDBKeyIntoSerializedValue(dummyKey, value, keyPath);
- if (!valueAfterInjection) {
+ if (!canInjectIDBKeyIntoScriptValue(value, keyPath)) {
ec = IDBDatabaseException::DATA_ERR;
return 0;
}
@@ -213,7 +218,7 @@
ASSERT(indexKeys.size() == indexNames.size());
RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transaction.get());
- m_backend->putWithIndexKeys(value.release(), key.release(), putMode, request, m_transaction->backend(), indexNames, indexKeys, ec);
+ m_backend->putWithIndexKeys(serializedValue.release(), key.release(), putMode, request, m_transaction->backend(), indexNames, indexKeys, ec);
if (ec) {
request->markEarlyDeath();
return 0;
@@ -313,7 +318,7 @@
{
}
- virtual void handleEvent(ScriptExecutionContext*, Event* event)
+ virtual void handleEvent(ScriptExecutionContext* context, Event* event)
{
ASSERT(event->type() == eventNames().successEvent);
EventTarget* target = event->target();
@@ -336,7 +341,8 @@
RefPtr<IDBAny> valueAny = cursor->value();
ASSERT(valueAny->type() == IDBAny::SerializedScriptValueType);
- RefPtr<SerializedScriptValue> value = valueAny->serializedScriptValue();
+ RefPtr<SerializedScriptValue> serializedValue = valueAny->serializedScriptValue();
+ ScriptValue value(deserializeIDBValue(context, serializedValue));
IDBObjectStore::IndexKeys indexKeys;
generateIndexKeysForValue(m_indexMetadata, value, &indexKeys);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2012-09-12 23:20:22 UTC (rev 128379)
@@ -64,8 +64,8 @@
PassRefPtr<IDBTransaction> transaction() const { return m_transaction; }
bool autoIncrement() const { return m_metadata.autoIncrement; }
- PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return add(context, value, 0, ec); }
- PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, PassRefPtr<SerializedScriptValue> value, ExceptionCode& ec) { return put(context, value, 0, ec); }
+ PassRefPtr<IDBRequest> add(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec) { return add(context, value, 0, ec); }
+ PassRefPtr<IDBRequest> put(ScriptExecutionContext* context, ScriptValue& value, ExceptionCode& ec) { return put(context, value, 0, ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKey> key, ExceptionCode& ec) { return openCursor(context, key, IDBCursor::directionNext(), ec); }
@@ -77,8 +77,8 @@
PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
- PassRefPtr<IDBRequest> add(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&);
- PassRefPtr<IDBRequest> put(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&);
+ PassRefPtr<IDBRequest> add(ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&);
+ PassRefPtr<IDBRequest> put(ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&);
PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<IDBKey> key, ExceptionCode&);
PassRefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&);
@@ -97,7 +97,7 @@
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKey>, ExceptionCode&);
- PassRefPtr<IDBRequest> put(IDBObjectStoreBackendInterface::PutMode, PassRefPtr<IDBAny> source, ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, ExceptionCode&);
+ PassRefPtr<IDBRequest> put(IDBObjectStoreBackendInterface::PutMode, PassRefPtr<IDBAny> source, ScriptExecutionContext*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&);
void markDeleted() { m_deleted = true; }
void transactionFinished();
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl (128378 => 128379)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl 2012-09-12 23:20:22 UTC (rev 128379)
@@ -34,9 +34,9 @@
readonly attribute IDBTransaction transaction;
readonly attribute boolean autoIncrement;
- [CallWith=ScriptExecutionContext] IDBRequest put(in SerializedScriptValue value, in [Optional] IDBKey key)
+ [CallWith=ScriptExecutionContext] IDBRequest put(in any value, in [Optional] IDBKey key)
raises (IDBDatabaseException);
- [CallWith=ScriptExecutionContext] IDBRequest add(in SerializedScriptValue value, in [Optional] IDBKey key)
+ [CallWith=ScriptExecutionContext] IDBRequest add(in any value, in [Optional] IDBKey key)
raises (IDBDatabaseException);
[CallWith=ScriptExecutionContext, ImplementedAs=deleteFunction] IDBRequest delete(in IDBKeyRange? keyRange)
raises (IDBDatabaseException);
Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (128378 => 128379)
--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp 2012-09-12 23:20:22 UTC (rev 128379)
@@ -35,6 +35,7 @@
#include "SerializedScriptValue.h"
#include "V8Binding.h"
#include "V8IDBKey.h"
+#include "WorldContextHandle.h"
#include <wtf/MathExtras.h>
#include <wtf/Vector.h>
@@ -85,10 +86,8 @@
return IDBKey::createInvalid();
}
-namespace {
-
template<typename T>
-bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value)
+static bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value)
{
v8::Local<v8::Object> object = v8Value->ToObject();
if (!object->Has(indexOrName))
@@ -98,49 +97,72 @@
}
template<typename T>
-bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v8::Value>& v8Value)
+static bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v8::Value>& v8Value)
{
v8::Local<v8::Object> object = v8Object->ToObject();
return object->Set(indexOrName, v8Value);
}
-bool get(v8::Handle<v8::Value>& object, const String& keyPathElement)
+static bool get(v8::Handle<v8::Value>& object, const String& keyPathElement, v8::Handle<v8::Value>& result)
{
if (object->IsString() && keyPathElement == "length") {
int32_t length = v8::Handle<v8::String>::Cast(object)->Length();
- object = v8::Number::New(length);
+ result = v8::Number::New(length);
return true;
}
- return object->IsObject() && getValueFrom(v8String(keyPathElement), object);
+ return object->IsObject() && getValueFrom(v8String(keyPathElement), result);
}
-bool set(v8::Handle<v8::Value>& object, const String& keyPathElement, const v8::Handle<v8::Value>& v8Value)
+static bool canSet(v8::Handle<v8::Value>& object, const String& keyPathElement)
{
- return object->IsObject() && setValue(object, v8String(keyPathElement), v8Value);
+ return object->IsObject();
}
-v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
+static bool set(v8::Handle<v8::Value>& object, const String& keyPathElement, const v8::Handle<v8::Value>& v8Value)
{
+ return canSet(object, keyPathElement) && setValue(object, v8String(keyPathElement), v8Value);
+}
+
+static v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
+{
v8::Handle<v8::Value> currentValue(rootValue);
-
ASSERT(index <= keyPathElements.size());
for (size_t i = 0; i < index; ++i) {
- if (!get(currentValue, keyPathElements[i]))
+ v8::Handle<v8::Value> parentValue(currentValue);
+ if (!get(parentValue, keyPathElements[i], currentValue))
return v8Undefined();
}
return currentValue;
}
-v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
+static bool canInjectNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
{
+ if (!rootValue->IsObject())
+ return false;
+
v8::Handle<v8::Value> currentValue(rootValue);
ASSERT(index <= keyPathElements.size());
for (size_t i = 0; i < index; ++i) {
v8::Handle<v8::Value> parentValue(currentValue);
const String& keyPathElement = keyPathElements[i];
- if (!get(currentValue, keyPathElement)) {
+ if (!get(parentValue, keyPathElement, currentValue))
+ return canSet(parentValue, keyPathElement);
+ }
+ return true;
+}
+
+
+static v8::Handle<v8::Value> ensureNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<String>& keyPathElements, size_t index)
+{
+ v8::Handle<v8::Value> currentValue(rootValue);
+
+ ASSERT(index <= keyPathElements.size());
+ for (size_t i = 0; i < index; ++i) {
+ v8::Handle<v8::Value> parentValue(currentValue);
+ const String& keyPathElement = keyPathElements[i];
+ if (!get(parentValue, keyPathElement, currentValue)) {
v8::Handle<v8::Object> object = v8::Object::New();
if (!set(parentValue, keyPathElement, object))
return v8Undefined();
@@ -151,8 +173,42 @@
return currentValue;
}
-} // anonymous namespace
+static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& value, const String& keyPath)
+{
+ Vector<String> keyPathElements;
+ IDBKeyPathParseError error;
+ IDBParseKeyPath(keyPath, keyPathElements, error);
+ ASSERT(error == IDBKeyPathParseErrorNone);
+ v8::Handle<v8::Value> v8Value(value.v8Value());
+ v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));
+ if (v8Key.IsEmpty())
+ return 0;
+ return createIDBKeyFromValue(v8Key);
+}
+
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& value, const IDBKeyPath& keyPath)
+{
+ IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
+ ASSERT(!keyPath.isNull());
+
+ v8::HandleScope scope;
+ if (keyPath.type() == IDBKeyPath::ArrayType) {
+ IDBKey::KeyArray result;
+ const Vector<String>& array = keyPath.array();
+ for (size_t i = 0; i < array.size(); ++i) {
+ RefPtr<IDBKey> key = createIDBKeyFromScriptValueAndKeyPath(value, array[i]);
+ if (!key)
+ return 0;
+ result.append(key);
+ }
+ return IDBKey::createArray(result);
+ }
+
+ ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string());
+}
+
static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const String& keyPath)
{
Vector<String> keyPathElements;
@@ -172,6 +228,13 @@
return createIDBKeyFromValue(v8Key);
}
+// FIXME: The only reason this exists is because we need a v8::Context and scope inside a timer. Is there a better / more general way to do this?
+ScriptValue deserializeIDBValue(ScriptExecutionContext* scriptContext, PassRefPtr<SerializedScriptValue> prpValue)
+{
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
+ return ScriptValue(prpValue->deserialize());
+}
PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const IDBKeyPath& keyPath)
{
@@ -223,6 +286,22 @@
return SerializedScriptValue::create(v8Value);
}
+bool canInjectIDBKeyIntoScriptValue(const ScriptValue& scriptValue, const IDBKeyPath& keyPath)
+{
+ IDB_TRACE("canInjectIDBKeyIntoScriptValue");
+ ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ Vector<String> keyPathElements;
+ IDBKeyPathParseError error;
+ IDBParseKeyPath(keyPath.string(), keyPathElements, error);
+ ASSERT(error == IDBKeyPathParseErrorNone);
+
+ if (!keyPathElements.size())
+ return false;
+
+ v8::Handle<v8::Value> v8Value(scriptValue.v8Value());
+ return canInjectNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1);
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h (128378 => 128379)
--- trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h 2012-09-12 23:17:00 UTC (rev 128378)
+++ trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h 2012-09-12 23:20:22 UTC (rev 128379)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "ScriptValue.h"
#include <v8.h>
#include <wtf/Forward.h>
@@ -38,9 +39,15 @@
class SerializedScriptValue;
PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>);
+
+// FIXME: remove the SerializedValue versions when their use is finally removed in https://bugs.webkit.org/show_bug.cgi?id=95409.
PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue&, const IDBKeyPath&);
+bool canInjectIDBKeyIntoScriptValue(const ScriptValue&, const IDBKeyPath&);
+ScriptValue deserializeIDBValue(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>);
+
}
#endif // ENABLE(INDEXED_DATABASE)