<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[192798] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/192798">192798</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-11-30 10:11:34 -0800 (Mon, 30 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Modern IDB: Support keyPath injection into object store records.
https://bugs.webkit.org/show_bug.cgi?id=151640
Reviewed by Andy Estes.
Source/WebCore:
No new tests (At least one existing failure now passes and is unskipped,
while many other existing failures are now closer to passing).
* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord): Use the new UniqueIDBDatabase VM/ExecState.
(WebCore::IDBServer::MemoryObjectStore::populateIndexWithExistingRecords): Ditto
(WebCore::IDBServer::indexVM): Deleted.
(WebCore::IDBServer::indexGlobalExec): Deleted.
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::databaseThreadVM):
(WebCore::IDBServer::UniqueIDBDatabase::databaseThreadExecState):
(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd): If appropriate, inject the key that will be used into
the value before storing the record.
* Modules/indexeddb/server/UniqueIDBDatabase.h:
Add modern JSValue/ExecState& version of some binding utilities, for use today and in preparation of getting
rid of the DOMRequestState and Deprecated::ScriptValue versions later:
* bindings/js/IDBBindingUtilities.cpp:
(WebCore::idbKeyToJSValue):
(WebCore::injectIDBKeyIntoScriptValue):
(WebCore::deserializeIDBValueData):
(WebCore::deserializeIDBValueDataToJSValue):
* bindings/js/IDBBindingUtilities.h:
LayoutTests:
* platform/mac-wk1/TestExpectations:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsIDBBindingUtilitiescpp">trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsIDBBindingUtilitiesh">trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/LayoutTests/ChangeLog        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2015-11-30 Brady Eidson <beidson@apple.com>
+
+ Modern IDB: Support keyPath injection into object store records.
+ https://bugs.webkit.org/show_bug.cgi?id=151640
+
+ Reviewed by Andy Estes.
+
+ * platform/mac-wk1/TestExpectations:
+
</ins><span class="cx"> 2015-11-29 Antoine Quint <graouts@apple.com>
</span><span class="cx">
</span><span class="cx"> Browser does not fall back to SVG attribute value when CSS style value is invalid or not supported
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx"> # But Modern IndexedDB is.
</span><span class="cx"> storage/indexeddb/modern [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/add-twice-failure.html [ Pass ]
</span><ins>+storage/indexeddb/mozilla/autoincrement-indexes.html [ Pass ]
</ins><span class="cx"> storage/indexeddb/mozilla/bad-keypath.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/create-index-unique.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/create-index-with-integer-keys.html [ Pass ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/ChangeLog        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2015-11-30 Brady Eidson <beidson@apple.com>
+
+ Modern IDB: Support keyPath injection into object store records.
+ https://bugs.webkit.org/show_bug.cgi?id=151640
+
+ Reviewed by Andy Estes.
+
+ No new tests (At least one existing failure now passes and is unskipped,
+ while many other existing failures are now closer to passing).
+
+ * Modules/indexeddb/server/MemoryObjectStore.cpp:
+ (WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord): Use the new UniqueIDBDatabase VM/ExecState.
+ (WebCore::IDBServer::MemoryObjectStore::populateIndexWithExistingRecords): Ditto
+ (WebCore::IDBServer::indexVM): Deleted.
+ (WebCore::IDBServer::indexGlobalExec): Deleted.
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::databaseThreadVM):
+ (WebCore::IDBServer::UniqueIDBDatabase::databaseThreadExecState):
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd): If appropriate, inject the key that will be used into
+ the value before storing the record.
+ * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
+ Add modern JSValue/ExecState& version of some binding utilities, for use today and in preparation of getting
+ rid of the DOMRequestState and Deprecated::ScriptValue versions later:
+ * bindings/js/IDBBindingUtilities.cpp:
+ (WebCore::idbKeyToJSValue):
+ (WebCore::injectIDBKeyIntoScriptValue):
+ (WebCore::deserializeIDBValueData):
+ (WebCore::deserializeIDBValueDataToJSValue):
+ * bindings/js/IDBBindingUtilities.h:
+
</ins><span class="cx"> 2015-11-25 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> [Content Filtering] Avoid creating a ContentFilter when loading the empty document
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "IndexKey.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "MemoryBackingStoreTransaction.h"
</span><ins>+#include "UniqueIDBDatabase.h"
</ins><span class="cx">
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx">
</span><span class="lines">@@ -267,27 +268,6 @@
</span><span class="cx"> return error;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static VM& indexVM()
-{
- ASSERT(!isMainThread());
- static NeverDestroyed<RefPtr<VM>> vm = VM::create();
- return *vm.get();
-}
-
-static ExecState& indexGlobalExec()
-{
- ASSERT(!isMainThread());
- static NeverDestroyed<Strong<JSGlobalObject>> globalObject;
- static bool initialized = false;
- if (!initialized) {
- globalObject.get().set(indexVM(), JSGlobalObject::create(indexVM(), JSGlobalObject::createStructure(indexVM(), jsNull())));
- initialized = true;
- }
-
- RELEASE_ASSERT(globalObject.get()->globalExec());
- return *globalObject.get()->globalExec();
-}
-
</del><span class="cx"> void MemoryObjectStore::updateCursorsForPutRecord(std::set<IDBKeyData>::iterator iterator)
</span><span class="cx"> {
</span><span class="cx"> for (auto& cursor : m_cursors.values())
</span><span class="lines">@@ -308,9 +288,9 @@
</span><span class="cx">
</span><span class="cx"> IDBError MemoryObjectStore::updateIndexesForPutRecord(const IDBKeyData& key, const ThreadSafeDataBuffer& value)
</span><span class="cx"> {
</span><del>- JSLockHolder locker(indexVM());
</del><ins>+ JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
</ins><span class="cx">
</span><del>- auto jsValue = idbValueDataToJSValue(indexGlobalExec(), value);
</del><ins>+ auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), value);
</ins><span class="cx"> if (jsValue.isUndefinedOrNull())
</span><span class="cx"> return { };
</span><span class="cx">
</span><span class="lines">@@ -319,7 +299,7 @@
</span><span class="cx">
</span><span class="cx"> for (auto* index : m_indexesByName.values()) {
</span><span class="cx"> IndexKey indexKey;
</span><del>- generateIndexKeyForValue(indexGlobalExec(), index->info(), jsValue, indexKey);
</del><ins>+ generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey);
</ins><span class="cx">
</span><span class="cx"> if (indexKey.isNull())
</span><span class="cx"> continue;
</span><span class="lines">@@ -340,21 +320,20 @@
</span><span class="cx"> return error;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> IDBError MemoryObjectStore::populateIndexWithExistingRecords(MemoryIndex& index)
</span><span class="cx"> {
</span><span class="cx"> if (!m_keyValueStore)
</span><span class="cx"> return { };
</span><span class="cx">
</span><del>- JSLockHolder locker(indexVM());
</del><ins>+ JSLockHolder locker(UniqueIDBDatabase::databaseThreadVM());
</ins><span class="cx">
</span><span class="cx"> for (auto iterator : *m_keyValueStore) {
</span><del>- auto jsValue = idbValueDataToJSValue(indexGlobalExec(), iterator.value);
</del><ins>+ auto jsValue = idbValueDataToJSValue(UniqueIDBDatabase::databaseThreadExecState(), iterator.value);
</ins><span class="cx"> if (jsValue.isUndefinedOrNull())
</span><span class="cx"> return { };
</span><span class="cx">
</span><span class="cx"> IndexKey indexKey;
</span><del>- generateIndexKeyForValue(indexGlobalExec(), index.info(), jsValue, indexKey);
</del><ins>+ generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index.info(), jsValue, indexKey);
</ins><span class="cx">
</span><span class="cx"> if (indexKey.isNull())
</span><span class="cx"> continue;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -36,8 +36,11 @@
</span><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "UniqueIDBDatabaseConnection.h"
</span><span class="cx"> #include <wtf/MainThread.h>
</span><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><span class="cx">
</span><ins>+using namespace JSC;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace IDBServer {
</span><span class="cx">
</span><span class="lines">@@ -479,9 +482,26 @@
</span><span class="cx"> m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performPutOrAdd, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), keyData, valueData, overwriteMode));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
</del><ins>+VM& UniqueIDBDatabase::databaseThreadVM()
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!isMainThread());
</span><ins>+ static VM* vm = &VM::create().leakRef();
+ return *vm;
+}
+
+ExecState& UniqueIDBDatabase::databaseThreadExecState()
+{
+ ASSERT(!isMainThread());
+
+ static NeverDestroyed<Strong<JSGlobalObject>> globalObject(databaseThreadVM(), JSGlobalObject::create(databaseThreadVM(), JSGlobalObject::createStructure(databaseThreadVM(), jsNull())));
+
+ RELEASE_ASSERT(globalObject.get()->globalExec());
+ return *globalObject.get()->globalExec();
+}
+
+void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& originalRecordValue, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
+{
+ ASSERT(!isMainThread());
</ins><span class="cx"> LOG(IndexedDB, "(db) UniqueIDBDatabase::performPutOrAdd");
</span><span class="cx">
</span><span class="cx"> ASSERT(m_backingStore);
</span><span class="lines">@@ -497,6 +517,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ bool usedKeyIsGenerated = false;
</ins><span class="cx"> if (objectStoreInfo->autoIncrement() && !keyData.isValid()) {
</span><span class="cx"> uint64_t keyNumber;
</span><span class="cx"> error = m_backingStore->generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
</span><span class="lines">@@ -506,6 +527,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> usedKey.setNumberValue(keyNumber);
</span><ins>+ usedKeyIsGenerated = true;
</ins><span class="cx"> } else
</span><span class="cx"> usedKey = keyData;
</span><span class="cx">
</span><span class="lines">@@ -521,6 +543,33 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // 3.4.1.2 Object Store Storage Operation
+ // If ObjectStore has a key path and the key is autogenerated, then inject the key into the value
+ // using steps to assign a key to a value using a key path.
+ ThreadSafeDataBuffer injectedRecordValue;
+ if (usedKeyIsGenerated && !objectStoreInfo->keyPath().isNull()) {
+ JSLockHolder locker(databaseThreadVM());
+
+ JSValue value = deserializeIDBValueDataToJSValue(databaseThreadExecState(), originalRecordValue);
+ if (value.isUndefined()) {
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBExceptionCode::ConstraintError, ASCIILiteral("Unable to deserialize record value for record key injection")), usedKey));
+ return;
+ }
+
+ if (!injectIDBKeyIntoScriptValue(databaseThreadExecState(), usedKey, value, objectStoreInfo->keyPath())) {
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBExceptionCode::ConstraintError, ASCIILiteral("Unable to inject record key into record value")), usedKey));
+ return;
+ }
+
+ auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
+ if (databaseThreadExecState().hadException()) {
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBExceptionCode::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
+ return;
+ }
+
+ injectedRecordValue = ThreadSafeDataBuffer::copyVector(serializedValue->data());
+ }
+
</ins><span class="cx"> // 3.4.1 Object Store Storage Operation
</span><span class="cx"> // ...If a record already exists in store ...
</span><span class="cx"> // then remove the record from store using the steps for deleting records from an object store...
</span><span class="lines">@@ -531,7 +580,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- error = m_backingStore->addRecord(transactionIdentifier, objectStoreIdentifier, usedKey, valueData);
</del><ins>+ error = m_backingStore->addRecord(transactionIdentifier, objectStoreIdentifier, usedKey, injectedRecordValue.data() ? injectedRecordValue : originalRecordValue);
</ins><span class="cx">
</span><span class="cx"> m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="cx">
</span><span class="cx"> #include "IDBBackingStore.h"
</span><ins>+#include "IDBBindingUtilities.h"
</ins><span class="cx"> #include "IDBDatabaseIdentifier.h"
</span><span class="cx"> #include "IDBDatabaseInfo.h"
</span><span class="cx"> #include "IDBGetResult.h"
</span><span class="lines">@@ -97,6 +98,9 @@
</span><span class="cx"> void handleDelete(IDBConnectionToClient&, const IDBRequestData&);
</span><span class="cx"> bool deletePending() const { return m_deletePending; }
</span><span class="cx">
</span><ins>+ static JSC::VM& databaseThreadVM();
+ static JSC::ExecState& databaseThreadExecState();
+
</ins><span class="cx"> private:
</span><span class="cx"> UniqueIDBDatabase(IDBServer&, const IDBDatabaseIdentifier&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsIDBBindingUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static JSValue idbKeyToJSValue(ExecState* exec, JSDOMGlobalObject* globalObject, IDBKey* key)
</del><ins>+static JSValue idbKeyToJSValue(ExecState* exec, JSGlobalObject* globalObject, IDBKey* key)
</ins><span class="cx"> {
</span><span class="cx"> if (!key || !exec) {
</span><span class="cx"> // This should be undefined, not null.
</span><span class="lines">@@ -294,12 +294,40 @@
</span><span class="cx"> if (parent.isUndefined())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), key.get())))
</del><ins>+ if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool injectIDBKeyIntoScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData, JSC::JSValue value, const IDBKeyPath& keyPath)
+{
+ LOG(IndexedDB, "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;
+
+ JSValue parent = ensureNthValueOnKeyPath(&exec, value, keyPathElements, keyPathElements.size() - 1);
+ if (parent.isUndefined())
+ return false;
+
+ auto key = keyData.maybeCreateIDBKey();
+ if (!key)
+ return false;
+
+ if (!set(&exec, parent, keyPathElements.last(), idbKeyToJSValue(&exec, exec.lexicalGlobalObject(), key.get())))
+ return false;
+
+ return true;
+}
+
</ins><span class="cx"> RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
</span><span class="cx"> {
</span><span class="cx"> LOG(StorageAPI, "createIDBKeyFromScriptValueAndKeyPath");
</span><span class="lines">@@ -409,21 +437,26 @@
</span><span class="cx"> if (!execState)
</span><span class="cx"> return Deprecated::ScriptValue();
</span><span class="cx">
</span><ins>+ return Deprecated::ScriptValue(execState->vm(), deserializeIDBValueDataToJSValue(*execState, valueData));
+}
+
+JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
+{
</ins><span class="cx"> if (!valueData.data())
</span><del>- return Deprecated::ScriptValue(execState->vm(), jsUndefined());
</del><ins>+ return jsUndefined();
</ins><span class="cx">
</span><span class="cx"> const Vector<uint8_t>& data = *valueData.data();
</span><span class="cx"> JSValue result;
</span><span class="cx"> if (data.size()) {
</span><span class="cx"> RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(data);
</span><span class="cx">
</span><del>- execState->vm().apiLock().lock();
- result = serializedValue->deserialize(execState, execState->lexicalGlobalObject(), 0, NonThrowing);
- execState->vm().apiLock().unlock();
</del><ins>+ exec.vm().apiLock().lock();
+ result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
+ exec.vm().apiLock().unlock();
</ins><span class="cx"> } else
</span><span class="cx"> result = jsNull();
</span><span class="cx">
</span><del>- return Deprecated::ScriptValue(execState->vm(), result);
</del><ins>+ return result;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState* requestState, PassRefPtr<SharedBuffer> prpBuffer, bool keyIsDefined)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsIDBBindingUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h (192797 => 192798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h        2015-11-30 18:06:23 UTC (rev 192797)
+++ trunk/Source/WebCore/bindings/js/IDBBindingUtilities.h        2015-11-30 18:11:34 UTC (rev 192798)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> IDBKeyPath idbKeyPathFromValue(JSC::ExecState*, JSC::JSValue);
</span><span class="cx">
</span><span class="cx"> bool injectIDBKeyIntoScriptValue(DOMRequestState*, PassRefPtr<IDBKey>, Deprecated::ScriptValue&, const IDBKeyPath&);
</span><ins>+bool injectIDBKeyIntoScriptValue(JSC::ExecState&, const IDBKeyData&, JSC::JSValue, const IDBKeyPath&);
</ins><span class="cx">
</span><span class="cx"> RefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(JSC::ExecState*, const Deprecated::ScriptValue&, const IDBKeyPath&);
</span><span class="cx"> RefPtr<IDBKey> maybeCreateIDBKeyFromScriptValueAndKeyPath(JSC::ExecState&, const Deprecated::ScriptValue&, const IDBKeyPath&);
</span><span class="lines">@@ -61,6 +62,8 @@
</span><span class="cx"> Deprecated::ScriptValue deserializeIDBValueBuffer(DOMRequestState*, PassRefPtr<SharedBuffer>, bool keyIsDefined);
</span><span class="cx"> WEBCORE_EXPORT Deprecated::ScriptValue deserializeIDBValueBuffer(JSC::ExecState*, const Vector<uint8_t>&, bool keyIsDefined);
</span><span class="cx">
</span><ins>+JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
+
</ins><span class="cx"> Deprecated::ScriptValue idbKeyToScriptValue(DOMRequestState*, PassRefPtr<IDBKey>);
</span><span class="cx"> RefPtr<IDBKey> scriptValueToIDBKey(DOMRequestState*, const JSC::JSValue&);
</span><span class="cx"> RefPtr<IDBKey> scriptValueToIDBKey(JSC::ExecState&, const JSC::JSValue&);
</span></span></pre>
</div>
</div>
</body>
</html>