⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 125730 in webkit


Ignore:
Timestamp:
Aug 15, 2012, 5:57:53 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

IndexedDB: IDB*::keyPath should return IDBKeyPath, not IDBAny
https://bugs.webkit.org/show_bug.cgi?id=92434

Patch by Alec Flett <alecflett@chromium.org> on 2012-08-15
Reviewed by Tony Chang.

Clean up IDBKeyPath conversion to IDBAny objects. This gets rid of
some implicit conversion from IDBKeyPath to IDBAny.

No new tests, just changing method signatures.

  • Modules/indexeddb/IDBAny.cpp:

(WebCore::IDBAny::set):
(WebCore):

  • Modules/indexeddb/IDBAny.h:

(WebCore):
(WebCore::IDBAny::create):
(IDBAny):

  • Modules/indexeddb/IDBIndex.h:

(WebCore::IDBIndex::keyPathAny):
(WebCore::IDBIndex::keyPath):

  • Modules/indexeddb/IDBIndex.idl:
  • Modules/indexeddb/IDBKeyPath.cpp:
  • Modules/indexeddb/IDBKeyPath.h:
  • Modules/indexeddb/IDBObjectStore.h:

(WebCore::IDBObjectStore::keyPathAny):
(WebCore::IDBObjectStore::keyPath):

  • Modules/indexeddb/IDBObjectStore.idl:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125729 r125730  
     12012-08-15  Alec Flett  <alecflett@chromium.org>
     2
     3        IndexedDB: IDB*::keyPath should return IDBKeyPath, not IDBAny
     4        https://bugs.webkit.org/show_bug.cgi?id=92434
     5
     6        Reviewed by Tony Chang.
     7
     8        Clean up IDBKeyPath conversion to IDBAny objects. This gets rid of
     9        some implicit conversion from IDBKeyPath to IDBAny.
     10
     11        No new tests, just changing method signatures.
     12
     13        * Modules/indexeddb/IDBAny.cpp:
     14        (WebCore::IDBAny::set):
     15        (WebCore):
     16        * Modules/indexeddb/IDBAny.h:
     17        (WebCore):
     18        (WebCore::IDBAny::create):
     19        (IDBAny):
     20        * Modules/indexeddb/IDBIndex.h:
     21        (WebCore::IDBIndex::keyPathAny):
     22        (WebCore::IDBIndex::keyPath):
     23        * Modules/indexeddb/IDBIndex.idl:
     24        * Modules/indexeddb/IDBKeyPath.cpp:
     25        * Modules/indexeddb/IDBKeyPath.h:
     26        * Modules/indexeddb/IDBObjectStore.h:
     27        (WebCore::IDBObjectStore::keyPathAny):
     28        (WebCore::IDBObjectStore::keyPath):
     29        * Modules/indexeddb/IDBObjectStore.idl:
     30
    1312012-08-15  Ryosuke Niwa  <rniwa@webkit.org>
    232
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp

    r117817 r125730  
    3333#include "IDBFactory.h"
    3434#include "IDBIndex.h"
     35#include "IDBKeyPath.h"
    3536#include "IDBObjectStore.h"
    3637#include "SerializedScriptValue.h"
     
    208209}
    209210
     211void IDBAny::set(const IDBKeyPath& value)
     212{
     213    ASSERT(m_type == UndefinedType);
     214    switch (value.type()) {
     215    case IDBKeyPath::NullType:
     216        m_type = NullType;
     217        break;
     218    case IDBKeyPath::StringType:
     219        m_type = StringType;
     220        m_string = value.string();
     221        break;
     222    case IDBKeyPath::ArrayType:
     223        RefPtr<DOMStringList> keyPaths = DOMStringList::create();
     224        for (Vector<String>::const_iterator it = value.array().begin(); it != value.array().end(); ++it)
     225            keyPaths->append(*it);
     226        m_type = DOMStringListType;
     227        m_domStringList = keyPaths.release();
     228        break;
     229    }
     230}
     231
    210232void IDBAny::set(const String& value)
    211233{
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.h

    r117817 r125730  
    4343class IDBIndex;
    4444class IDBKey;
     45class IDBKeyPath;
    4546class IDBObjectStore;
    4647class IDBTransaction;
     
    5758        RefPtr<IDBAny> any = IDBAny::createInvalid();
    5859        any->set(idbObject);
     60        return any.release();
     61    }
     62    static PassRefPtr<IDBAny> create(const IDBKeyPath& keyPath)
     63    {
     64        RefPtr<IDBAny> any = IDBAny::createInvalid();
     65        any->set(keyPath);
    5966        return any.release();
    6067    }
     
    110117    void set(PassRefPtr<IDBTransaction>);
    111118    void set(PassRefPtr<SerializedScriptValue>);
     119    void set(const IDBKeyPath&);
    112120    void set(const String&);
    113121
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h

    r121059 r125730  
    5454    const String name() const { return m_metadata.name; }
    5555    PassRefPtr<IDBObjectStore> objectStore() const { return m_objectStore; }
    56     PassRefPtr<IDBAny> keyPath() const { return m_metadata.keyPath; }
     56    PassRefPtr<IDBAny> keyPathAny() const { return IDBAny::create(m_metadata.keyPath); }
     57    const IDBKeyPath keyPath() const { return m_metadata.keyPath; }
    5758    bool unique() const { return m_metadata.unique; }
    5859    bool multiEntry() const { return m_metadata.multiEntry; }
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl

    r121714 r125730  
    3131        readonly attribute DOMString name;
    3232        readonly attribute IDBObjectStore objectStore;
    33         readonly attribute IDBAny keyPath;
     33        readonly attribute [ImplementedAs=keyPathAny] IDBAny keyPath;
    3434        readonly attribute boolean unique;
    3535        readonly attribute boolean multiEntry;
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp

    r123843 r125730  
    220220}
    221221
    222 IDBKeyPath::operator PassRefPtr<IDBAny>() const
    223 {
    224     switch (m_type) {
    225     case NullType:
    226         return IDBAny::createNull();
    227     case StringType:
    228         return IDBAny::createString(m_string);
    229     case ArrayType:
    230         RefPtr<DOMStringList> keyPaths = DOMStringList::create();
    231         for (Vector<String>::const_iterator it = m_array.begin(); it != m_array.end(); ++it)
    232         keyPaths->append(*it);
    233         return IDBAny::create(static_cast<PassRefPtr<DOMStringList> >(keyPaths));
    234     }
    235     ASSERT_NOT_REACHED();
    236     return 0;
    237 }
    238 
    239 bool IDBKeyPath::operator==(PassRefPtr<IDBAny> other) const
    240 {
    241     if (!isValid())
    242         return false;
    243 
    244     switch (m_type) {
    245     case NullType:
    246         return other->type() == IDBAny::NullType;
    247     case StringType:
    248         return other->type() == IDBAny::StringType && other->string() == string();
    249     case ArrayType:
    250         if (other->type() != IDBAny::DOMStringListType)
    251             return false;
    252 
    253         RefPtr<DOMStringList> otherList = other->domStringList();
    254         for (size_t i = 0; i < m_array.size(); ++i) {
    255             if (otherList->item(i) != m_array[i])
    256                 return false;
    257         }
    258         return true;
    259     }
    260     ASSERT_NOT_REACHED();
    261     return false;
    262 }
    263 
    264222bool IDBKeyPath::operator==(const IDBKeyPath& other) const
    265223{
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h

    r123843 r125730  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include "IDBAny.h"
    3231#include "PlatformString.h"
    3332#include <wtf/Vector.h>
     
    7271    bool isNull() const { return m_type == NullType; }
    7372    bool isValid() const;
    74     operator PassRefPtr<IDBAny>() const;
    75     bool operator==(PassRefPtr<IDBAny> other) const;
    7673    bool operator==(const IDBKeyPath& other) const;
    7774
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h

    r125728 r125730  
    5959    // Implement the IDBObjectStore IDL
    6060    const String name() const { return m_metadata.name; }
    61     PassRefPtr<IDBAny> keyPath() const { return m_metadata.keyPath; }
     61    PassRefPtr<IDBAny> keyPathAny() const { return IDBAny::create(m_metadata.keyPath); }
     62    const IDBKeyPath keyPath() const { return m_metadata.keyPath; }
    6263    PassRefPtr<DOMStringList> indexNames() const;
    6364    PassRefPtr<IDBTransaction> transaction() const { return m_transaction; }
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl

    r125728 r125730  
    3030    ] IDBObjectStore {
    3131        readonly attribute [TreatReturnedNullStringAs=Null] DOMString name;
    32         readonly attribute IDBAny keyPath;
     32        readonly attribute [ImplementedAs=keyPathAny] IDBAny keyPath;
    3333        readonly attribute DOMStringList indexNames;
    3434        readonly attribute IDBTransaction transaction;
Note: See TracChangeset for help on using the changeset viewer.