Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (136685 => 136686)
--- trunk/Source/WebCore/CMakeLists.txt 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-12-05 15:37:44 UTC (rev 136686)
@@ -195,8 +195,10 @@
Modules/indexeddb/IDBKey.idl
Modules/indexeddb/IDBKeyRange.idl
Modules/indexeddb/IDBObjectStore.idl
+ Modules/indexeddb/IDBOpenDBRequest.idl
Modules/indexeddb/IDBRequest.idl
Modules/indexeddb/IDBTransaction.idl
+ Modules/indexeddb/IDBUpgradeNeededEvent.idl
Modules/indexeddb/IDBVersionChangeEvent.idl
Modules/indexeddb/IDBVersionChangeRequest.idl
Modules/indexeddb/WorkerContextIndexedDatabase.idl
Modified: trunk/Source/WebCore/ChangeLog (136685 => 136686)
--- trunk/Source/WebCore/ChangeLog 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/ChangeLog 2012-12-05 15:37:44 UTC (rev 136686)
@@ -1,3 +1,53 @@
+2012-12-05 Michael Pruett <[email protected]>
+
+ IndexedDB: Implement IndexedDB bindings for JSC
+ https://bugs.webkit.org/show_bug.cgi?id=103484
+
+ Reviewed by Kentaro Hara.
+
+ IndexedDB is currently implemented only for V8. This change adds
+ the bindings necessary for IndexedDB to work with JSC. With this
+ patch, IndexedDB for JSC passes 112 out of the 196 layout tests in
+ storage/indexeddb. IndexedDB is still not enabled for any JSC port.
+
+ Tests: storage/indexeddb/*
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Modules/indexeddb/IDBOpenDBRequest.idl:
+ * Modules/indexeddb/IDBVersionChangeRequest.idl:
+ * UseJSC.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/DOMRequestState.h: Added to match bindings/v8/DOMRequestState.h.
+ (WebCore):
+ (DOMRequestState):
+ (WebCore::DOMRequestState::DOMRequestState):
+ (WebCore::DOMRequestState::clear):
+ (Scope):
+ (WebCore::DOMRequestState::Scope::Scope):
+ (WebCore::DOMRequestState::exec):
+ * bindings/js/IDBBindingUtilities.cpp: Add utility functions matching those in bindings/v8/IDBBindingUtilities.cpp.
+ (WebCore::get):
+ (WebCore):
+ (WebCore::canSet):
+ (WebCore::set):
+ (WebCore::createIDBKeyFromValue):
+ (WebCore::getNthValueOnKeyPath):
+ (WebCore::createIDBKeyFromScriptValueAndKeyPath):
+ (WebCore::ensureNthValueOnKeyPath):
+ (WebCore::canInjectNthValueOnKeyPath):
+ (WebCore::injectIDBKeyIntoScriptValue):
+ (WebCore::canInjectIDBKeyIntoScriptValue):
+ (WebCore::deserializeIDBValue):
+ (WebCore::idbKeyToScriptValue):
+ * bindings/js/IDBBindingUtilities.h: Add utility functions matching those in bindings/v8/IDBBindingUtilities.h.
+ (WebCore):
+ * bindings/js/JSIDBAnyCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSIDBKeyCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSIDBVersionChangeRequestCustom.cpp: Removed.
+
2012-12-05 Antoine Quint <[email protected]>
TextTrackCue's .endTime property should fire a TypeError when NaN is assigned
Modified: trunk/Source/WebCore/GNUmakefile.list.am (136685 => 136686)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-12-05 15:37:44 UTC (rev 136686)
@@ -465,12 +465,16 @@
DerivedSources/WebCore/JSIDBKeyRange.h \
DerivedSources/WebCore/JSIDBObjectStore.cpp \
DerivedSources/WebCore/JSIDBObjectStore.h \
+ DerivedSources/WebCore/JSIDBOpenDBRequest.cpp \
+ DerivedSources/WebCore/JSIDBOpenDBRequest.h \
DerivedSources/WebCore/JSIDBRequest.cpp \
DerivedSources/WebCore/JSIDBRequest.h \
DerivedSources/WebCore/JSIDBTransaction.cpp \
DerivedSources/WebCore/JSIDBTransaction.h \
DerivedSources/WebCore/JSIDBVersionChangeEvent.cpp \
DerivedSources/WebCore/JSIDBVersionChangeEvent.h \
+ DerivedSources/WebCore/JSIDBUpgradeNeededEvent.cpp \
+ DerivedSources/WebCore/JSIDBUpgradeNeededEvent.h \
DerivedSources/WebCore/JSIDBVersionChangeRequest.cpp \
DerivedSources/WebCore/JSIDBVersionChangeRequest.h \
DerivedSources/WebCore/JSImageData.cpp \
@@ -1229,6 +1233,7 @@
$(WebCore)/Modules/indexeddb/IDBTransaction.idl \
$(WebCore)/Modules/indexeddb/IDBUpgradeNeededEvent.idl \
$(WebCore)/Modules/indexeddb/IDBVersionChangeEvent.idl \
+ $(WebCore)/Modules/indexeddb/IDBUpgradeNeededEvent.idl \
$(WebCore)/Modules/indexeddb/IDBVersionChangeRequest.idl \
$(WebCore)/Modules/indexeddb/WorkerContextIndexedDatabase.idl \
$(WebCore)/Modules/mediasource/MediaSource.idl \
@@ -2242,6 +2247,7 @@
Source/WebCore/bindings/js/DOMWrapperWorld.h \
Source/WebCore/bindings/js/GCController.cpp \
Source/WebCore/bindings/js/GCController.h \
+ Source/WebCore/bindings/js/IDBBindingUtilities.cpp \
Source/WebCore/bindings/js/IDBBindingUtilities.h \
Source/WebCore/bindings/js/JSArrayBufferCustom.cpp \
Source/WebCore/bindings/js/JSArrayBufferViewHelper.h \
@@ -2342,7 +2348,6 @@
Source/WebCore/bindings/js/JSHistoryCustom.h \
Source/WebCore/bindings/js/JSIDBAnyCustom.cpp \
Source/WebCore/bindings/js/JSIDBKeyCustom.cpp \
- Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp \
Source/WebCore/bindings/js/JSImageConstructor.cpp \
Source/WebCore/bindings/js/JSImageConstructor.h \
Source/WebCore/bindings/js/JSImageDataCustom.cpp \
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.idl (136685 => 136686)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.idl 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.idl 2012-12-05 15:37:44 UTC (rev 136686)
@@ -27,7 +27,8 @@
Conditional=INDEXED_DATABASE,
ActiveDOMObject,
EventTarget,
- JSNoStaticTables
+ JSNoStaticTables,
+ JSGenerateToJSObject
] interface IDBOpenDBRequest : IDBRequest {
attribute EventListener onblocked;
attribute EventListener onupgradeneeded;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBVersionChangeRequest.idl (136685 => 136686)
--- trunk/Source/WebCore/Modules/indexeddb/IDBVersionChangeRequest.idl 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBVersionChangeRequest.idl 2012-12-05 15:37:44 UTC (rev 136686)
@@ -27,7 +27,8 @@
Conditional=INDEXED_DATABASE,
ActiveDOMObject,
EventTarget,
- JSNoStaticTables
+ JSNoStaticTables,
+ JSGenerateToJSObject
] interface IDBVersionChangeRequest : IDBRequest {
attribute EventListener onblocked;
};
Modified: trunk/Source/WebCore/UseJSC.cmake (136685 => 136686)
--- trunk/Source/WebCore/UseJSC.cmake 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/UseJSC.cmake 2012-12-05 15:37:44 UTC (rev 136686)
@@ -204,7 +204,6 @@
bindings/js/IDBBindingUtilities.cpp
bindings/js/JSIDBAnyCustom.cpp
bindings/js/JSIDBKeyCustom.cpp
- bindings/js/JSIDBVersionChangeRequestCustom.cpp
)
ENDIF ()
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (136685 => 136686)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-12-05 15:37:44 UTC (rev 136686)
@@ -727,7 +727,6 @@
24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */; settings = {ATTRIBUTES = (); }; };
2542F4DA1166C25A00E89A86 /* UserGestureIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */; };
2542F4DB1166C25A00E89A86 /* UserGestureIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 26247DAE150EF0C40027B53A /* JSIDBVersionChangeRequestCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26247DAD150EF0C40027B53A /* JSIDBVersionChangeRequestCustom.cpp */; };
265541391489811C000DFC5D /* KeyEventCodesIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 265541371489811C000DFC5D /* KeyEventCodesIOS.h */; };
2655413A1489811C000DFC5D /* KeyEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 265541381489811C000DFC5D /* KeyEventIOS.mm */; };
265541521489B233000DFC5D /* CursorIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2655414B1489AA2B000DFC5D /* CursorIOS.cpp */; };
@@ -7889,7 +7888,6 @@
24F54EAB101FE914000AE741 /* ApplicationCacheHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheHost.h; sourceTree = "<group>"; };
2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserGestureIndicator.cpp; sourceTree = "<group>"; };
2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserGestureIndicator.h; sourceTree = "<group>"; };
- 26247DAD150EF0C40027B53A /* JSIDBVersionChangeRequestCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBVersionChangeRequestCustom.cpp; sourceTree = "<group>"; };
265541371489811C000DFC5D /* KeyEventCodesIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCodesIOS.h; path = ios/KeyEventCodesIOS.h; sourceTree = "<group>"; };
265541381489811C000DFC5D /* KeyEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventIOS.mm; path = ios/KeyEventIOS.mm; sourceTree = "<group>"; };
2655414B1489AA2B000DFC5D /* CursorIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CursorIOS.cpp; path = ios/CursorIOS.cpp; sourceTree = "<group>"; };
@@ -20635,7 +20633,6 @@
E1AD139D1295D96100ACA989 /* JSHTMLStyleElementCustom.cpp */,
C585A65C11D4FAB2004C3E4B /* JSIDBAnyCustom.cpp */,
C585A65D11D4FAB2004C3E4B /* JSIDBKeyCustom.cpp */,
- 26247DAD150EF0C40027B53A /* JSIDBVersionChangeRequestCustom.cpp */,
A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */,
7A0E76D410BF050700A0276E /* JSInjectedScriptHostCustom.cpp */,
F316396D1329487600A649CB /* JSInjectedScriptManager.cpp */,
@@ -27611,7 +27608,6 @@
B6566271120B1227006EA85C /* JSIDBTransaction.cpp in Sources */,
269239951505E1AA009E57FC /* JSIDBVersionChangeEvent.cpp in Sources */,
269239971505E1AA009E57FC /* JSIDBVersionChangeRequest.cpp in Sources */,
- 26247DAE150EF0C40027B53A /* JSIDBVersionChangeRequestCustom.cpp in Sources */,
BC6C49F30D7DBA0500FFA558 /* JSImageConstructor.cpp in Sources */,
A77979280D6B9E64003851B9 /* JSImageData.cpp in Sources */,
A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */,
Added: trunk/Source/WebCore/bindings/js/DOMRequestState.h (0 => 136686)
--- trunk/Source/WebCore/bindings/js/DOMRequestState.h (rev 0)
+++ trunk/Source/WebCore/bindings/js/DOMRequestState.h 2012-12-05 15:37:44 UTC (rev 136686)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 Michael Pruett <[email protected]>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DOMRequestState_h
+#define DOMRequestState_h
+
+#include "DOMWrapperWorld.h"
+#include "Document.h"
+#include "ScriptState.h"
+#if ENABLE(WORKERS)
+#include "WorkerContext.h"
+#endif
+
+#include <_javascript_Core/APIShims.h>
+
+namespace WebCore {
+
+class ScriptExecutionContext;
+
+class DOMRequestState {
+public:
+ explicit DOMRequestState(ScriptExecutionContext* scriptExecutionContext)
+ : m_scriptExecutionContext(scriptExecutionContext)
+ , m_exec(0)
+ {
+ if (m_scriptExecutionContext->isDocument()) {
+ Document* document = static_cast<Document*>(m_scriptExecutionContext);
+ m_exec = scriptStateFromPage(mainThreadNormalWorld(), document->page());
+ } else {
+ WorkerContext* workerContext = static_cast<WorkerContext*>(m_scriptExecutionContext);
+ m_exec = scriptStateFromWorkerContext(workerContext);
+ }
+ }
+
+ void clear()
+ {
+ m_scriptExecutionContext = 0;
+ m_exec = 0;
+ }
+
+ class Scope {
+ public:
+ explicit Scope(DOMRequestState& state)
+ : m_entryShim(state.exec())
+ {
+ }
+ private:
+ JSC::APIEntryShim m_entryShim;
+ };
+
+ JSC::ExecState* exec()
+ {
+ return m_exec;
+ }
+
+private:
+ ScriptExecutionContext* m_scriptExecutionContext;
+ JSC::ExecState* m_exec;
+};
+
+}
+#endif
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (136685 => 136686)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp 2012-12-05 15:37:44 UTC (rev 136686)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Michael Pruett <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,22 +29,238 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBBindingUtilities.h"
+#include "DOMRequestState.h"
#include "IDBKey.h"
+#include "IDBKeyPath.h"
+#include "IDBTracing.h"
+#include "JSIDBKey.h"
+#include <runtime/DateInstance.h>
+
+using namespace JSC;
+
namespace WebCore {
-PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value)
+static bool get(ExecState* exec, JSValue object, const String& keyPathElement, JSValue& result)
{
- if (value.isNull())
- return IDBKey::createInvalid();
- if (value.isInt32())
+ if (object.isString() && keyPathElement == "length") {
+ result = jsNumber(object.toString(exec)->length());
+ return true;
+ }
+ if (!object.isObject())
+ return false;
+ Identifier identifier(&exec->globalData(), keyPathElement.utf8().data());
+ if (!asObject(object)->hasProperty(exec, identifier))
+ return false;
+ result = asObject(object)->get(exec, identifier);
+ return true;
+}
+
+static bool canSet(JSValue object, const String& keyPathElement)
+{
+ return object.isObject();
+}
+
+static bool set(ExecState* exec, JSValue& object, const String& keyPathElement, JSValue jsValue)
+{
+ if (!canSet(object, keyPathElement))
+ return false;
+ Identifier identifier(&exec->globalData(), keyPathElement.utf8().data());
+ asObject(object)->putDirect(exec->globalData(), identifier, jsValue);
+ return true;
+}
+
+static const size_t maximumDepth = 2000;
+
+static PassRefPtr<IDBKey> createIDBKeyFromValue(ExecState* exec, JSValue value, Vector<JSArray*>& stack)
+{
+ if (value.isNumber() && !isnan(value.toNumber(exec)))
return IDBKey::createNumber(value.toNumber(exec));
if (value.isString())
return IDBKey::createString(value.toString(exec)->value(exec));
- // FIXME: Implement dates.
+ if (value.inherits(&DateInstance::s_info) && !isnan(valueToDate(exec, value)))
+ return IDBKey::createDate(valueToDate(exec, value));
+ if (value.isObject()) {
+ JSObject* object = asObject(value);
+ if (isJSArray(object) || object->inherits(&JSArray::s_info)) {
+ JSArray* array = asArray(object);
+ size_t length = array->length();
+
+ if (stack.contains(array))
+ return 0;
+ if (stack.size() >= maximumDepth)
+ return 0;
+ stack.append(array);
+
+ IDBKey::KeyArray subkeys;
+ for (size_t i = 0; i < length; i++) {
+ JSValue item = array->getIndex(exec, i);
+ RefPtr<IDBKey> subkey = createIDBKeyFromValue(exec, item, stack);
+ if (!subkey)
+ subkeys.append(IDBKey::createInvalid());
+ else
+ subkeys.append(subkey);
+ }
+
+ stack.removeLast();
+ return IDBKey::createArray(subkeys);
+ }
+ }
return 0;
}
+PassRefPtr<IDBKey> createIDBKeyFromValue(ExecState* exec, JSValue value)
+{
+ Vector<JSArray*> stack;
+ RefPtr<IDBKey> key = createIDBKeyFromValue(exec, value, stack);
+ if (key)
+ return key;
+ return IDBKey::createInvalid();
+}
+
+static JSValue getNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
+{
+ JSValue currentValue(rootValue);
+ ASSERT(index <= keyPathElements.size());
+ for (size_t i = 0; i < index; i++) {
+ JSValue parentValue(currentValue);
+ if (!get(exec, parentValue, keyPathElements[i], currentValue))
+ return jsUndefined();
+ }
+ return currentValue;
+}
+
+static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const ScriptValue& value, const String& keyPath)
+{
+ Vector<String> keyPathElements;
+ IDBKeyPathParseError error;
+ IDBParseKeyPath(keyPath, keyPathElements, error);
+ ASSERT(error == IDBKeyPathParseErrorNone);
+
+ JSValue jsValue = value.jsValue();
+ jsValue = getNthValueOnKeyPath(exec, jsValue, keyPathElements, keyPathElements.size());
+ if (jsValue.isUndefined())
+ return 0;
+ return createIDBKeyFromValue(exec, jsValue);
+}
+
+static JSValue ensureNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
+{
+ JSValue currentValue(rootValue);
+
+ ASSERT(index <= keyPathElements.size());
+ for (size_t i = 0; i < index; i++) {
+ JSValue parentValue(currentValue);
+ const String& keyPathElement = keyPathElements[i];
+ if (!get(exec, parentValue, keyPathElement, currentValue)) {
+ JSObject* object = constructEmptyObject(exec);
+ if (!set(exec, parentValue, keyPathElement, JSValue(object)))
+ return jsUndefined();
+ currentValue = JSValue(object);
+ }
+ }
+
+ return currentValue;
+}
+
+static bool canInjectNthValueOnKeyPath(ExecState* exec, JSValue rootValue, const Vector<String>& keyPathElements, size_t index)
+{
+ if (!rootValue.isObject())
+ return false;
+
+ JSValue currentValue(rootValue);
+
+ ASSERT(index <= keyPathElements.size());
+ for (size_t i = 0; i < index; ++i) {
+ JSValue parentValue(currentValue);
+ const String& keyPathElement = keyPathElements[i];
+ if (!get(exec, parentValue, keyPathElement, currentValue))
+ return canSet(parentValue, keyPathElement);
+ }
+ return true;
+}
+
+bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
+{
+ IDB_TRACE("injectIDBKeyIntoScriptValue");
+
+ ASSERT(keyPath.type() == IDBKeyPath::StringType);
+
+ Vector<String> keyPathElements;
+ IDBKeyPathParseError error;
+ IDBParseKeyPath(keyPath.string(), keyPathElements, error);
+ ASSERT(error == IDBKeyPathParseErrorNone);
+
+ 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(), toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get())))
+ return false;
+
+ return true;
+}
+
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState* requestState, const ScriptValue& value, const IDBKeyPath& keyPath)
+{
+ IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
+ ASSERT(!keyPath.isNull());
+
+ ExecState* exec = requestState->exec();
+
+ 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(exec, value, array[i]);
+ if (!key)
+ return 0;
+ result.append(key);
+ }
+ return IDBKey::createArray(result);
+ }
+
+ ASSERT(keyPath.type() == IDBKeyPath::StringType);
+ return createIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath.string());
+}
+
+bool canInjectIDBKeyIntoScriptValue(DOMRequestState* requestState, 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;
+
+ JSC::ExecState* exec = requestState->exec();
+ return canInjectNthValueOnKeyPath(exec, scriptValue.jsValue(), keyPathElements, keyPathElements.size() - 1);
+}
+
+ScriptValue deserializeIDBValue(DOMRequestState* requestState, PassRefPtr<SerializedScriptValue> prpValue)
+{
+ ExecState* exec = requestState->exec();
+ RefPtr<SerializedScriptValue> serializedValue = prpValue;
+ if (serializedValue)
+ return ScriptValue::deserialize(exec, serializedValue.get(), NonThrowing);
+ return ScriptValue(exec->globalData(), jsNull());
+}
+
+ScriptValue idbKeyToScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key)
+{
+ ExecState* exec = requestState->exec();
+ return ScriptValue(exec->globalData(), toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get()));
+}
+
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h (136685 => 136686)
--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h 2012-12-05 15:37:44 UTC (rev 136686)
@@ -34,10 +34,18 @@
namespace WebCore {
+class DOMRequestState;
class IDBKey;
+class IDBKeyPath;
PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState*, JSC::JSValue);
+bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey>, ScriptValue&, const IDBKeyPath&);
+PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(DOMRequestState*, const ScriptValue&, const IDBKeyPath&);
+bool canInjectIDBKeyIntoScriptValue(DOMRequestState*, const ScriptValue&, const IDBKeyPath&);
+ScriptValue deserializeIDBValue(DOMRequestState*, PassRefPtr<SerializedScriptValue>);
+ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
+
}
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp (136685 => 136686)
--- trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp 2012-12-05 15:37:44 UTC (rev 136686)
@@ -64,8 +64,6 @@
return jsUndefined();
case IDBAny::NullType:
return jsNull();
- case IDBAny::StringType:
- return jsStringWithCache(exec, idbAny->string());
case IDBAny::DOMStringListType:
return toJS(exec, globalObject, idbAny->domStringList());
case IDBAny::IDBCursorType:
@@ -84,8 +82,12 @@
return toJS(exec, globalObject, idbAny->idbObjectStore());
case IDBAny::IDBTransactionType:
return toJS(exec, globalObject, idbAny->idbTransaction());
- case IDBAny::SerializedScriptValueType:
- return idbAny->serializedScriptValue()->deserialize(exec, globalObject);
+ case IDBAny::ScriptValueType:
+ return idbAny->scriptValue().jsValue();
+ case IDBAny::IntegerType:
+ return jsNumber(idbAny->integer());
+ case IDBAny::StringType:
+ return jsStringWithCache(exec, idbAny->string());
}
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp (136685 => 136686)
--- trunk/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp 2012-12-05 15:37:44 UTC (rev 136686)
@@ -50,11 +50,10 @@
{
const IDBKey::KeyArray& inArray = key->array();
size_t size = inArray.size();
- JSArray* outArray = constructEmptyArray(exec, globalObject, size);
- JSGlobalData& globalData = exec->globalData();
+ JSArray* outArray = constructEmptyArray(exec, 0, globalObject, size);
for (size_t i = 0; i < size; ++i) {
IDBKey* arrayKey = inArray.at(i).get();
- outArray->initializeIndex(globalData, i, toJS(exec, globalObject, arrayKey));
+ outArray->putDirectIndex(exec, i, toJS(exec, globalObject, arrayKey));
}
return JSValue(outArray);
}
Deleted: trunk/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp (136685 => 136686)
--- trunk/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp 2012-12-05 15:31:09 UTC (rev 136685)
+++ trunk/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp 2012-12-05 15:37:44 UTC (rev 136686)
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2012, Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-
-#include "config.h"
-#include "JSIDBVersionChangeRequest.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-void JSIDBVersionChangeRequest::visitChildren(JSCell*, JSC::SlotVisitor&)
-{
- // FIXME: Implement this.
-}
-
-}
-
-#endif