<!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>[192847] 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/192847">192847</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-11-30 17:28:15 -0800 (Mon, 30 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modern IDB: &quot;prevunique&quot; cursors should point at the lowest primary key that matches, not the highest.
https://bugs.webkit.org/show_bug.cgi?id=151675.

Reviewed by Darin Adler.

Source/WebCore:

No new tests (Covered by at least one failing test that now passes, and updates to previously incorrect tests).

* Modules/indexeddb/server/IndexValueEntry.cpp:
(WebCore::IDBServer::IndexValueEntry::reverseBegin): If CursorDuplicity is NoDuplicates, start at the lowest
  entry instead of the highest.
(WebCore::IDBServer::IndexValueEntry::reverseFind):
* Modules/indexeddb/server/IndexValueEntry.h:

* Modules/indexeddb/server/IndexValueStore.cpp:
(WebCore::IDBServer::IndexValueStore::reverseFind):
(WebCore::IDBServer::IndexValueStore::Iterator::Iterator):
(WebCore::IDBServer::IndexValueStore::Iterator::nextIndexEntry):
* Modules/indexeddb/server/IndexValueStore.h:

* Modules/indexeddb/server/MemoryIndexCursor.cpp:
(WebCore::IDBServer::MemoryIndexCursor::MemoryIndexCursor):
(WebCore::IDBServer::MemoryIndexCursor::iterate):

* Modules/indexeddb/shared/IDBCursorInfo.cpp:
(WebCore::IDBCursorInfo::duplicity):
(WebCore::IDBCursorInfo::isDirectionNoDuplicate): Deleted.
* Modules/indexeddb/shared/IDBCursorInfo.h:

LayoutTests:

