Changeset 97168 in webkit


Ignore:
Timestamp:
Oct 11, 2011 12:22:14 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

IndexedDB: implement IDBFactory.cmp method
https://bugs.webkit.org/show_bug.cgi?id=62293

Patch by Joshua Bell <jsbell@chromium.org> on 2011-10-11
Reviewed by Tony Chang.

Source/WebCore:

  • storage/IDBFactory.cpp:

(WebCore::IDBFactory::cmp):

  • storage/IDBFactory.h:
  • storage/IDBFactory.idl:
  • storage/IDBKey.cpp:

(WebCore::IDBKey::compare):
(WebCore::IDBKey::isLessThan):
(WebCore::IDBKey::isEqual):

  • storage/IDBKey.h:

LayoutTests:

Check for IDBFactory.deleteDatabase (NYI) marked as FAIL. crbug.com/72002
Tests for array keys (NYI) marked as FAIL. crbug.com/99876
Tests for invalid key exception types marked as FAIL. crbug.com/98930

  • storage/indexeddb/factory-basics-expected.txt:
  • storage/indexeddb/factory-basics.html:
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r97166 r97168  
     12011-10-11  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: implement IDBFactory.cmp method
     4        https://bugs.webkit.org/show_bug.cgi?id=62293
     5
     6        Reviewed by Tony Chang.
     7
     8        Check for IDBFactory.deleteDatabase (NYI) marked as FAIL. crbug.com/72002
     9        Tests for array keys (NYI) marked as FAIL. crbug.com/99876
     10        Tests for invalid key exception types marked as FAIL. crbug.com/98930
     11
     12        * storage/indexeddb/factory-basics-expected.txt:
     13        * storage/indexeddb/factory-basics.html:
     14
    1152011-10-11  Dimitri Glazkov  <dglazkov@chromium.org>
    216
  • trunk/LayoutTests/storage/indexeddb/factory-basics-expected.txt

    r96054 r97168  
    66indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
    77PASS indexedDB == null is false
     8PASS typeof indexedDB.open === 'function' is true
     9PASS typeof indexedDB.cmp === 'function' is true
     10PASS typeof indexedDB.getDatabaseNames === 'function' is true
     11deleteDatabase API is not yet implemented, so this will fail:
     12FAIL typeof indexedDB.deleteDatabase === 'function' should be true. Was false.
    813indexedDB.getDatabaseNames()
    914databaseNames = event.target.result
  • trunk/LayoutTests/storage/indexeddb/factory-basics.html

    r96054 r97168  
    1515    layoutTestController.waitUntilDone();
    1616
    17 
    1817function test()
    1918{
    2019    indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
    2120    shouldBeFalse("indexedDB == null");
     21
     22    shouldBeTrue("typeof indexedDB.open === 'function'");
     23    shouldBeTrue("typeof indexedDB.cmp === 'function'");
     24    shouldBeTrue("typeof indexedDB.getDatabaseNames === 'function'");
     25
     26    debug("deleteDatabase API is not yet implemented, so this will fail:");
     27    shouldBeTrue("typeof indexedDB.deleteDatabase === 'function'");
    2228
    2329    name = 'storage/indexeddb/factory-basics';
     
    5662
    5763    // FIXME: test indexedDB.deleteDatabase(databaseName)
    58     // FIXME: test indexedDB.cmp(key1, key2)
     64
    5965    done();
    6066}
  • trunk/Source/WebCore/ChangeLog

    r97165 r97168  
     12011-10-11  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: implement IDBFactory.cmp method
     4        https://bugs.webkit.org/show_bug.cgi?id=62293
     5
     6        Reviewed by Tony Chang.
     7
     8        * storage/IDBFactory.cpp:
     9        (WebCore::IDBFactory::cmp):
     10        * storage/IDBFactory.h:
     11        * storage/IDBFactory.idl:
     12        * storage/IDBKey.cpp:
     13        (WebCore::IDBKey::compare):
     14        (WebCore::IDBKey::isLessThan):
     15        (WebCore::IDBKey::isEqual):
     16        * storage/IDBKey.h:
     17
    1182011-10-11  No'am Rosenthal  <noam.rosenthal@nokia.com>
    219
  • trunk/Source/WebCore/storage/IDBFactory.cpp

    r96054 r97168  
    4040#include "IDBDatabaseException.h"
    4141#include "IDBFactoryBackendInterface.h"
     42#include "IDBKey.h"
    4243#include "IDBKeyRange.h"
    4344#include "IDBRequest.h"
     
    9899}
    99100
     101short IDBFactory::cmp(PassRefPtr<IDBKey> first, PassRefPtr<IDBKey> second, ExceptionCode& ec)
     102{
     103    ASSERT(first);
     104    ASSERT(second);
     105
     106    if (first->type() == IDBKey::NullType || second->type() == IDBKey::NullType) {
     107        ec = IDBDatabaseException::DATA_ERR;
     108        return 0;
     109    }   
     110   
     111    return static_cast<short>(first->compare(second.get()));
     112}
     113
    100114} // namespace WebCore
    101115
  • trunk/Source/WebCore/storage/IDBFactory.h

    r96054 r97168  
    5959    PassRefPtr<IDBRequest> open(ScriptExecutionContext*, const String& name, ExceptionCode&);
    6060
     61    short cmp(PassRefPtr<IDBKey> first, PassRefPtr<IDBKey> second, ExceptionCode&);
     62
    6163private:
    6264    IDBFactory(IDBFactoryBackendInterface*);
  • trunk/Source/WebCore/storage/IDBFactory.idl

    r96054 r97168  
    3333        [CallWith=ScriptExecutionContext] IDBRequest open(in DOMString name)
    3434            raises (IDBDatabaseException);
     35
     36        short cmp(in IDBKey first, in IDBKey second)
     37            raises (IDBDatabaseException);
    3538    };
    3639
  • trunk/Source/WebCore/storage/IDBKey.cpp

    r95901 r97168  
    4040}
    4141
     42int IDBKey::compare(const IDBKey* other) const
     43{
     44    ASSERT(other);
     45    if (m_type != other->m_type)
     46        return m_type > other->m_type ? -1 : 1;
     47
     48    switch (m_type) {
     49    case StringType:
     50        return -codePointCompare(other->m_string, m_string);
     51    case DateType:
     52        return (m_date < other->m_date) ? -1 :
     53                (m_date > other->m_date) ? 1 : 0;
     54    case NumberType:
     55        return (m_number < other->m_number) ? -1 :
     56                (m_number > other-> m_number) ? 1 : 0;
     57    case NullType:
     58        return 0;
     59    }
     60
     61    ASSERT_NOT_REACHED();
     62    return 0;
     63}
     64
    4265bool IDBKey::isLessThan(const IDBKey* other) const
    4366{
    4467    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;
     68    return compare(other) == -1;
    6369}
    6470
    6571bool IDBKey::isEqual(const IDBKey* other) const
    6672{
    67     if (!other || other->m_type != m_type)
     73    if (!other)
    6874        return false;
    6975
    70     switch (m_type) {
    71     case StringType:
    72         return other->m_string == m_string;
    73     case DateType:
    74         return other->m_date == m_date;
    75     case NumberType:
    76         return other->m_number == m_number;
    77     case NullType:
    78         return true;
    79     }
    80 
    81     ASSERT_NOT_REACHED();
    82     return false;
     76    return !compare(other);
    8377}
    8478
  • trunk/Source/WebCore/storage/IDBKey.h

    r95901 r97168  
    9898    }
    9999
     100    int compare(const IDBKey* other) const;
    100101    bool isLessThan(const IDBKey* other) const;
    101102    bool isEqual(const IDBKey* other) const;
Note: See TracChangeset for help on using the changeset viewer.