| Index: Source/WebCore/bindings/v8/IDBBindingUtilities.cpp
|
| ===================================================================
|
| --- Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (revision 132816)
|
| +++ Source/WebCore/bindings/v8/IDBBindingUtilities.cpp (working copy)
|
| @@ -209,6 +209,25 @@
|
| return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string());
|
| }
|
|
|
| +static PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const String& keyPath)
|
| +{
|
| + Vector<String> keyPathElements;
|
| + IDBKeyPathParseError error;
|
| + IDBParseKeyPath(keyPath, keyPathElements, error);
|
| + ASSERT(error == IDBKeyPathParseErrorNone);
|
| +
|
| + RefPtr<SerializedScriptValue> value = prpValue;
|
| +
|
| + v8::HandleScope handleScope;
|
| + v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
|
| +
|
| + v8::Handle<v8::Value> v8Value(value->deserialize());
|
| + v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));
|
| + if (v8Key.IsEmpty())
|
| + return 0;
|
| + 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)
|
| {
|
| @@ -217,11 +236,34 @@
|
| return ScriptValue(prpValue->deserialize());
|
| }
|
|
|
| -bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
|
| +PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> prpValue, const IDBKeyPath& keyPath)
|
| {
|
| - IDB_TRACE("injectIDBKeyIntoScriptValue");
|
| + IDB_TRACE("createIDBKeyFromSerializedValueAndKeyPath");
|
| + ASSERT(!keyPath.isNull());
|
|
|
| + RefPtr<SerializedScriptValue> value = prpValue;
|
| +
|
| + 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 = createIDBKeyFromSerializedValueAndKeyPath(value, array[i]);
|
| + if (!key)
|
| + return 0;
|
| + result.append(key);
|
| + }
|
| + return IDBKey::createArray(result);
|
| + }
|
| +
|
| ASSERT(keyPath.type() == IDBKeyPath::StringType);
|
| + return createIDBKeyFromSerializedValueAndKeyPath(value, keyPath.string());
|
| +}
|
| +
|
| +PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
|
| +{
|
| + IDB_TRACE("injectIDBKeyIntoSerializedValue");
|
| +
|
| + ASSERT(keyPath.type() == IDBKeyPath::StringType);
|
| Vector<String> keyPathElements;
|
| IDBKeyPathParseError error;
|
| IDBParseKeyPath(keyPath.string(), keyPathElements, error);
|
| @@ -233,15 +275,15 @@
|
| v8::HandleScope handleScope;
|
| v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
|
|
|
| - v8::Handle<v8::Value> v8Value(value.v8Value());
|
| + v8::Handle<v8::Value> v8Value(value->deserialize());
|
| v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1));
|
| if (parent.IsEmpty())
|
| - return false;
|
| + return 0;
|
|
|
| if (!set(parent, keyPathElements.last(), toV8(key.get())))
|
| - return false;
|
| + return 0;
|
|
|
| - return true;
|
| + return SerializedScriptValue::create(v8Value);
|
| }
|
|
|
| bool canInjectIDBKeyIntoScriptValue(const ScriptValue& scriptValue, const IDBKeyPath& keyPath)
|
|
|