* platform/mac-wk1/TestExpectations:
* storage/indexeddb/modern/index-cursor-1-expected.txt:
* storage/indexeddb/modern/index-cursor-2-expected.txt:
* storage/indexeddb/modern/index-cursor-3-expected.txt:</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="#trunkLayoutTestsstorageindexeddbmodernindexcursor1expectedtxt">trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernindexcursor2expectedtxt">trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernindexcursor3expectedtxt">trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIndexValueEntrycpp">trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIndexValueEntryh">trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIndexValueStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIndexValueStoreh">trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIndexCursorcpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedIDBCursorInfocpp">trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbsharedIDBCursorInfoh">trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/ChangeLog        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-11-30  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: &quot;prevunique&quot; cursors should point at the lowest primary key that matches, not the highest.
+        https://bugs.webkit.org/show_bug.cgi?id=151675.
+
+        Reviewed by Darin Adler.
+
+        * platform/mac-wk1/TestExpectations:
+        * storage/indexeddb/modern/index-cursor-1-expected.txt:
+        * storage/indexeddb/modern/index-cursor-2-expected.txt:
+        * storage/indexeddb/modern/index-cursor-3-expected.txt:
+
</ins><span class="cx"> 2015-11-30  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Null dereference loading Blink layout test http/tests/misc/detach-during-notifyDone.html
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx"> storage/indexeddb/mozilla/delete-result.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/event-source.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/global-data.html [ Pass ]
</span><ins>+storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Pass ]
</ins><span class="cx"> storage/indexeddb/mozilla/key-requirements-delete-null-key.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/key-requirements-inline-and-passed.html [ Pass ]
</span><span class="cx"> storage/indexeddb/mozilla/key-requirements-put-no-key.html [ Pass ]
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernindexcursor1expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-1-expected.txt        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -356,25 +356,25 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: D
</span><del>-Cursor primary key is: 12
</del><ins>+Cursor primary key is: 10
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: C
</span><del>-Cursor primary key is: 9
</del><ins>+Cursor primary key is: 7
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: B
</span><del>-Cursor primary key is: 6
</del><ins>+Cursor primary key is: 4
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: A
</span><del>-Cursor primary key is: 3
</del><ins>+Cursor primary key is: 1
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> 
</span><span class="cx"> Starting a new cursor: testCursorDirection(index2, 'prevunique')
</span><span class="lines">@@ -382,25 +382,25 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex2
</span><span class="cx"> Cursor key is: d
</span><del>-Cursor primary key is: 12
</del><ins>+Cursor primary key is: 10
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex2
</span><span class="cx"> Cursor key is: c
</span><del>-Cursor primary key is: 9
</del><ins>+Cursor primary key is: 7
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex2
</span><span class="cx"> Cursor key is: b
</span><del>-Cursor primary key is: 6
</del><ins>+Cursor primary key is: 4
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex2
</span><span class="cx"> Cursor key is: a
</span><del>-Cursor primary key is: 3
</del><ins>+Cursor primary key is: 1
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Done
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernindexcursor2expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-2-expected.txt        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: C
</span><del>-Cursor primary key is: 9
</del><ins>+Cursor primary key is: 7
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> 
</span><span class="cx"> Starting a new cursor: testCursorDirection('next', IDBKeyRange.bound('B', 'C'))
</span><span class="lines">@@ -153,13 +153,13 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: C
</span><del>-Cursor primary key is: 9
</del><ins>+Cursor primary key is: 7
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: B
</span><del>-Cursor primary key is: 6
</del><ins>+Cursor primary key is: 4
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> 
</span><span class="cx"> Starting a new cursor: testCursorDirection('next', IDBKeyRange.upperBound('B'))
</span><span class="lines">@@ -257,13 +257,13 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: B
</span><del>-Cursor primary key is: 6
</del><ins>+Cursor primary key is: 4
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: A
</span><del>-Cursor primary key is: 3
</del><ins>+Cursor primary key is: 1
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> 
</span><span class="cx"> Starting a new cursor: testCursorDirection('next', IDBKeyRange.lowerBound('C'))
</span><span class="lines">@@ -361,13 +361,13 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: D
</span><del>-Cursor primary key is: 12
</del><ins>+Cursor primary key is: 10
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: C
</span><del>-Cursor primary key is: 9
</del><ins>+Cursor primary key is: 7
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> 
</span><span class="cx"> Starting a new cursor: testCursorDirection('next', IDBKeyRange.only('B'))
</span><span class="lines">@@ -423,7 +423,7 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: B
</span><del>-Cursor primary key is: 6
</del><ins>+Cursor primary key is: 4
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Done
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernindexcursor3expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/LayoutTests/storage/indexeddb/modern/index-cursor-3-expected.txt        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -240,35 +240,26 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: I
</span><del>-Cursor primary key is: 18
</del><ins>+Cursor primary key is: 17
</ins><span class="cx"> Cursor value is: [object Object]
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: H
</span><del>-Cursor primary key is: 16
</del><ins>+Cursor primary key is: 15
</ins><span class="cx"> Cursor value is: [object Object]
</span><del>-Deleted key 16 from object store
</del><span class="cx"> Deleted key 15 from object store
</span><span class="cx"> Deleted key 14 from object store
</span><del>-Success opening or iterating cursor
-Cursor direction is: prevunique
-Cursor source is: TestIndex1
-Cursor key is: G
-Cursor primary key is: 13
-Cursor value is: [object Object]
</del><span class="cx"> Deleted key 13 from object store
</span><del>-Deleted key 12 from object store
-Deleted key 11 from object store
</del><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><del>-Cursor key is: E
-Cursor primary key is: 10
</del><ins>+Cursor key is: F
+Cursor primary key is: 11
</ins><span class="cx"> Cursor value is: [object Object]
</span><ins>+Deleted key 11 from object store
</ins><span class="cx"> Deleted key 10 from object store
</span><span class="cx"> Deleted key 9 from object store
</span><del>-Deleted key 8 from object store
</del><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="lines">@@ -282,17 +273,10 @@
</span><span class="cx"> Cursor direction is: prevunique
</span><span class="cx"> Cursor source is: TestIndex1
</span><span class="cx"> Cursor key is: B
</span><del>-Cursor primary key is: 4
</del><ins>+Cursor primary key is: 3
</ins><span class="cx"> Cursor value is: [object Object]
</span><del>-Deleted key 4 from object store
</del><span class="cx"> Deleted key 3 from object store
</span><span class="cx"> Deleted key 2 from object store
</span><del>-Success opening or iterating cursor
-Cursor direction is: prevunique
-Cursor source is: TestIndex1
-Cursor key is: A
-Cursor primary key is: 1
-Cursor value is: [object Object]
</del><span class="cx"> Deleted key 1 from object store
</span><span class="cx"> Success opening or iterating cursor
</span><span class="cx"> Done
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/ChangeLog        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-11-30  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: &quot;prevunique&quot; cursors should point at the lowest primary key that matches, not the highest.
+        https://bugs.webkit.org/show_bug.cgi?id=151675.
+
+        Reviewed by Darin Adler.
+
+        No new tests (Covered by at least one failing test that now passes, and updates to previously incorrect tests).
+
+        * Modules/indexeddb/server/IndexValueEntry.cpp:
+        (WebCore::IDBServer::IndexValueEntry::reverseBegin): If CursorDuplicity is NoDuplicates, start at the lowest
+          entry instead of the highest.
+        (WebCore::IDBServer::IndexValueEntry::reverseFind):
+        * Modules/indexeddb/server/IndexValueEntry.h:
+        
+        * Modules/indexeddb/server/IndexValueStore.cpp:
+        (WebCore::IDBServer::IndexValueStore::reverseFind):
+        (WebCore::IDBServer::IndexValueStore::Iterator::Iterator):
+        (WebCore::IDBServer::IndexValueStore::Iterator::nextIndexEntry):
+        * Modules/indexeddb/server/IndexValueStore.h:
+        
+        * Modules/indexeddb/server/MemoryIndexCursor.cpp:
+        (WebCore::IDBServer::MemoryIndexCursor::MemoryIndexCursor):
+        (WebCore::IDBServer::MemoryIndexCursor::iterate):
+        
+        * Modules/indexeddb/shared/IDBCursorInfo.cpp:
+        (WebCore::IDBCursorInfo::duplicity):
+        (WebCore::IDBCursorInfo::isDirectionNoDuplicate): Deleted.
+        * Modules/indexeddb/shared/IDBCursorInfo.h:
+
</ins><span class="cx"> 2015-11-30  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Null dereference loading Blink layout test http/tests/misc/detach-during-notifyDone.html
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIndexValueEntrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.cpp        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -28,6 +28,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="cx"> 
</span><ins>+#include &quot;IDBCursorInfo.h&quot;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace IDBServer {
</span><span class="cx"> 
</span><span class="lines">@@ -176,7 +178,7 @@
</span><span class="cx">     return { *this, m_orderedKeys-&gt;begin() };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IndexValueEntry::Iterator IndexValueEntry::reverseBegin()
</del><ins>+IndexValueEntry::Iterator IndexValueEntry::reverseBegin(CursorDuplicity duplicity)
</ins><span class="cx"> {
</span><span class="cx">     if (m_unique) {
</span><span class="cx">         ASSERT(m_key);
</span><span class="lines">@@ -184,7 +186,13 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_orderedKeys);
</span><del>-    return { *this, m_orderedKeys-&gt;rbegin() };
</del><ins>+
+    if (duplicity == CursorDuplicity::Duplicates)
+        return { *this, m_orderedKeys-&gt;rbegin() };
+
+    auto iterator = m_orderedKeys-&gt;rend();
+    --iterator;
+    return { *this, iterator };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IndexValueEntry::Iterator IndexValueEntry::find(const IDBKeyData&amp; key)
</span><span class="lines">@@ -202,7 +210,7 @@
</span><span class="cx">     return { *this, iterator };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IndexValueEntry::Iterator IndexValueEntry::reverseFind(const IDBKeyData&amp; key)
</del><ins>+IndexValueEntry::Iterator IndexValueEntry::reverseFind(const IDBKeyData&amp; key, CursorDuplicity)
</ins><span class="cx"> {
</span><span class="cx">     if (m_unique) {
</span><span class="cx">         ASSERT(m_key);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIndexValueEntryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueEntry.h        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx"> 
</span><span class="cx"> class ThreadSafeDataBuffer;
</span><span class="cx"> 
</span><ins>+enum class CursorDuplicity;
+
</ins><span class="cx"> namespace IDBServer {
</span><span class="cx"> 
</span><span class="cx"> class IndexValueEntry {
</span><span class="lines">@@ -77,12 +79,12 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     Iterator begin();
</span><del>-    Iterator reverseBegin();
</del><ins>+    Iterator reverseBegin(CursorDuplicity);
</ins><span class="cx"> 
</span><span class="cx">     // Finds the key, or the next higher record after the key.
</span><span class="cx">     Iterator find(const IDBKeyData&amp;);
</span><span class="cx">     // Finds the key, or the next lowest record before the key.
</span><del>-    Iterator reverseFind(const IDBKeyData&amp;);
</del><ins>+    Iterator reverseFind(const IDBKeyData&amp;, CursorDuplicity);
</ins><span class="cx"> 
</span><span class="cx">     bool unique() const { return m_unique; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIndexValueStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.cpp        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">     return { *this, iterator, primaryIterator };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData&amp; key, bool open)
</del><ins>+IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData&amp; key, CursorDuplicity duplicity, bool open)
</ins><span class="cx"> {
</span><span class="cx">     IDBKeyRangeData range;
</span><span class="cx">     if (!key.isNull())
</span><span class="lines">@@ -247,12 +247,12 @@
</span><span class="cx">     auto record = m_records.get(*iterator);
</span><span class="cx">     ASSERT(record);
</span><span class="cx"> 
</span><del>-    auto primaryIterator = record-&gt;reverseBegin();
</del><ins>+    auto primaryIterator = record-&gt;reverseBegin(duplicity);
</ins><span class="cx">     ASSERT(primaryIterator.isValid());
</span><del>-    return { *this, iterator, primaryIterator };
</del><ins>+    return { *this, duplicity, iterator, primaryIterator };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData&amp; key, const IDBKeyData&amp; primaryKey)
</del><ins>+IndexValueStore::Iterator IndexValueStore::reverseFind(const IDBKeyData&amp; key, const IDBKeyData&amp; primaryKey, CursorDuplicity duplicity)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!key.isNull());
</span><span class="cx">     ASSERT(!primaryKey.isNull());
</span><span class="lines">@@ -268,9 +268,9 @@
</span><span class="cx">     auto record = m_records.get(*iterator);
</span><span class="cx">     ASSERT(record);
</span><span class="cx"> 
</span><del>-    auto primaryIterator = record-&gt;reverseFind(primaryKey);
</del><ins>+    auto primaryIterator = record-&gt;reverseFind(primaryKey, duplicity);
</ins><span class="cx">     if (primaryIterator.isValid())
</span><del>-        return { *this, iterator, primaryIterator };
</del><ins>+        return { *this, duplicity, iterator, primaryIterator };
</ins><span class="cx"> 
</span><span class="cx">     // If we didn't find a primary key iterator in this entry,
</span><span class="cx">     // we need to move on to start of the next record.
</span><span class="lines">@@ -281,10 +281,10 @@
</span><span class="cx">     record = m_records.get(*iterator);
</span><span class="cx">     ASSERT(record);
</span><span class="cx"> 
</span><del>-    primaryIterator = record-&gt;reverseBegin();
</del><ins>+    primaryIterator = record-&gt;reverseBegin(duplicity);
</ins><span class="cx">     ASSERT(primaryIterator.isValid());
</span><span class="cx"> 
</span><del>-    return { *this, iterator, primaryIterator };
</del><ins>+    return { *this, duplicity, iterator, primaryIterator };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -295,9 +295,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IndexValueStore::Iterator::Iterator(IndexValueStore&amp; store, std::set&lt;IDBKeyData&gt;::reverse_iterator iterator, IndexValueEntry::Iterator primaryIterator)
</del><ins>+IndexValueStore::Iterator::Iterator(IndexValueStore&amp; store, CursorDuplicity duplicity, std::set&lt;IDBKeyData&gt;::reverse_iterator iterator, IndexValueEntry::Iterator primaryIterator)
</ins><span class="cx">     : m_store(&amp;store)
</span><span class="cx">     , m_forward(false)
</span><ins>+    , m_duplicity(duplicity)
</ins><span class="cx">     , m_reverseIterator(iterator)
</span><span class="cx">     , m_primaryKeyIterator(primaryIterator)
</span><span class="cx"> {
</span><span class="lines">@@ -330,7 +331,7 @@
</span><span class="cx">         auto* entry = m_store-&gt;m_records.get(*m_reverseIterator);
</span><span class="cx">         ASSERT(entry);
</span><span class="cx"> 
</span><del>-        m_primaryKeyIterator = entry-&gt;reverseBegin();
</del><ins>+        m_primaryKeyIterator = entry-&gt;reverseBegin(m_duplicity);
</ins><span class="cx">         ASSERT(m_primaryKeyIterator.isValid());
</span><span class="cx">     }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIndexValueStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IndexValueStore.h        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="cx"> 
</span><ins>+#include &quot;IDBCursorInfo.h&quot;
</ins><span class="cx"> #include &quot;IDBKeyData.h&quot;
</span><span class="cx"> #include &quot;IndexValueEntry.h&quot;
</span><span class="cx"> #include &lt;set&gt;
</span><span class="lines">@@ -67,7 +68,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         Iterator(IndexValueStore&amp;, std::set&lt;IDBKeyData&gt;::iterator, IndexValueEntry::Iterator);
</span><del>-        Iterator(IndexValueStore&amp;, std::set&lt;IDBKeyData&gt;::reverse_iterator, IndexValueEntry::Iterator);
</del><ins>+        Iterator(IndexValueStore&amp;, CursorDuplicity, std::set&lt;IDBKeyData&gt;::reverse_iterator, IndexValueEntry::Iterator);
</ins><span class="cx"> 
</span><span class="cx">         void invalidate();
</span><span class="cx">         bool isValid();
</span><span class="lines">@@ -82,6 +83,7 @@
</span><span class="cx">     private:
</span><span class="cx">         IndexValueStore* m_store { nullptr };
</span><span class="cx">         bool m_forward { true };
</span><ins>+        CursorDuplicity m_duplicity { CursorDuplicity::Duplicates };
</ins><span class="cx">         std::set&lt;IDBKeyData&gt;::iterator m_forwardIterator;
</span><span class="cx">         std::set&lt;IDBKeyData&gt;::reverse_iterator m_reverseIterator;
</span><span class="cx"> 
</span><span class="lines">@@ -90,11 +92,11 @@
</span><span class="cx"> 
</span><span class="cx">     // Returns an iterator pointing to the first primaryKey record in the requested key, or the next key if it doesn't exist.
</span><span class="cx">     Iterator find(const IDBKeyData&amp;, bool open = false);
</span><del>-    Iterator reverseFind(const IDBKeyData&amp;, bool open = false);
</del><ins>+    Iterator reverseFind(const IDBKeyData&amp;, CursorDuplicity, bool open = false);
</ins><span class="cx"> 
</span><span class="cx">     // Returns an iterator pointing to the key/primaryKey record, or the next one after it if it doesn't exist.
</span><span class="cx">     Iterator find(const IDBKeyData&amp;, const IDBKeyData&amp; primaryKey);
</span><del>-    Iterator reverseFind(const IDBKeyData&amp;, const IDBKeyData&amp; primaryKey);
</del><ins>+    Iterator reverseFind(const IDBKeyData&amp;, const IDBKeyData&amp; primaryKey, CursorDuplicity);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     std::set&lt;IDBKeyData&gt;::iterator lowestIteratorInRange(const IDBKeyRangeData&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIndexCursorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">     if (m_info.isDirectionForward())
</span><span class="cx">         iterator = valueStore-&gt;find(m_info.range().lowerKey, m_info.range().lowerOpen);
</span><span class="cx">     else
</span><del>-        iterator = valueStore-&gt;reverseFind(m_info.range().upperKey, m_info.range().upperOpen);
</del><ins>+        iterator = valueStore-&gt;reverseFind(m_info.range().upperKey, m_info.duplicity(), m_info.range().upperOpen);
</ins><span class="cx"> 
</span><span class="cx">     if (iterator.isValid()) {
</span><span class="cx">         m_currentKey = iterator.key();
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">         if (m_info.isDirectionForward())
</span><span class="cx">             m_currentIterator = valueStore-&gt;find(m_currentKey);
</span><span class="cx">         else
</span><del>-            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey);
</del><ins>+            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey, m_info.duplicity());
</ins><span class="cx"> 
</span><span class="cx">         if (!m_currentIterator.isValid()) {
</span><span class="cx">             m_currentKey = { };
</span><span class="lines">@@ -130,10 +130,10 @@
</span><span class="cx">             m_currentIterator = valueStore-&gt;find(m_currentKey, true);
</span><span class="cx">             break;
</span><span class="cx">         case IndexedDB::CursorDirection::Prev:
</span><del>-            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey, m_currentPrimaryKey);
</del><ins>+            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey, m_currentPrimaryKey, m_info.duplicity());
</ins><span class="cx">             break;
</span><span class="cx">         case IndexedDB::CursorDirection::PrevNoDuplicate:
</span><del>-            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey, true);
</del><ins>+            m_currentIterator = valueStore-&gt;reverseFind(m_currentKey, m_info.duplicity(), true);
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx">     ASSERT(m_currentIterator.isValid());
</span><span class="cx"> 
</span><span class="cx">     while (count) {
</span><del>-        if (m_info.isDirectionNoDuplicate())
</del><ins>+        if (m_info.duplicity() == CursorDuplicity::NoDuplicates)
</ins><span class="cx">             m_currentIterator.nextIndexEntry();
</span><span class="cx">         else
</span><span class="cx">             ++m_currentIterator;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedIDBCursorInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -84,9 +84,9 @@
</span><span class="cx">     return m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::NextNoDuplicate;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool IDBCursorInfo::isDirectionNoDuplicate() const
</del><ins>+CursorDuplicity IDBCursorInfo::duplicity() const
</ins><span class="cx"> {
</span><del>-    return m_direction == IndexedDB::CursorDirection::NextNoDuplicate || m_direction == IndexedDB::CursorDirection::PrevNoDuplicate;
</del><ins>+    return m_direction == IndexedDB::CursorDirection::NextNoDuplicate || m_direction == IndexedDB::CursorDirection::PrevNoDuplicate ? CursorDuplicity::NoDuplicates : CursorDuplicity::Duplicates;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IDBCursorInfo IDBCursorInfo::isolatedCopy() const
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbsharedIDBCursorInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h (192846 => 192847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h        2015-12-01 01:05:13 UTC (rev 192846)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h        2015-12-01 01:28:15 UTC (rev 192847)
</span><span class="lines">@@ -45,6 +45,11 @@
</span><span class="cx"> 
</span><span class="cx"> struct IDBKeyRangeData;
</span><span class="cx"> 
</span><ins>+enum class CursorDuplicity {
+    Duplicates,
+    NoDuplicates,
+};
+
</ins><span class="cx"> class IDBCursorInfo {
</span><span class="cx"> public:
</span><span class="cx">     static IDBCursorInfo objectStoreCursor(IDBClient::IDBTransaction&amp;, uint64_t objectStoreIdentifier, const IDBKeyRangeData&amp;, IndexedDB::CursorDirection);
</span><span class="lines">@@ -60,7 +65,7 @@
</span><span class="cx">     const IDBKeyRangeData&amp; range() const { return m_range; }
</span><span class="cx"> 
</span><span class="cx">     bool isDirectionForward() const;
</span><del>-    bool isDirectionNoDuplicate() const;
</del><ins>+    CursorDuplicity duplicity() const;
</ins><span class="cx"> 
</span><span class="cx">     IDBCursorInfo isolatedCopy() const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>