Title: [163252] trunk/Source/WebKit2
Revision
163252
Author
[email protected]
Date
2014-02-01 17:58:16 -0800 (Sat, 01 Feb 2014)

Log Message

IDB: Implement IDBCursor.delete()
<rdar://problem/15944203> and https://bugs.webkit.org/show_bug.cgi?id=127882

Reviewed by Sam Weinig.

IDBCursor.delete() actually relies on deleteRange(), which was implemented earlier.
So the only thing keeping it from working was a "Cursors iterate past their end" bug,
causing the delete transaction to be aborted.

* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
(WebKit::SQLiteIDBCursor::advanceOnce): When the cursor does the final iteration,
  clear the previous values to indicate completion.

* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp:
(WebKit::SQLiteIDBTransaction::clearCursors): Noticed this opportunistic cleanup to
  iterate over unique_ptr<>s with an auto& instead of an auto.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (163251 => 163252)


--- trunk/Source/WebKit2/ChangeLog	2014-02-02 00:16:15 UTC (rev 163251)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-02 01:58:16 UTC (rev 163252)
@@ -1,3 +1,22 @@
+2014-02-01  Brady Eidson  <[email protected]>
+
+        IDB: Implement IDBCursor.delete()
+        <rdar://problem/15944203> and https://bugs.webkit.org/show_bug.cgi?id=127882
+
+        Reviewed by Sam Weinig.
+
+        IDBCursor.delete() actually relies on deleteRange(), which was implemented earlier.
+        So the only thing keeping it from working was a "Cursors iterate past their end" bug,
+        causing the delete transaction to be aborted.
+
+        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp:
+        (WebKit::SQLiteIDBCursor::advanceOnce): When the cursor does the final iteration,
+          clear the previous values to indicate completion.
+
+        * DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp:
+        (WebKit::SQLiteIDBTransaction::clearCursors): Noticed this opportunistic cleanup to
+          iterate over unique_ptr<>s with an auto& instead of an auto.
+
 2014-01-31  Enrica Casucci  <[email protected]>
 
         Text interaction assistant is not deleted when dismissing the keyboard on iPad.

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp (163251 => 163252)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp	2014-02-02 00:16:15 UTC (rev 163251)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp	2014-02-02 01:58:16 UTC (rev 163252)
@@ -257,6 +257,13 @@
     int result = m_statement->step();
     if (result == SQLResultDone) {
         m_completed = true;
+
+        // When a cursor reaches its end, that is indicated by having undefined keys/values
+        m_currentKey = IDBKeyData();
+        m_currentPrimaryKey = IDBKeyData();
+        m_currentValueBuffer.clear();
+        m_currentValueKey = IDBKeyData();
+
         return true;
     }
 

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp (163251 => 163252)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp	2014-02-02 00:16:15 UTC (rev 163251)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp	2014-02-02 01:58:16 UTC (rev 163252)
@@ -124,9 +124,8 @@
 
 void SQLiteIDBTransaction::clearCursors()
 {
-    // Iterate over the keys instead of each key/value pair because std::unique_ptr<> can't be iterated over directly.
-    for (auto key : m_cursors.keys())
-        m_backingStore.unregisterCursor(m_cursors.get(key));
+    for (auto& cursor : m_cursors.values())
+        m_backingStore.unregisterCursor(cursor.get());
 
     m_cursors.clear();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to