[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
andreip at google.com
andreip at google.com
Wed Dec 22 18:49:05 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 0837fabb2d58b7fff490e7c2f4fffeace5598c89
Author: andreip at google.com <andreip at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 20 14:31:27 2010 +0000
2010-12-20 Andrei Popescu <andreip at google.com>
Reviewed by Jeremy Orlow.
IDBCursor::delete is not implemented.
https://bugs.webkit.org/show_bug.cgi?id=51110
* storage/indexeddb/cursor-delete-expected.txt: Added.
* storage/indexeddb/cursor-delete.html: Added.
* storage/indexeddb/cursor-index-delete-expected.txt: Added.
* storage/indexeddb/cursor-index-delete.html: Added.
2010-12-20 Andrei Popescu <andreip at google.com>
Reviewed by Jeremy Orlow.
IDBCursor::delete is not implemented.
https://bugs.webkit.org/show_bug.cgi?id=51110
Implement IDBCursor::delete.
See http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBCursor-delete
Tests: storage/indexeddb/cursor-delete.html
storage/indexeddb/cursor-index-delete.html
* storage/IDBCursor.cpp:
(WebCore::IDBCursor::deleteFunction):
* storage/IDBCursor.h:
* storage/IDBCursor.idl:
* storage/IDBCursorBackendImpl.cpp:
(WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::deleteFunction):
(WebCore::IDBCursorBackendImpl::loadCurrentRow):
* storage/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::create):
* storage/IDBCursorBackendInterface.h:
* storage/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::openCursorInternal):
* storage/IDBKey.cpp:
(WebCore::IDBKey::fromQuery):
* storage/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::deleteInternal):
(WebCore::IDBObjectStoreBackendImpl::openCursorInternal):
2010-12-20 Andrei Popescu <andreip at google.com>
Reviewed by Jeremy Orlow.
IDBCursor::delete is not implemented.
https://bugs.webkit.org/show_bug.cgi?id=51110
* public/WebIDBCursor.h:
(WebKit::WebIDBCursor::remove):
(WebKit::WebIDBCursor::deleteFunction):
* src/IDBCursorBackendProxy.cpp:
(WebCore::IDBCursorBackendProxy::deleteFunction):
* src/IDBCursorBackendProxy.h:
* src/WebIDBCursorImpl.cpp:
(WebKit::WebIDBCursorImpl::deleteFunction):
* src/WebIDBCursorImpl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74342 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0a722b9..d07d2d7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-12-20 Andrei Popescu <andreip at google.com>
+
+ Reviewed by Jeremy Orlow.
+
+ IDBCursor::delete is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=51110
+
+ * storage/indexeddb/cursor-delete-expected.txt: Added.
+ * storage/indexeddb/cursor-delete.html: Added.
+ * storage/indexeddb/cursor-index-delete-expected.txt: Added.
+ * storage/indexeddb/cursor-index-delete.html: Added.
+
2010-12-20 Yury Semikhatsky <yurys at chromium.org>
Unreviewed. Update Chromium test expectations.
diff --git a/LayoutTests/storage/indexeddb/cursor-delete-expected.txt b/LayoutTests/storage/indexeddb/cursor-delete-expected.txt
new file mode 100644
index 0000000..7f5d776
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/cursor-delete-expected.txt
@@ -0,0 +1,132 @@
+Test IndexedDB's openCursor.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('name')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+db = event.result
+db.setVersion('new version')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+setVersionSuccess():
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+trans = event.result
+PASS trans !== null is true
+Deleted all object stores.
+objectStore = db.createObjectStore('test')
+objectStore.add('myValue1', 'myKey1')
+objectStore.add('myValue2', 'myKey2')
+objectStore.add('myValue3', 'myKey3')
+objectStore.add('myValue4', 'myKey4')
+openCursor1
+trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+trans.objectStore('test').openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+event.result.delete()
+PASS event.result.value is "myValue1"
+event.result.continue()
+event.result.delete()
+PASS event.result.value is "myValue2"
+event.result.continue()
+event.result.delete()
+PASS event.result.value is "myValue3"
+event.result.continue()
+event.result.delete()
+PASS event.result.value is "myValue4"
+event.result.continue()
+PASS counter is 5
+trans.objectStore('test').openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+WARN: shouldBe() expects string arguments
+PASS null is null
+trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+objectStore = trans.objectStore('test')
+objectStore.add('myValue1', 'myKey1')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+openCursor2
+objectStore.openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS [object IDBCursor] is non-null.
+event.result.delete()
+objectStore.get('myKey1')
+Error event fired:
+PASS 'result' in event is false
+PASS 'code' in event is true
+PASS 'message' in event is true
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/storage/indexeddb/cursor-delete.html b/LayoutTests/storage/indexeddb/cursor-delete.html
new file mode 100644
index 0000000..ce62d6a
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/cursor-delete.html
@@ -0,0 +1,132 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test IndexedDB's openCursor.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+test();
+
+function test()
+{
+ result = evalAndLog("webkitIndexedDB.open('name')");
+ verifyResult(result);
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+ verifySuccessEvent(event);
+ var db = evalAndLog("db = event.result");
+
+ result = evalAndLog("db.setVersion('new version')");
+ verifyResult(result);
+ result.onsuccess = setVersionSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function setVersionSuccess()
+{
+ debug("setVersionSuccess():");
+ verifySuccessEvent(event);
+ window.trans = evalAndLog("trans = event.result");
+ shouldBeTrue("trans !== null");
+ trans.onabort = unexpectedAbortCallback;
+ trans.oncomplete = openCursor;
+
+ deleteAllObjectStores(db, createAndPopulateObjectStore);
+}
+
+function createAndPopulateObjectStore()
+{
+ var objectStore = evalAndLog("objectStore = db.createObjectStore('test')");
+ evalAndLog("objectStore.add('myValue1', 'myKey1')");
+ evalAndLog("objectStore.add('myValue2', 'myKey2')");
+ evalAndLog("objectStore.add('myValue3', 'myKey3')");
+ evalAndLog("objectStore.add('myValue4', 'myKey4')");
+}
+
+function openCursor()
+{
+ debug("openCursor1");
+ evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ keyRange = webkitIDBKeyRange.lowerBound("myKey1");
+ result = evalAndLog("trans.objectStore('test').openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = cursorSuccess;
+ result.onerror = unexpectedErrorCallback;
+ counter = 1;
+}
+
+function cursorSuccess()
+{
+ if (event.result == null) {
+ shouldBe("counter", "5");
+ result = evalAndLog("trans.objectStore('test').openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = cursorEmpty;
+ result.onerror = unexpectedErrorCallback;
+ return;
+ }
+ evalAndLog("event.result.delete()");
+ shouldBeEqualToString("event.result.value", "myValue" + counter++);
+ evalAndLog("event.result.continue()");
+}
+
+function cursorEmpty()
+{
+ verifySuccessEvent(event);
+ shouldBeNull(event.result);
+ trans.oncomplete = addObject;
+}
+
+function addObject()
+{
+ evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ objectStore = evalAndLog("objectStore = trans.objectStore('test')");
+ result = evalAndLog("objectStore.add('myValue1', 'myKey1')");
+ verifyResult(result);
+ result.onsuccess = openCursor2;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function openCursor2()
+{
+ debug("openCursor2");
+ result = evalAndLog("objectStore.openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = deleteObject;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function deleteObject()
+{
+ verifySuccessEvent(event);
+ shouldBeNonNull(event.result);
+ evalAndLog("event.result.delete()");
+ result = evalAndLog("objectStore.get('myKey1')");
+ result.onsuccess = unexpectedSuccessCallback;
+ result.onerror = verifyObjectDeleted;
+}
+
+function verifyObjectDeleted()
+{
+ verifyErrorEvent(event);
+ done();
+}
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt b/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt
new file mode 100644
index 0000000..8da0df3
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/cursor-index-delete-expected.txt
@@ -0,0 +1,133 @@
+Test IndexedDB's openCursor.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('name')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+db = event.result
+db.setVersion('new version')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+setVersionSuccess():
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+trans = event.result
+PASS trans !== null is true
+Deleted all object stores.
+objectStore = db.createObjectStore('test')
+objectStore.createIndex('testIndex', 'x')
+objectStore.add({x: 1}, 'myKey1')
+objectStore.add({x: 2}, 'myKey2')
+objectStore.add({x: 3}, 'myKey3')
+objectStore.add({x: 4}, 'myKey4')
+openCursor1
+trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+trans.objectStore('test').index('testIndex').openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+event.result.delete()
+PASS event.result.key is counter++
+event.result.continue()
+event.result.delete()
+PASS event.result.key is counter++
+event.result.continue()
+event.result.delete()
+PASS event.result.key is counter++
+event.result.continue()
+event.result.delete()
+PASS event.result.key is counter++
+event.result.continue()
+PASS counter is 5
+trans.objectStore('test').index('testIndex').openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS event.result is null
+trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)
+objectStore = trans.objectStore('test')
+objectStore.add({x: 1}, 'myKey1')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+openCursor2
+index = event.source.index('testIndex')
+index.openCursor({range: keyRange})
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+Success event fired:
+PASS 'result' in event is true
+PASS 'code' in event is false
+PASS 'message' in event is false
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS [object IDBCursor] is non-null.
+event.result.delete()
+index.get(1)
+Error event fired:
+PASS 'result' in event is false
+PASS 'code' in event is true
+PASS 'message' in event is true
+PASS 'source' in event is true
+PASS event.source != null is true
+PASS 'onsuccess' in event.target is true
+PASS 'onerror' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
diff --git a/LayoutTests/storage/indexeddb/cursor-index-delete.html b/LayoutTests/storage/indexeddb/cursor-index-delete.html
new file mode 100644
index 0000000..ea10f02
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/cursor-index-delete.html
@@ -0,0 +1,136 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test IndexedDB's openCursor.");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+test();
+
+function test()
+{
+ result = evalAndLog("webkitIndexedDB.open('name')");
+ verifyResult(result);
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+ verifySuccessEvent(event);
+ var db = evalAndLog("db = event.result");
+
+ result = evalAndLog("db.setVersion('new version')");
+ verifyResult(result);
+ result.onsuccess = setVersionSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function setVersionSuccess()
+{
+ debug("setVersionSuccess():");
+ verifySuccessEvent(event);
+ window.trans = evalAndLog("trans = event.result");
+ shouldBeTrue("trans !== null");
+ trans.onabort = unexpectedAbortCallback;
+ trans.oncomplete = openCursor;
+
+ deleteAllObjectStores(db, createAndPopulateObjectStoreAndIndex);
+}
+
+function createAndPopulateObjectStoreAndIndex()
+{
+ objectStore = evalAndLog("objectStore = db.createObjectStore('test')");
+ evalAndLog("objectStore.createIndex('testIndex', 'x')");
+
+ evalAndLog("objectStore.add({x: 1}, 'myKey1')");
+ evalAndLog("objectStore.add({x: 2}, 'myKey2')");
+ evalAndLog("objectStore.add({x: 3}, 'myKey3')");
+ evalAndLog("objectStore.add({x: 4}, 'myKey4')");
+}
+
+function openCursor()
+{
+ debug("openCursor1");
+ evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ keyRange = webkitIDBKeyRange.lowerBound(1);
+ result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = cursorSuccess;
+ result.onerror = unexpectedErrorCallback;
+ counter = 1;
+}
+
+function cursorSuccess()
+{
+ if (event.result == null) {
+ shouldBe("counter", "5");
+ result = evalAndLog("trans.objectStore('test').index('testIndex').openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = cursorEmpty;
+ result.onerror = unexpectedErrorCallback;
+ return;
+ }
+ var deleteResult = evalAndLog("event.result.delete()");
+ deleteResult.onerror = unexpectedErrorCallback;
+ shouldBe("event.result.key", "counter++");
+ evalAndLog("event.result.continue()");
+}
+
+function cursorEmpty()
+{
+ verifySuccessEvent(event);
+ shouldBeNull("event.result");
+ trans.oncomplete = addObject;
+}
+
+function addObject()
+{
+ evalAndLog("trans = db.transaction('test', webkitIDBTransaction.READ_WRITE)");
+ objectStore = evalAndLog("objectStore = trans.objectStore('test')");
+ result = evalAndLog("objectStore.add({x: 1}, 'myKey1')");
+ verifyResult(result);
+ result.onsuccess = openCursor2;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function openCursor2()
+{
+ debug("openCursor2");
+ evalAndLog("index = event.source.index('testIndex')");
+ result = evalAndLog("index.openCursor({range: keyRange})");
+ verifyResult(result);
+ result.onsuccess = deleteObject;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function deleteObject()
+{
+ verifySuccessEvent(event);
+ shouldBeNonNull(event.result);
+ evalAndLog("event.result.delete()");
+ result = evalAndLog("index.get(1)");
+ result.onsuccess = unexpectedSuccessCallback;
+ result.onerror = verifyObjectDeleted;
+}
+
+function verifyObjectDeleted()
+{
+ verifyErrorEvent(event);
+ done();
+}
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c18fe90..b213fb8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2010-12-20 Andrei Popescu <andreip at google.com>
+
+ Reviewed by Jeremy Orlow.
+
+ IDBCursor::delete is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=51110
+
+ Implement IDBCursor::delete.
+ See http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBCursor-delete
+
+ Tests: storage/indexeddb/cursor-delete.html
+ storage/indexeddb/cursor-index-delete.html
+
+ * storage/IDBCursor.cpp:
+ (WebCore::IDBCursor::deleteFunction):
+ * storage/IDBCursor.h:
+ * storage/IDBCursor.idl:
+ * storage/IDBCursorBackendImpl.cpp:
+ (WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
+ (WebCore::IDBCursorBackendImpl::deleteFunction):
+ (WebCore::IDBCursorBackendImpl::loadCurrentRow):
+ * storage/IDBCursorBackendImpl.h:
+ (WebCore::IDBCursorBackendImpl::create):
+ * storage/IDBCursorBackendInterface.h:
+ * storage/IDBIndexBackendImpl.cpp:
+ (WebCore::IDBIndexBackendImpl::openCursorInternal):
+ * storage/IDBKey.cpp:
+ (WebCore::IDBKey::fromQuery):
+ * storage/IDBObjectStoreBackendImpl.cpp:
+ (WebCore::IDBObjectStoreBackendImpl::deleteInternal):
+ (WebCore::IDBObjectStoreBackendImpl::openCursorInternal):
+
2010-12-20 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/storage/IDBCursor.cpp b/WebCore/storage/IDBCursor.cpp
index 1aaff9d..444c109 100644
--- a/WebCore/storage/IDBCursor.cpp
+++ b/WebCore/storage/IDBCursor.cpp
@@ -87,10 +87,10 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionCode& ec)
ASSERT_NOT_REACHED();
}
-PassRefPtr<IDBRequest> IDBCursor::remove(ScriptExecutionContext* context, ExceptionCode& ec)
+PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionCode& ec)
{
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
- m_backend->remove(request, ec);
+ m_backend->deleteFunction(request, ec);
if (ec)
return 0;
return request.release();
diff --git a/WebCore/storage/IDBCursor.h b/WebCore/storage/IDBCursor.h
index 6f3a940..54bf51a 100644
--- a/WebCore/storage/IDBCursor.h
+++ b/WebCore/storage/IDBCursor.h
@@ -67,7 +67,7 @@ public:
PassRefPtr<IDBAny> value() const;
PassRefPtr<IDBRequest> update(ScriptExecutionContext*, PassRefPtr<SerializedScriptValue>, ExceptionCode&);
void continueFunction(PassRefPtr<IDBKey>, ExceptionCode&);
- PassRefPtr<IDBRequest> remove(ScriptExecutionContext*, ExceptionCode&);
+ PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&);
private:
explicit IDBCursor(PassRefPtr<IDBCursorBackendInterface>, IDBRequest*, IDBTransactionBackendInterface*);
diff --git a/WebCore/storage/IDBCursor.idl b/WebCore/storage/IDBCursor.idl
index 2d250d5..12d0baf 100644
--- a/WebCore/storage/IDBCursor.idl
+++ b/WebCore/storage/IDBCursor.idl
@@ -42,8 +42,7 @@ module storage {
// raises (IDBDatabaseException);
[ImplementationFunction=continueFunction] void continue(in [Optional] IDBKey key)
raises (IDBDatabaseException);
- // FIXME: Implement.
- //[CallWith=ScriptExecutionContext] IDBRequest remove()
- // raises (IDBDatabaseException);
+ [CallWith=ScriptExecutionContext, ImplementationFunction=deleteFunction] IDBRequest delete()
+ raises (IDBDatabaseException);
};
}
diff --git a/WebCore/storage/IDBCursorBackendImpl.cpp b/WebCore/storage/IDBCursorBackendImpl.cpp
index 8d5c8a1..9b4e4f1 100644
--- a/WebCore/storage/IDBCursorBackendImpl.cpp
+++ b/WebCore/storage/IDBCursorBackendImpl.cpp
@@ -45,13 +45,14 @@
namespace WebCore {
-IDBCursorBackendImpl::IDBCursorBackendImpl(IDBSQLiteDatabase* database, PassRefPtr<IDBKeyRange> keyRange, IDBCursor::Direction direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface* transaction)
+IDBCursorBackendImpl::IDBCursorBackendImpl(IDBSQLiteDatabase* database, PassRefPtr<IDBKeyRange> keyRange, IDBCursor::Direction direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface* transaction, IDBObjectStoreBackendInterface* objectStore)
: m_database(database)
, m_keyRange(keyRange)
, m_direction(direction)
, m_query(query)
, m_isSerializedScriptValueCursor(isSerializedScriptValueCursor)
, m_transaction(transaction)
+ , m_objectStore(objectStore)
{
loadCurrentRow();
}
@@ -158,50 +159,34 @@ void IDBCursorBackendImpl::continueFunctionInternal(ScriptExecutionContext*, Pas
callbacks->onSuccess(cursor.get());
}
-void IDBCursorBackendImpl::remove(PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
+void IDBCursorBackendImpl::deleteFunction(PassRefPtr<IDBCallbacks> prpCallbacks, ExceptionCode& ec)
{
- RefPtr<IDBCursorBackendImpl> cursor = this;
- RefPtr<IDBCallbacks> callbacks = prpCallbacks;
- if (!m_transaction->scheduleTask(createCallbackTask(&IDBCursorBackendImpl::removeInternal, cursor, callbacks)))
+ if (!m_query || m_currentId == InvalidId || !m_isSerializedScriptValueCursor) {
ec = IDBDatabaseException::NOT_ALLOWED_ERR;
-}
-
-void IDBCursorBackendImpl::removeInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl> cursor, PassRefPtr<IDBCallbacks> callbacks)
-{
- // FIXME: This method doesn't update indexes. It's dangerous to call in its current state.
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Not implemented."));
- return;
-
- if (!cursor->m_query || cursor->m_currentId == InvalidId) {
- // FIXME: Use the proper error code when it's specced.
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Operation not possible."));
return;
}
- String sql = "DELETE FROM ObjectStoreData WHERE id = ?";
- SQLiteStatement deleteQuery(cursor->database(), sql);
-
- bool ok = deleteQuery.prepare() == SQLResultOk;
- ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
- deleteQuery.bindInt64(1, cursor->m_currentId);
- ok = deleteQuery.step() == SQLResultDone;
- ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
-
- cursor->m_currentId = InvalidId;
- cursor->m_currentSerializedScriptValue = 0;
- cursor->m_currentIDBKeyValue = 0;
- callbacks->onSuccess();
+ // FIXME: Check that the transaction is READ_WRITE
+ // if (m_transaction->mode() == IDBTransaction::READ_ONLY) {
+ // FIXME: We must return READ_ONLY_ERR here. Fix this when we update IDBDatabaseException to match the spec.
+ // ec = IDBDatabaseException::NOT_ALLOWED_ERR;
+ // return;
+ // }
+ RefPtr<IDBKey> key = m_currentIDBKeyValue ? m_currentIDBKeyValue : m_currentKey;
+ m_objectStore->deleteFunction(key.release(), prpCallbacks, m_transaction.get(), ec);
}
+
void IDBCursorBackendImpl::loadCurrentRow()
{
- // The column numbers depend on the query in IDBObjectStoreBackendImpl::openCursor.
+ // The column numbers depend on the query in IDBObjectStoreBackendImpl::openCursorInternal or
+ // IDBIndexBackendImpl::openCursorInternal.
m_currentId = m_query->getColumnInt64(0);
m_currentKey = IDBKey::fromQuery(*m_query, 1);
if (m_isSerializedScriptValueCursor)
m_currentSerializedScriptValue = SerializedScriptValue::createFromWire(m_query->getColumnText(4));
- else
- m_currentIDBKeyValue = IDBKey::fromQuery(*m_query, 4);
+
+ m_currentIDBKeyValue = IDBKey::fromQuery(*m_query, 5);
}
SQLiteDatabase& IDBCursorBackendImpl::database() const
diff --git a/WebCore/storage/IDBCursorBackendImpl.h b/WebCore/storage/IDBCursorBackendImpl.h
index b646f1c..e3a8995 100644
--- a/WebCore/storage/IDBCursorBackendImpl.h
+++ b/WebCore/storage/IDBCursorBackendImpl.h
@@ -40,7 +40,7 @@ namespace WebCore {
class IDBDatabaseBackendImpl;
class IDBIndexBackendImpl;
class IDBKeyRange;
-class IDBObjectStoreBackendImpl;
+class IDBObjectStoreBackendInterface;
class IDBSQLiteDatabase;
class IDBTransactionBackendInterface;
class SQLiteDatabase;
@@ -49,9 +49,9 @@ class SerializedScriptValue;
class IDBCursorBackendImpl : public IDBCursorBackendInterface {
public:
- static PassRefPtr<IDBCursorBackendImpl> create(IDBSQLiteDatabase* database, PassRefPtr<IDBKeyRange> keyRange, IDBCursor::Direction direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface* transaction)
+ static PassRefPtr<IDBCursorBackendImpl> create(IDBSQLiteDatabase* database, PassRefPtr<IDBKeyRange> keyRange, IDBCursor::Direction direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface* transaction, IDBObjectStoreBackendInterface* objectStore)
{
- return adoptRef(new IDBCursorBackendImpl(database, keyRange, direction, query, isSerializedScriptValueCursor, transaction));
+ return adoptRef(new IDBCursorBackendImpl(database, keyRange, direction, query, isSerializedScriptValueCursor, transaction, objectStore));
}
virtual ~IDBCursorBackendImpl();
@@ -60,17 +60,16 @@ public:
virtual PassRefPtr<IDBAny> value() const;
virtual void update(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
virtual void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
- virtual void remove(PassRefPtr<IDBCallbacks>, ExceptionCode&);
+ virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&);
private:
- IDBCursorBackendImpl(IDBSQLiteDatabase*, PassRefPtr<IDBKeyRange>, IDBCursor::Direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface*);
+ IDBCursorBackendImpl(IDBSQLiteDatabase*, PassRefPtr<IDBKeyRange>, IDBCursor::Direction, PassOwnPtr<SQLiteStatement> query, bool isSerializedScriptValueCursor, IDBTransactionBackendInterface*, IDBObjectStoreBackendInterface*);
void loadCurrentRow();
SQLiteDatabase& database() const;
static void updateInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl>, PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>);
static void continueFunctionInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl>, PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>);
- static void removeInternal(ScriptExecutionContext*, PassRefPtr<IDBCursorBackendImpl>, PassRefPtr<IDBCallbacks>);
static const int64_t InvalidId = -1;
@@ -83,11 +82,13 @@ private:
int64_t m_currentId;
RefPtr<IDBKey> m_currentKey;
- // Only one of these will ever be used for each instance. Which depends on m_isSerializedScriptValueCursor.
+ // m_isSerializedScriptValueCursor will only be available for object cursors.
RefPtr<SerializedScriptValue> m_currentSerializedScriptValue;
+ // FIXME: make the primary key available via script for all types of cursors.
RefPtr<IDBKey> m_currentIDBKeyValue;
RefPtr<IDBTransactionBackendInterface> m_transaction;
+ RefPtr<IDBObjectStoreBackendInterface> m_objectStore;
};
} // namespace WebCore
diff --git a/WebCore/storage/IDBCursorBackendInterface.h b/WebCore/storage/IDBCursorBackendInterface.h
index e1ac274..0d132ca 100644
--- a/WebCore/storage/IDBCursorBackendInterface.h
+++ b/WebCore/storage/IDBCursorBackendInterface.h
@@ -51,7 +51,7 @@ public:
virtual void update(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>, ExceptionCode&) = 0;
virtual void continueFunction(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>, ExceptionCode&) = 0;
- virtual void remove(PassRefPtr<IDBCallbacks>, ExceptionCode&) = 0;
+ virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&) = 0;
};
} // namespace WebCore
diff --git a/WebCore/storage/IDBIndexBackendImpl.cpp b/WebCore/storage/IDBIndexBackendImpl.cpp
index 597a8c2..df88fdb 100644
--- a/WebCore/storage/IDBIndexBackendImpl.cpp
+++ b/WebCore/storage/IDBIndexBackendImpl.cpp
@@ -70,7 +70,7 @@ void IDBIndexBackendImpl::openCursorInternal(ScriptExecutionContext*, PassRefPtr
{
// Several files depend on this order of selects.
String sql = String("SELECT IndexData.id, IndexData.keyString, IndexData.keyDate, IndexData.keyNumber, ")
- + (objectCursor ? "ObjectStoreData.value " : "ObjectStoreData.keyString, ObjectStoreData.keyDate, ObjectStoreData.keyNumber ")
+ + ("ObjectStoreData.value, ObjectStoreData.keyString, ObjectStoreData.keyDate, ObjectStoreData.keyNumber ")
+ "FROM IndexData INNER JOIN ObjectStoreData ON IndexData.objectStoreDataId = ObjectStoreData.id WHERE ";
bool lowerBound = range && range->lower();
@@ -104,7 +104,11 @@ void IDBIndexBackendImpl::openCursorInternal(ScriptExecutionContext*, PassRefPtr
return;
}
- RefPtr<IDBCursorBackendInterface> cursor = IDBCursorBackendImpl::create(index->m_database.get(), range, direction, query.release(), objectCursor, transaction.get());
+ ExceptionCode ec = 0;
+ RefPtr<IDBObjectStoreBackendInterface> objectStore = transaction->objectStore(index->m_storeName, ec);
+ ASSERT(objectStore && !ec);
+
+ RefPtr<IDBCursorBackendInterface> cursor = IDBCursorBackendImpl::create(index->m_database.get(), range, direction, query.release(), objectCursor, transaction.get(), objectStore.get());
callbacks->onSuccess(cursor.release());
}
diff --git a/WebCore/storage/IDBKey.cpp b/WebCore/storage/IDBKey.cpp
index eb38d81..5f45543 100644
--- a/WebCore/storage/IDBKey.cpp
+++ b/WebCore/storage/IDBKey.cpp
@@ -44,6 +44,9 @@ IDBKey::~IDBKey()
PassRefPtr<IDBKey> IDBKey::fromQuery(SQLiteStatement& query, int baseColumn)
{
+ if (query.columnCount() <= baseColumn)
+ return 0;
+
if (!query.isColumnNull(baseColumn))
return IDBKey::createString(query.getColumnText(baseColumn));
diff --git a/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
index fb08e37..22d3b8d 100644
--- a/WebCore/storage/IDBObjectStoreBackendImpl.cpp
+++ b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
@@ -286,16 +286,35 @@ void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKey> prpKey, PassRe
void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks> callbacks)
{
- SQLiteStatement query(objectStore->sqliteDatabase(), "DELETE FROM ObjectStoreData " + whereClause(key.get()));
- bool ok = query.prepare() == SQLResultOk;
+ SQLiteStatement idQuery(objectStore->sqliteDatabase(), "SELECT id FROM ObjectStoreData " + whereClause(key.get()));
+ bool ok = idQuery.prepare() == SQLResultOk;
ASSERT_UNUSED(ok, ok); // FIXME: Better error handling?
-
- bindWhereClause(query, objectStore->id(), key.get());
- if (query.step() != SQLResultDone) {
+ bindWhereClause(idQuery, objectStore->id(), key.get());
+ if (idQuery.step() != SQLResultRow) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store."));
return;
}
+ int64_t id = idQuery.getColumnInt64(0);
+
+ SQLiteStatement osQuery(objectStore->sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE id = ?");
+ ok = osQuery.prepare() == SQLResultOk;
+ ASSERT_UNUSED(ok, ok); // FIXME: Better error handling?
+
+ osQuery.bindInt64(1, id);
+
+ ok = osQuery.step() == SQLResultDone;
+ ASSERT_UNUSED(ok, ok);
+
+ SQLiteStatement indexQuery(objectStore->sqliteDatabase(), "DELETE FROM IndexData WHERE objectStoreDataId = ?");
+ ok = indexQuery.prepare() == SQLResultOk;
+ ASSERT_UNUSED(ok, ok); // FIXME: Better error handling?
+
+ indexQuery.bindInt64(1, id);
+
+ ok = indexQuery.step() == SQLResultDone;
+ ASSERT_UNUSED(ok, ok);
+
callbacks->onSuccess();
}
@@ -436,7 +455,7 @@ void IDBObjectStoreBackendImpl::openCursorInternal(ScriptExecutionContext*, Pass
return;
}
- RefPtr<IDBCursorBackendInterface> cursor = IDBCursorBackendImpl::create(objectStore->m_database.get(), range, direction, query.release(), true, transaction.get());
+ RefPtr<IDBCursorBackendInterface> cursor = IDBCursorBackendImpl::create(objectStore->m_database.get(), range, direction, query.release(), true, transaction.get(), objectStore.get());
callbacks->onSuccess(cursor.release());
}
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 2b2ed68..ec97cbf 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,20 @@
+2010-12-20 Andrei Popescu <andreip at google.com>
+
+ Reviewed by Jeremy Orlow.
+
+ IDBCursor::delete is not implemented.
+ https://bugs.webkit.org/show_bug.cgi?id=51110
+
+ * public/WebIDBCursor.h:
+ (WebKit::WebIDBCursor::remove):
+ (WebKit::WebIDBCursor::deleteFunction):
+ * src/IDBCursorBackendProxy.cpp:
+ (WebCore::IDBCursorBackendProxy::deleteFunction):
+ * src/IDBCursorBackendProxy.h:
+ * src/WebIDBCursorImpl.cpp:
+ (WebKit::WebIDBCursorImpl::deleteFunction):
+ * src/WebIDBCursorImpl.h:
+
2010-12-18 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Laszlo Gombos.
diff --git a/WebKit/chromium/public/WebIDBCursor.h b/WebKit/chromium/public/WebIDBCursor.h
index 88b8b22..98b2b97 100644
--- a/WebKit/chromium/public/WebIDBCursor.h
+++ b/WebKit/chromium/public/WebIDBCursor.h
@@ -55,7 +55,9 @@ public:
virtual void update(const WebSerializedScriptValue&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
virtual void continueFunction(const WebIDBKey&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
- virtual void remove(WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
+ // FIXME: Remove after WK roll.
+ virtual void remove(WebIDBCallbacks* callbacks, WebExceptionCode& ec) { deleteFunction(callbacks, ec); }
+ virtual void deleteFunction(WebIDBCallbacks* callbacks, WebExceptionCode& ec) { remove(callbacks, ec); }
protected:
WebIDBCursor() { }
diff --git a/WebKit/chromium/src/IDBCursorBackendProxy.cpp b/WebKit/chromium/src/IDBCursorBackendProxy.cpp
index 94491f9..ec7bf63 100644
--- a/WebKit/chromium/src/IDBCursorBackendProxy.cpp
+++ b/WebKit/chromium/src/IDBCursorBackendProxy.cpp
@@ -85,9 +85,9 @@ void IDBCursorBackendProxy::continueFunction(PassRefPtr<IDBKey> key, PassRefPtr<
m_idbCursor->continueFunction(key, new WebIDBCallbacksImpl(callbacks), ec);
}
-void IDBCursorBackendProxy::remove(PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
+void IDBCursorBackendProxy::deleteFunction(PassRefPtr<IDBCallbacks> callbacks, ExceptionCode& ec)
{
- m_idbCursor->remove(new WebIDBCallbacksImpl(callbacks), ec);
+ m_idbCursor->deleteFunction(new WebIDBCallbacksImpl(callbacks), ec);
}
} // namespace WebCore
diff --git a/WebKit/chromium/src/IDBCursorBackendProxy.h b/WebKit/chromium/src/IDBCursorBackendProxy.h
index 0a7a288..650dded 100644
--- a/WebKit/chromium/src/IDBCursorBackendProxy.h
+++ b/WebKit/chromium/src/IDBCursorBackendProxy.h
@@ -47,7 +47,7 @@ public:
virtual PassRefPtr<IDBAny> value() const;
virtual void update(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
virtual void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBCallbacks>, ExceptionCode&);
- virtual void remove(PassRefPtr<IDBCallbacks>, ExceptionCode&);
+ virtual void deleteFunction(PassRefPtr<IDBCallbacks>, ExceptionCode&);
private:
IDBCursorBackendProxy(PassOwnPtr<WebKit::WebIDBCursor>);
diff --git a/WebKit/chromium/src/WebIDBCursorImpl.cpp b/WebKit/chromium/src/WebIDBCursorImpl.cpp
index eca5d42..5165574 100644
--- a/WebKit/chromium/src/WebIDBCursorImpl.cpp
+++ b/WebKit/chromium/src/WebIDBCursorImpl.cpp
@@ -80,9 +80,9 @@ void WebIDBCursorImpl::continueFunction(const WebIDBKey& key, WebIDBCallbacks* c
m_idbCursorBackend->continueFunction(key, IDBCallbacksProxy::create(callbacks), ec);
}
-void WebIDBCursorImpl::remove(WebIDBCallbacks* callbacks, WebExceptionCode& ec)
+void WebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, WebExceptionCode& ec)
{
- m_idbCursorBackend->remove(IDBCallbacksProxy::create(callbacks), ec);
+ m_idbCursorBackend->deleteFunction(IDBCallbacksProxy::create(callbacks), ec);
}
} // namespace WebCore
diff --git a/WebKit/chromium/src/WebIDBCursorImpl.h b/WebKit/chromium/src/WebIDBCursorImpl.h
index 39fa44b..7f8ebd7 100644
--- a/WebKit/chromium/src/WebIDBCursorImpl.h
+++ b/WebKit/chromium/src/WebIDBCursorImpl.h
@@ -47,7 +47,7 @@ public:
virtual void value(WebSerializedScriptValue&, WebIDBKey&) const;
virtual void update(const WebSerializedScriptValue&, WebIDBCallbacks*, WebExceptionCode&);
virtual void continueFunction(const WebIDBKey&, WebIDBCallbacks*, WebExceptionCode&);
- virtual void remove(WebIDBCallbacks*, WebExceptionCode&);
+ virtual void deleteFunction(WebIDBCallbacks*, WebExceptionCode&);
private:
WTF::RefPtr<WebCore::IDBCursorBackendInterface> m_idbCursorBackend;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list