Changeset 80308 in webkit


Ignore:
Timestamp:
Mar 3, 2011 6:18:45 PM (13 years ago)
Author:
jorlow@chromium.org
Message:

2011-03-02 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Steve Block.

Cursor.continue with a key param should test less than, not equal to
https://bugs.webkit.org/show_bug.cgi?id=55640

  • storage/indexeddb/cursor-continue-expected.txt: Added.
  • storage/indexeddb/cursor-continue.html: Added.

2011-03-02 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Steve Block.

Cursor.continue with a key param should test less than, not equal to
https://bugs.webkit.org/show_bug.cgi?id=55640

If you supply a param to cursor.continue, we sould guarantee that
the item we continue to is greater than or equal to the parameter.
Right now, we only test equality.

http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBCursor-continue
http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#dfn-steps-for-iterating-a-cursor

Test: storage/indexeddb/cursor-continue.html

  • storage/IDBCursorBackendImpl.cpp: (WebCore::IDBCursorBackendImpl::continueFunctionInternal):
  • storage/IDBKey.cpp: (WebCore::IDBKey::isLessThan): (WebCore::IDBKey::isEqual):
  • storage/IDBKey.h:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80293 r80308  
     12011-03-02  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Cursor.continue with a key param should test less than, not equal to
     6        https://bugs.webkit.org/show_bug.cgi?id=55640
     7
     8        * storage/indexeddb/cursor-continue-expected.txt: Added.
     9        * storage/indexeddb/cursor-continue.html: Added.
     10
    1112011-03-03  Mihai Parparita  <mihaip@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r80304 r80308  
     12011-03-02  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Cursor.continue with a key param should test less than, not equal to
     6        https://bugs.webkit.org/show_bug.cgi?id=55640
     7
     8        If you supply a param to cursor.continue, we sould guarantee that
     9        the item we continue to is greater than or equal to the parameter.
     10        Right now, we only test equality.
     11
     12        http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBCursor-continue
     13        http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#dfn-steps-for-iterating-a-cursor
     14
     15        Test: storage/indexeddb/cursor-continue.html
     16
     17        * storage/IDBCursorBackendImpl.cpp:
     18        (WebCore::IDBCursorBackendImpl::continueFunctionInternal):
     19        * storage/IDBKey.cpp:
     20        (WebCore::IDBKey::isLessThan):
     21        (WebCore::IDBKey::isEqual):
     22        * storage/IDBKey.h:
     23
    1242011-03-03  Brent Fulgham  <bfulgham@webkit.org>
    225
  • trunk/Source/WebCore/storage/IDBBackingStore.cpp

    r80265 r80308  
    669669class CursorImplCommon : public IDBBackingStore::Cursor {
    670670public:
    671     CursorImplCommon(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint)
     671    CursorImplCommon(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint, bool iterateForward)
    672672        : m_query(sqliteDatabase, query)
    673673        , m_db(sqliteDatabase)
    674674        , m_uniquenessConstraint(uniquenessConstraint)
     675        , m_iterateForward(iterateForward)
    675676    {
    676677    }
     
    693694    SQLiteDatabase& m_db;
    694695    bool m_uniquenessConstraint;
     696    bool m_iterateForward;
    695697    int64_t m_currentId;
    696698    RefPtr<IDBKey> m_currentKey;
     
    710712            continue;
    711713
    712         // If a key was supplied, we must loop until we find that key (or hit the end).
    713         if (key && !key->isEqual(m_currentKey.get()))
    714             continue;
     714        // If a key was supplied, we must loop until we find a key greater than or equal to it (or hit the end).
     715        if (key) {
     716            if (m_iterateForward) {
     717                if (m_currentKey->isLessThan(key))
     718                    continue;
     719            } else {
     720                if (key->isLessThan(m_currentKey.get()))
     721                    continue;
     722            }
     723        }
    715724
    716725        // If we don't have a uniqueness constraint, we can stop now.
     
    726735class ObjectStoreCursorImpl : public CursorImplCommon {
    727736public:
    728     ObjectStoreCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint)
    729         : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint)
     737    ObjectStoreCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint, bool iterateForward)
     738        : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint, iterateForward)
    730739    {
    731740    }
     
    763772class IndexKeyCursorImpl : public CursorImplCommon {
    764773public:
    765     IndexKeyCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint)
    766         : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint)
     774    IndexKeyCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint, bool iterateForward)
     775        : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint, iterateForward)
    767776    {
    768777    }
     
    801810class IndexCursorImpl : public CursorImplCommon {
    802811public:
    803     IndexCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint)
    804         : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint)
     812    IndexCursorImpl(SQLiteDatabase& sqliteDatabase, String query, bool uniquenessConstraint, bool iterateForward)
     813        : CursorImplCommon(sqliteDatabase, query, uniquenessConstraint, iterateForward)
    805814    {
    806815    }
     
    858867        sql += "keyString DESC, keyDate DESC, keyNumber DESC";
    859868
    860     RefPtr<ObjectStoreCursorImpl> cursor = adoptRef(new ObjectStoreCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE));
     869    RefPtr<ObjectStoreCursorImpl> cursor = adoptRef(new ObjectStoreCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE,
     870                                                                              direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT));
    861871
    862872    bool ok = cursor->m_query.prepare() == SQLResultOk;
     
    897907        sql += "IndexData.keyString DESC, IndexData.keyDate DESC, IndexData.keyNumber DESC, IndexData.id DESC";
    898908
    899     RefPtr<IndexKeyCursorImpl> cursor = adoptRef(new IndexKeyCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE));
     909    RefPtr<IndexKeyCursorImpl> cursor = adoptRef(new IndexKeyCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE,
     910                                                                        direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT));
    900911
    901912    bool ok = cursor->m_query.prepare() == SQLResultOk;
     
    936947        sql += "IndexData.keyString DESC, IndexData.keyDate DESC, IndexData.keyNumber DESC, IndexData.id DESC";
    937948
    938     RefPtr<IndexCursorImpl> cursor = adoptRef(new IndexCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE));
     949    RefPtr<IndexCursorImpl> cursor = adoptRef(new IndexCursorImpl(m_db, sql, direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::PREV_NO_DUPLICATE,
     950                                                                  direction == IDBCursor::NEXT_NO_DUPLICATE || direction == IDBCursor::NEXT));
    939951
    940952    bool ok = cursor->m_query.prepare() == SQLResultOk;
  • trunk/Source/WebCore/storage/IDBKey.cpp

    r80220 r80308  
    4040}
    4141
    42 bool IDBKey::isEqual(IDBKey* other) const
     42bool IDBKey::isLessThan(const IDBKey* other) const
     43{
     44    ASSERT(other);
     45    if (other->m_type < m_type)
     46        return true;
     47    if (other->m_type > m_type)
     48        return false;
     49
     50    switch (m_type) {
     51    case StringType:
     52        return codePointCompare(other->m_string, m_string) > 0;
     53    case DateType:
     54        return other->m_date > m_date;
     55    case NumberType:
     56        return other->m_number > m_number;
     57    case NullType:
     58        return true;
     59    }
     60
     61    ASSERT_NOT_REACHED();
     62    return false;
     63}
     64
     65bool IDBKey::isEqual(const IDBKey* other) const
    4366{
    4467    if (!other || other->m_type != m_type)
  • trunk/Source/WebCore/storage/IDBKey.h

    r80220 r80308  
    100100    }
    101101
    102     bool isEqual(IDBKey* other) const;
     102    bool isLessThan(const IDBKey* other) const;
     103    bool isEqual(const IDBKey* other) const;
    103104
    104105    using ThreadSafeShared<IDBKey>::ref;
Note: See TracChangeset for help on using the changeset viewer.