Changeset 207937 in webkit


Ignore:
Timestamp:
Oct 26, 2016 11:00:11 PM (7 years ago)
Author:
Chris Dumez
Message:

[Web IDL] Add support for having string enumerations in their own IDL file
https://bugs.webkit.org/show_bug.cgi?id=164025

Reviewed by Darin Adler.

Source/WebCore:

Add support for having string enumerations in their own IDL file to facilitate
sharing them. Use this new support to implement IDBTransactionMode enumeration
for IndexedDB:

No new tests, rebaselined existing tests.

  • CMakeLists.txt:
  • DerivedSources.cpp:
  • DerivedSources.make:
  • Modules/indexeddb/IDBDatabase.cpp:

(WebCore::IDBDatabase::transaction):
(WebCore::IDBDatabase::startVersionChangeTransaction):

  • Modules/indexeddb/IDBDatabase.h:
  • Modules/indexeddb/IDBDatabase.idl:
  • Modules/indexeddb/IDBOpenDBRequest.cpp:

(WebCore::IDBOpenDBRequest::onUpgradeNeeded):

  • Modules/indexeddb/IDBTransaction.cpp:

(WebCore::IDBTransaction::IDBTransaction):

  • Modules/indexeddb/IDBTransaction.h:

(WebCore::IDBTransaction::mode):
(WebCore::IDBTransaction::isVersionChange):
(WebCore::IDBTransaction::isReadOnly):

  • Modules/indexeddb/IDBTransaction.idl:
  • Modules/indexeddb/IDBTransactionMode.h: Added.
  • Modules/indexeddb/IDBTransactionMode.idl: Copied from Source/WebCore/Modules/indexeddb/IDBTransaction.idl.
  • Modules/indexeddb/IndexedDB.h:
  • Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:

(WebCore::IDBServer::MemoryBackingStoreTransaction::MemoryBackingStoreTransaction):
(WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreRenamed):
(WebCore::IDBServer::MemoryBackingStoreTransaction::indexRenamed):
(WebCore::IDBServer::MemoryBackingStoreTransaction::abort):

  • Modules/indexeddb/server/MemoryBackingStoreTransaction.h:

(WebCore::IDBServer::MemoryBackingStoreTransaction::isVersionChange):
(WebCore::IDBServer::MemoryBackingStoreTransaction::isWriting):

  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange):
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
(WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber):
(WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):

  • Modules/indexeddb/server/SQLiteIDBTransaction.cpp:

(WebCore::IDBServer::SQLiteIDBTransaction::begin):

  • Modules/indexeddb/server/SQLiteIDBTransaction.h:

(WebCore::IDBServer::SQLiteIDBTransaction::mode):

  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::enqueueTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::takeNextRunnableTransaction):

  • Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction):

  • Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseTransaction::UniqueIDBDatabaseTransaction):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::originalDatabaseInfo):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::isVersionChange):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::isReadOnly):

  • Modules/indexeddb/shared/IDBTransactionInfo.cpp:

(WebCore::IDBTransactionInfo::clientTransaction):
(WebCore::IDBTransactionInfo::versionChange):
(WebCore::IDBTransactionInfo::loggingString):

  • Modules/indexeddb/shared/IDBTransactionInfo.h:

(WebCore::IDBTransactionInfo::mode):

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/scripts/CodeGenerator.pm:

(ProcessDocument):
(IsEnumType):
(GetEnumByName):
(IsExternalEnumType):
(ValidEnumValues):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateEnumeration):
(AddToImplIncludesForIDLType):
(GetEnumerationClassName):
(GenerateEnumerationHeader):
(GenerateEnumerationImplementation):
(GenerateEnumerationImplementationContent):
(GenerateEnumerationsImplementationContent):
(GenerateEnumerationHeaderContent):
(GenerateEnumerationsHeaderContent):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionMethodWithEnumArgCaller):
(WebCore::jsTestObjPrototypeFunctionMethodWithStandaloneEnumArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithStandaloneEnumArgCaller):

  • bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Added.

(WebCore::convertEnumerationToJS):
(WebCore::parseEnumeration<TestStandaloneEnumeration>):
(WebCore::convertEnumeration<TestStandaloneEnumeration>):
(WebCore::expectedEnumerationValues<TestStandaloneEnumeration>):

  • bindings/scripts/test/JS/JSTestStandaloneEnumeration.h: Added.
  • bindings/scripts/test/TestObj.idl:
  • bindings/scripts/test/TestStandaloneEnumeration.idl: Copied from Source/WebCore/Modules/indexeddb/IDBTransaction.idl.
  • inspector/InspectorIndexedDBAgent.cpp:

LayoutTests:

Rebaseline existign tests as the exception messages differ slightly.

  • storage/indexeddb/exceptions-expected.txt:
  • storage/indexeddb/exceptions-private-expected.txt:
  • storage/indexeddb/modern/idbdatabase-transaction-failures-expected.txt:
  • storage/indexeddb/modern/idbdatabase-transaction-failures-private-expected.txt:
  • storage/indexeddb/transaction-basics-expected.txt:
  • storage/indexeddb/transaction-basics-private-expected.txt:
Location:
trunk
Files:
3 added
35 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207932 r207937  
     12016-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        [Web IDL] Add support for having string enumerations in their own IDL file
     4        https://bugs.webkit.org/show_bug.cgi?id=164025
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline existign tests as the exception messages differ slightly.
     9
     10        * storage/indexeddb/exceptions-expected.txt:
     11        * storage/indexeddb/exceptions-private-expected.txt:
     12        * storage/indexeddb/modern/idbdatabase-transaction-failures-expected.txt:
     13        * storage/indexeddb/modern/idbdatabase-transaction-failures-private-expected.txt:
     14        * storage/indexeddb/transaction-basics-expected.txt:
     15        * storage/indexeddb/transaction-basics-private-expected.txt:
     16
    1172016-10-26  Yusuke Suzuki  <utatane.tea@gmail.com>
    218
  • trunk/LayoutTests/storage/indexeddb/exceptions-expected.txt

    r195181 r207937  
    106106Expecting TypeError exception from db.transaction('store', 'invalid-mode')
    107107PASS Exception was thrown.
    108 PASS db.transaction('store', 'invalid-mode') threw TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('invalid-mode') is not one of 'readonly' or 'readwrite'.
     108PASS db.transaction('store', 'invalid-mode') threw TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
    109109The function was called with an empty list of store names
    110110Expecting exception from db.transaction([])
  • trunk/LayoutTests/storage/indexeddb/exceptions-private-expected.txt

    r195247 r207937  
    106106Expecting TypeError exception from db.transaction('store', 'invalid-mode')
    107107PASS Exception was thrown.
    108 PASS db.transaction('store', 'invalid-mode') threw TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('invalid-mode') is not one of 'readonly' or 'readwrite'.
     108PASS db.transaction('store', 'invalid-mode') threw TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
    109109The function was called with an empty list of store names
    110110Expecting exception from db.transaction([])
  • trunk/LayoutTests/storage/indexeddb/modern/idbdatabase-transaction-failures-expected.txt

    r203309 r207937  
    1313Failed to start a transaction with an empty set of object stores - InvalidAccessError (DOM IDBDatabase Exception 15): Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.
    1414Failed to start a transaction to a nonexistent object store - NotFoundError (DOM IDBDatabase Exception 8): Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
    15 Failed to start a transaction with an invalid mode - TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('blahblah') is not one of 'readonly' or 'readwrite'.
    16 Failed to explicitly start a versionchange transaction - TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('versionchange') is not one of 'readonly' or 'readwrite'.
     15Failed to start a transaction with an invalid mode - TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
     16Failed to explicitly start a versionchange transaction - TypeError: Type error
    1717Failed to explicitly start a transaction with the close pending flag set - InvalidStateError (DOM IDBDatabase Exception 11): Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
    1818PASS successfullyParsed is true
  • trunk/LayoutTests/storage/indexeddb/modern/idbdatabase-transaction-failures-private-expected.txt

    r203309 r207937  
    1313Failed to start a transaction with an empty set of object stores - InvalidAccessError (DOM IDBDatabase Exception 15): Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.
    1414Failed to start a transaction to a nonexistent object store - NotFoundError (DOM IDBDatabase Exception 8): Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
    15 Failed to start a transaction with an invalid mode - TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('blahblah') is not one of 'readonly' or 'readwrite'.
    16 Failed to explicitly start a versionchange transaction - TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('versionchange') is not one of 'readonly' or 'readwrite'.
     15Failed to start a transaction with an invalid mode - TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
     16Failed to explicitly start a versionchange transaction - TypeError: Type error
    1717Failed to explicitly start a transaction with the close pending flag set - InvalidStateError (DOM IDBDatabase Exception 11): Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
    1818PASS successfullyParsed is true
  • trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt

    r195181 r207937  
    230230Expecting TypeError exception from db.transaction(['storeName'], 'lsakjdf')
    231231PASS Exception was thrown.
    232 PASS db.transaction(['storeName'], 'lsakjdf') threw TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('lsakjdf') is not one of 'readonly' or 'readwrite'.
     232PASS db.transaction(['storeName'], 'lsakjdf') threw TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
    233233
    234234Test that null and undefined are treated as strings
  • trunk/LayoutTests/storage/indexeddb/transaction-basics-private-expected.txt

    r195247 r207937  
    230230Expecting TypeError exception from db.transaction(['storeName'], 'lsakjdf')
    231231PASS Exception was thrown.
    232 PASS db.transaction(['storeName'], 'lsakjdf') threw TypeError: Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('lsakjdf') is not one of 'readonly' or 'readwrite'.
     232PASS db.transaction(['storeName'], 'lsakjdf') threw TypeError: Argument 2 ('mode') to IDBDatabase.transaction must be one of: "readonly", "readwrite", "versionchange"
    233233
    234234Test that null and undefined are treated as strings
  • trunk/Source/WebCore/CMakeLists.txt

    r207903 r207937  
    200200    Modules/indexeddb/IDBRequest.idl
    201201    Modules/indexeddb/IDBTransaction.idl
     202    Modules/indexeddb/IDBTransactionMode.idl
    202203    Modules/indexeddb/IDBVersionChangeEvent.idl
    203204    Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.idl
  • trunk/Source/WebCore/ChangeLog

    r207933 r207937  
     12016-10-26  Chris Dumez  <cdumez@apple.com>
     2
     3        [Web IDL] Add support for having string enumerations in their own IDL file
     4        https://bugs.webkit.org/show_bug.cgi?id=164025
     5
     6        Reviewed by Darin Adler.
     7
     8        Add support for having string enumerations in their own IDL file to facilitate
     9        sharing them. Use this new support to implement IDBTransactionMode enumeration
     10        for IndexedDB:
     11        - https://www.w3.org/TR/IndexedDB/#idl-def-IDBTransactionMode
     12
     13        No new tests, rebaselined existing tests.
     14
     15        * CMakeLists.txt:
     16        * DerivedSources.cpp:
     17        * DerivedSources.make:
     18        * Modules/indexeddb/IDBDatabase.cpp:
     19        (WebCore::IDBDatabase::transaction):
     20        (WebCore::IDBDatabase::startVersionChangeTransaction):
     21        * Modules/indexeddb/IDBDatabase.h:
     22        * Modules/indexeddb/IDBDatabase.idl:
     23        * Modules/indexeddb/IDBOpenDBRequest.cpp:
     24        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
     25        * Modules/indexeddb/IDBTransaction.cpp:
     26        (WebCore::IDBTransaction::IDBTransaction):
     27        * Modules/indexeddb/IDBTransaction.h:
     28        (WebCore::IDBTransaction::mode):
     29        (WebCore::IDBTransaction::isVersionChange):
     30        (WebCore::IDBTransaction::isReadOnly):
     31        * Modules/indexeddb/IDBTransaction.idl:
     32        * Modules/indexeddb/IDBTransactionMode.h: Added.
     33        * Modules/indexeddb/IDBTransactionMode.idl: Copied from Source/WebCore/Modules/indexeddb/IDBTransaction.idl.
     34        * Modules/indexeddb/IndexedDB.h:
     35        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
     36        (WebCore::IDBServer::MemoryBackingStoreTransaction::MemoryBackingStoreTransaction):
     37        (WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreRenamed):
     38        (WebCore::IDBServer::MemoryBackingStoreTransaction::indexRenamed):
     39        (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
     40        * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
     41        (WebCore::IDBServer::MemoryBackingStoreTransaction::isVersionChange):
     42        (WebCore::IDBServer::MemoryBackingStoreTransaction::isWriting):
     43        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     44        (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
     45        (WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
     46        (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
     47        (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
     48        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
     49        (WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
     50        (WebCore::IDBServer::SQLiteIDBBackingStore::clearObjectStore):
     51        (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
     52        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex):
     53        (WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
     54        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRecord):
     55        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteRange):
     56        (WebCore::IDBServer::SQLiteIDBBackingStore::addRecord):
     57        (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
     58        (WebCore::IDBServer::SQLiteIDBBackingStore::revertGeneratedKeyNumber):
     59        (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):
     60        * Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
     61        (WebCore::IDBServer::SQLiteIDBTransaction::begin):
     62        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
     63        (WebCore::IDBServer::SQLiteIDBTransaction::mode):
     64        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     65        (WebCore::IDBServer::UniqueIDBDatabase::enqueueTransaction):
     66        (WebCore::IDBServer::UniqueIDBDatabase::takeNextRunnableTransaction):
     67        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
     68        (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction):
     69        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
     70        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::UniqueIDBDatabaseTransaction):
     71        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::originalDatabaseInfo):
     72        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::isVersionChange):
     73        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::isReadOnly):
     74        * Modules/indexeddb/shared/IDBTransactionInfo.cpp:
     75        (WebCore::IDBTransactionInfo::clientTransaction):
     76        (WebCore::IDBTransactionInfo::versionChange):
     77        (WebCore::IDBTransactionInfo::loggingString):
     78        * Modules/indexeddb/shared/IDBTransactionInfo.h:
     79        (WebCore::IDBTransactionInfo::mode):
     80        * WebCore.xcodeproj/project.pbxproj:
     81        * bindings/scripts/CodeGenerator.pm:
     82        (ProcessDocument):
     83        (IsEnumType):
     84        (GetEnumByName):
     85        (IsExternalEnumType):
     86        (ValidEnumValues):
     87        * bindings/scripts/CodeGeneratorJS.pm:
     88        (GenerateEnumeration):
     89        (AddToImplIncludesForIDLType):
     90        (GetEnumerationClassName):
     91        (GenerateEnumerationHeader):
     92        (GenerateEnumerationImplementation):
     93        (GenerateEnumerationImplementationContent):
     94        (GenerateEnumerationsImplementationContent):
     95        (GenerateEnumerationHeaderContent):
     96        (GenerateEnumerationsHeaderContent):
     97        * bindings/scripts/test/JS/JSTestObj.cpp:
     98        (WebCore::jsTestObjPrototypeFunctionMethodWithEnumArgCaller):
     99        (WebCore::jsTestObjPrototypeFunctionMethodWithStandaloneEnumArg):
     100        (WebCore::jsTestObjPrototypeFunctionMethodWithStandaloneEnumArgCaller):
     101        * bindings/scripts/test/JS/JSTestStandaloneEnumeration.cpp: Added.
     102        (WebCore::convertEnumerationToJS):
     103        (WebCore::parseEnumeration<TestStandaloneEnumeration>):
     104        (WebCore::convertEnumeration<TestStandaloneEnumeration>):
     105        (WebCore::expectedEnumerationValues<TestStandaloneEnumeration>):
     106        * bindings/scripts/test/JS/JSTestStandaloneEnumeration.h: Added.
     107        * bindings/scripts/test/TestObj.idl:
     108        * bindings/scripts/test/TestStandaloneEnumeration.idl: Copied from Source/WebCore/Modules/indexeddb/IDBTransaction.idl.
     109        * inspector/InspectorIndexedDBAgent.cpp:
     110
    11112016-10-26  Dan Bernstein  <mitz@apple.com>
    2112
  • trunk/Source/WebCore/DerivedSources.cpp

    r207772 r207937  
    309309#include "JSIDBRequest.cpp"
    310310#include "JSIDBTransaction.cpp"
     311#include "JSIDBTransactionMode.cpp"
    311312#include "JSIDBVersionChangeEvent.cpp"
    312313#endif
  • trunk/Source/WebCore/DerivedSources.make

    r207901 r207937  
    116116    $(WebCore)/Modules/indexeddb/IDBRequest.idl \
    117117    $(WebCore)/Modules/indexeddb/IDBTransaction.idl \
     118    $(WebCore)/Modules/indexeddb/IDBTransactionMode.idl \
    118119    $(WebCore)/Modules/indexeddb/IDBVersionChangeEvent.idl \
    119120    $(WebCore)/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.idl \
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r207847 r207937  
    161161}
    162162
    163 ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfStrings&& storeNames, const String& modeString)
     163ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode mode)
    164164{
    165165    LOG(IndexedDB, "IDBDatabase::transaction");
     
    179179        return Exception { IDBDatabaseException::InvalidAccessError, ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.") };
    180180
    181     auto mode = IDBTransaction::stringToMode(modeString);
    182     if (!mode)
    183         return Exception { TypeError, "Failed to execute 'transaction' on 'IDBDatabase': The mode provided ('" + modeString + "') is not one of 'readonly' or 'readwrite'." };
    184 
    185     if (mode.value() != IndexedDB::TransactionMode::ReadOnly && mode.value() != IndexedDB::TransactionMode::ReadWrite)
     181    if (mode != IDBTransactionMode::Readonly && mode != IDBTransactionMode::Readwrite)
    186182        return Exception { TypeError };
    187183
     
    195191    }
    196192
    197     auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy.get(), objectStores, mode.value());
     193    auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy.get(), objectStores, mode);
    198194    auto transaction = IDBTransaction::create(*this, info);
    199195
     
    327323    ASSERT(currentThread() == originThreadID());
    328324    ASSERT(!m_versionChangeTransaction);
    329     ASSERT(info.mode() == IndexedDB::TransactionMode::VersionChange);
     325    ASSERT(info.mode() == IDBTransactionMode::Versionchange);
    330326    ASSERT(!m_closePending);
    331327    ASSERT(scriptExecutionContext());
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h

    r207931 r207937  
    3636#include "IDBDatabaseInfo.h"
    3737#include "IDBKeyPath.h"
     38#include "IDBTransactionMode.h"
    3839
    3940namespace WebCore {
     
    6566
    6667    using StringOrVectorOfStrings = WTF::Variant<String, Vector<String>>;
    67     ExceptionOr<Ref<IDBTransaction>> transaction(StringOrVectorOfStrings&& storeNames, const String& mode);
     68    ExceptionOr<Ref<IDBTransaction>> transaction(StringOrVectorOfStrings&& storeNames, IDBTransactionMode);
    6869    ExceptionOr<void> deleteObjectStore(const String& name);
    6970    void close();
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl

    r207847 r207937  
    3838    [MayThrowException] void deleteObjectStore(DOMString name);
    3939
    40     // FIXME: mode parameter type should be a IDBTransactionMode string enumeration.
    41     [MayThrowException] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames, optional DOMString mode = "readonly");
     40    [MayThrowException] IDBTransaction transaction((DOMString or sequence<DOMString>) storeNames, optional IDBTransactionMode mode = "readonly");
    4241
    4342    // FIXME: This is not part of the spec, but is needed for compatibility.
    4443    // See https://github.com/w3c/IndexedDB/issues/85
    45     [MayThrowException] IDBTransaction transaction(DOMStringList storeNames, optional DOMString mode = "readonly");
     44    [MayThrowException] IDBTransaction transaction(DOMStringList storeNames, optional IDBTransactionMode mode = "readonly");
    4645    void close();
    4746
  • trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp

    r202105 r207937  
    149149    Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
    150150
    151     ASSERT(transaction->info().mode() == IndexedDB::TransactionMode::VersionChange);
     151    ASSERT(transaction->info().mode() == IDBTransactionMode::Versionchange);
    152152    ASSERT(transaction->originalDatabaseInfo());
    153153
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r207845 r207937  
    6060namespace WebCore {
    6161
    62 const AtomicString& IDBTransaction::modeReadOnly()
    63 {
    64     static NeverDestroyed<AtomicString> readonly("readonly", AtomicString::ConstructFromLiteral);
    65     return readonly;
    66 }
    67 
    68 const AtomicString& IDBTransaction::modeReadWrite()
    69 {
    70     static NeverDestroyed<AtomicString> readwrite("readwrite", AtomicString::ConstructFromLiteral);
    71     return readwrite;
    72 }
    73 
    74 const AtomicString& IDBTransaction::modeVersionChange()
    75 {
    76     static NeverDestroyed<AtomicString> versionchange("versionchange", AtomicString::ConstructFromLiteral);
    77     return versionchange;
    78 }
    79 
    80 const AtomicString& IDBTransaction::modeReadOnlyLegacy()
    81 {
    82     static NeverDestroyed<AtomicString> readonly("0", AtomicString::ConstructFromLiteral);
    83     return readonly;
    84 }
    85 
    86 const AtomicString& IDBTransaction::modeReadWriteLegacy()
    87 {
    88     static NeverDestroyed<AtomicString> readwrite("1", AtomicString::ConstructFromLiteral);
    89     return readwrite;
    90 }
    91 
    92 Optional<IndexedDB::TransactionMode> IDBTransaction::stringToMode(const String& modeString)
    93 {
    94     if (modeString.isNull() || modeString == IDBTransaction::modeReadOnly())
    95         return IndexedDB::TransactionMode::ReadOnly;
    96     if (modeString == IDBTransaction::modeReadWrite())
    97         return IndexedDB::TransactionMode::ReadWrite;
    98 
    99     return Nullopt;
    100 }
    101 
    102 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode)
    103 {
    104     switch (mode) {
    105     case IndexedDB::TransactionMode::ReadOnly:
    106         return IDBTransaction::modeReadOnly();
    107 
    108     case IndexedDB::TransactionMode::ReadWrite:
    109         return IDBTransaction::modeReadWrite();
    110 
    111     case IndexedDB::TransactionMode::VersionChange:
    112         return IDBTransaction::modeVersionChange();
    113     }
    114 
    115     ASSERT_NOT_REACHED();
    116     return IDBTransaction::modeReadOnly();
    117 }
    118 
    11962Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
    12063{
     
    13881    ASSERT(currentThread() == m_database->originThreadID());
    13982
    140     if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) {
     83    if (m_info.mode() == IDBTransactionMode::Versionchange) {
    14184        ASSERT(m_openDBRequest);
    14285        m_openDBRequest->setVersionChangeTransaction(*this);
     
    182125    objectStoreNames->sort();
    183126    return objectStoreNames;
    184 }
    185 
    186 const String& IDBTransaction::mode() const
    187 {
    188     ASSERT(currentThread() == m_database->originThreadID());
    189 
    190     switch (m_info.mode()) {
    191     case IndexedDB::TransactionMode::ReadOnly:
    192         return IDBTransaction::modeReadOnly();
    193     case IndexedDB::TransactionMode::ReadWrite:
    194         return IDBTransaction::modeReadWrite();
    195     case IndexedDB::TransactionMode::VersionChange:
    196         return IDBTransaction::modeVersionChange();
    197     }
    198 
    199     RELEASE_ASSERT_NOT_REACHED();
    200127}
    201128
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r207821 r207937  
    3535#include "IDBOpenDBRequest.h"
    3636#include "IDBTransactionInfo.h"
     37#include "IDBTransactionMode.h"
    3738#include "IndexedDB.h"
    3839#include "Timer.h"
     
    6566class IDBTransaction : public ThreadSafeRefCounted<IDBTransaction>, public EventTargetWithInlineData, public IDBActiveDOMObject {
    6667public:
    67     static const AtomicString& modeReadOnly();
    68     static const AtomicString& modeReadWrite();
    69     static const AtomicString& modeVersionChange();
    70     static const AtomicString& modeReadOnlyLegacy();
    71     static const AtomicString& modeReadWriteLegacy();
    72 
    73     static Optional<IndexedDB::TransactionMode> stringToMode(const String&);
    74     static const AtomicString& modeToString(IndexedDB::TransactionMode);
    75 
    7668    static Ref<IDBTransaction> create(IDBDatabase&, const IDBTransactionInfo&);
    7769    static Ref<IDBTransaction> create(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest&);
     
    8173    // IDBTransaction IDL
    8274    Ref<DOMStringList> objectStoreNames() const;
    83     const String& mode() const;
     75    IDBTransactionMode mode() const { return m_info.mode(); }
    8476    IDBDatabase* db();
    8577    DOMError* error() const;
     
    111103    void didCommit(const IDBError&);
    112104
    113     bool isVersionChange() const { return m_info.mode() == IndexedDB::TransactionMode::VersionChange; }
    114     bool isReadOnly() const { return m_info.mode() == IndexedDB::TransactionMode::ReadOnly; }
     105    bool isVersionChange() const { return mode() == IDBTransactionMode::Versionchange; }
     106    bool isReadOnly() const { return mode() == IDBTransactionMode::Readonly; }
    115107    bool isActive() const;
    116108
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.idl

    r207821 r207937  
    3232] interface IDBTransaction : EventTarget {
    3333    readonly attribute DOMStringList objectStoreNames;
    34     readonly attribute DOMString mode;
     34    readonly attribute IDBTransactionMode mode;
    3535    readonly attribute IDBDatabase db;
    3636    readonly attribute DOMError error;
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransactionMode.idl

    r207935 r207937  
    1  /*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
     1/*
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2625
    2726[
    28     ActiveDOMObject,
    2927    Conditional=INDEXED_DATABASE,
    30     EnabledAtRuntime=IndexedDB,
    31     SkipVTableValidation,
    32 ] interface IDBTransaction : EventTarget {
    33     readonly attribute DOMStringList objectStoreNames;
    34     readonly attribute DOMString mode;
    35     readonly attribute IDBDatabase db;
    36     readonly attribute DOMError error;
    37 
    38     [MayThrowException] IDBObjectStore objectStore(DOMString name);
    39     [MayThrowException] void abort();
    40 
    41     attribute EventHandler onabort;
    42     attribute EventHandler oncomplete;
    43     attribute EventHandler onerror;
     28] enum IDBTransactionMode {
     29    "readonly",
     30    "readwrite",
     31    "versionchange"
    4432};
  • trunk/Source/WebCore/Modules/indexeddb/IndexedDB.h

    r200699 r207937  
    3131
    3232namespace IndexedDB {
    33 
    34 enum class TransactionMode {
    35     ReadOnly = 0,
    36     ReadWrite = 1,
    37     VersionChange = 2,
    38 };
    39 const unsigned TransactionModeMaximum = 2;
    4033
    4134enum class TransactionState {
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp

    r207761 r207937  
    4949    , m_info(info)
    5050{
    51     if (m_info.mode() == IndexedDB::TransactionMode::VersionChange) {
     51    if (m_info.mode() == IDBTransactionMode::Versionchange) {
    5252        IDBDatabaseInfo info;
    5353        auto error = m_backingStore.getOrEstablishDatabaseInfo(info);
     
    154154{
    155155    ASSERT(m_objectStores.contains(&objectStore));
    156     ASSERT(m_info.mode() == IndexedDB::TransactionMode::VersionChange);
     156    ASSERT(m_info.mode() == IDBTransactionMode::Versionchange);
    157157
    158158    // We only care about the first rename in a given transaction, because if the transaction is aborted we want
     
    164164{
    165165    ASSERT(m_objectStores.contains(&index.objectStore()));
    166     ASSERT(m_info.mode() == IndexedDB::TransactionMode::VersionChange);
     166    ASSERT(m_info.mode() == IDBTransactionMode::Versionchange);
    167167
    168168    // We only care about the first rename in a given transaction, because if the transaction is aborted we want
     
    234234
    235235    if (m_originalDatabaseInfo) {
    236         ASSERT(m_info.mode() == IndexedDB::TransactionMode::VersionChange);
     236        ASSERT(m_info.mode() == IDBTransactionMode::Versionchange);
    237237        m_backingStore.setDatabaseInfo(*m_originalDatabaseInfo);
    238238    }
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h

    r207761 r207937  
    5353    ~MemoryBackingStoreTransaction();
    5454
    55     bool isVersionChange() const { return m_info.mode() == IndexedDB::TransactionMode::VersionChange; }
    56     bool isWriting() const { return m_info.mode() != IndexedDB::TransactionMode::ReadOnly; }
     55    bool isVersionChange() const { return m_info.mode() == IDBTransactionMode::Versionchange; }
     56    bool isWriting() const { return m_info.mode() != IDBTransactionMode::Readonly; }
    5757    bool isAborting() const { return m_isAborting; }
    5858
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r207931 r207937  
    779779
    780780    auto error = addResult.iterator->value->begin(*m_sqliteDB);
    781     if (error.isNull() && info.mode() == IndexedDB::TransactionMode::VersionChange) {
     781    if (error.isNull() && info.mode() == IDBTransactionMode::Versionchange) {
    782782        m_originalDatabaseInfoBeforeVersionChange = std::make_unique<IDBDatabaseInfo>(*m_databaseInfo);
    783783
     
    806806
    807807
    808     if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) {
     808    if (transaction->mode() == IDBTransactionMode::Versionchange) {
    809809        ASSERT(m_originalDatabaseInfoBeforeVersionChange);
    810810        m_databaseInfo = WTFMove(m_originalDatabaseInfoBeforeVersionChange);
     
    829829    auto error = transaction->commit();
    830830    if (!error.isNull()) {
    831         if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) {
     831        if (transaction->mode() == IDBTransactionMode::Versionchange) {
    832832            ASSERT(m_originalDatabaseInfoBeforeVersionChange);
    833833            m_databaseInfo = WTFMove(m_originalDatabaseInfoBeforeVersionChange);
     
    851851        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an object store without an in-progress transaction") };
    852852    }
    853     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     853    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    854854        LOG_ERROR("Attempt to create an object store in a non-version-change transaction");
    855855        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an object store in a non-version-change transaction") };
     
    903903        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete an object store without an in-progress transaction") };
    904904    }
    905     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     905    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    906906        LOG_ERROR("Attempt to delete an object store in a non-version-change transaction");
    907907        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete an object store in a non-version-change transaction") };
     
    995995        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an object store without an in-progress transaction") };
    996996    }
    997     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     997    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    998998        LOG_ERROR("Attempt to rename an object store in a non-version-change transaction");
    999999        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an object store in a non-version-change transaction") };
     
    10281028        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to clear an object store without an in-progress transaction") };
    10291029    }
    1030     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     1030    if (transaction->mode() == IDBTransactionMode::Readonly) {
    10311031        LOG_ERROR("Attempt to clear an object store in a read-only transaction");
    10321032        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to clear an object store in a read-only transaction") };
     
    10691069        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an index without an in-progress transaction") };
    10701070    }
    1071     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     1071    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    10721072        LOG_ERROR("Attempt to create an index in a non-version-change transaction");
    10731073        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an index in a non-version-change transaction") };
     
    12461246    }
    12471247
    1248     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     1248    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    12491249        LOG_ERROR("Attempt to delete index during a non-version-change transaction");
    12501250        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete index during a non-version-change transaction") };
     
    13011301    }
    13021302
    1303     if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     1303    if (transaction->mode() != IDBTransactionMode::Versionchange) {
    13041304        LOG_ERROR("Attempt to rename an index in a non-version-change transaction");
    13051305        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an index in a non-version-change transaction") };
     
    14151415    ASSERT(m_sqliteDB->isOpen());
    14161416    ASSERT(transaction.inProgress());
    1417     ASSERT(transaction.mode() != IndexedDB::TransactionMode::ReadOnly);
     1417    ASSERT(transaction.mode() != IDBTransactionMode::Readonly);
    14181418    UNUSED_PARAM(transaction);
    14191419
     
    15121512        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete range from database without an in-progress transaction") };
    15131513    }
    1514     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     1514    if (transaction->mode() == IDBTransactionMode::Readonly) {
    15151515        LOG_ERROR("Attempt to delete records from an object store in a read-only transaction");
    15161516        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete records from an object store in a read-only transaction") };
     
    16311631        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to store a record in an object store without an in-progress transaction") };
    16321632    }
    1633     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     1633    if (transaction->mode() == IDBTransactionMode::Readonly) {
    16341634        LOG_ERROR("Attempt to store a record in an object store in a read-only transaction");
    16351635        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to store a record in an object store in a read-only transaction") };
     
    19901990        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in database without an in-progress transaction") };
    19911991    }
    1992     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     1992    if (transaction->mode() == IDBTransactionMode::Readonly) {
    19931993        LOG_ERROR("Attempt to generate key in a read-only transaction");
    19941994        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to generate key in a read-only transaction") };
     
    20192019        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in database without an in-progress transaction") };
    20202020    }
    2021     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     2021    if (transaction->mode() == IDBTransactionMode::Readonly) {
    20222022        LOG_ERROR("Attempt to revert key generator value in a read-only transaction");
    20232023        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to revert key generator value in a read-only transaction") };
     
    20402040        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in database without an in-progress transaction") };
    20412041    }
    2042     if (transaction->mode() == IndexedDB::TransactionMode::ReadOnly) {
     2042    if (transaction->mode() == IDBTransactionMode::Readonly) {
    20432043        LOG_ERROR("Attempt to update key generator value in a read-only transaction");
    20442044        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to update key generator value in a read-only transaction") };
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp

    r199730 r207937  
    5959    ASSERT(!m_sqliteTransaction);
    6060
    61     m_sqliteTransaction = std::make_unique<SQLiteTransaction>(database, m_info.mode() == IndexedDB::TransactionMode::ReadOnly);
     61    m_sqliteTransaction = std::make_unique<SQLiteTransaction>(database, m_info.mode() == IDBTransactionMode::Readonly);
    6262    m_sqliteTransaction->begin();
    6363
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h

    r199524 r207937  
    6767    void notifyCursorsOfChanges(int64_t objectStoreID);
    6868
    69     IndexedDB::TransactionMode mode() const { return m_info.mode(); }
     69    IDBTransactionMode mode() const { return m_info.mode(); }
    7070    bool inProgress() const;
    7171
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r207931 r207937  
    14131413    ASSERT(!m_hardClosedForUserDelete);
    14141414
    1415     ASSERT(transaction->info().mode() != IndexedDB::TransactionMode::VersionChange);
     1415    ASSERT(transaction->info().mode() != IDBTransactionMode::Versionchange);
    14161416
    14171417    m_pendingTransactions.append(WTFMove(transaction));
     
    15491549
    15501550        switch (currentTransaction->info().mode()) {
    1551         case IndexedDB::TransactionMode::ReadOnly: {
     1551        case IDBTransactionMode::Readonly: {
    15521552            bool hasOverlappingScopes = scopesOverlap(deferredReadWriteScopes, currentTransaction->objectStoreIdentifiers());
    15531553            hasOverlappingScopes |= scopesOverlap(m_objectStoreWriteTransactions, currentTransaction->objectStoreIdentifiers());
     
    15581558            break;
    15591559        }
    1560         case IndexedDB::TransactionMode::ReadWrite: {
     1560        case IDBTransactionMode::Readwrite: {
    15611561            bool hasOverlappingScopes = scopesOverlap(m_objectStoreTransactionCounts, currentTransaction->objectStoreIdentifiers());
    15621562            hasOverlappingScopes |= scopesOverlap(deferredReadWriteScopes, currentTransaction->objectStoreIdentifiers());
     
    15701570            break;
    15711571        }
    1572         case IndexedDB::TransactionMode::VersionChange:
     1572        case IDBTransactionMode::Versionchange:
    15731573            // Version change transactions should never be scheduled in the traditional manner.
    15741574            RELEASE_ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp

    r207761 r207937  
    136136    LOG(IndexedDB, "UniqueIDBDatabaseConnection::establishTransaction - %s - %" PRIu64, m_openRequestIdentifier.loggingString().utf8().data(), m_identifier);
    137137
    138     ASSERT(info.mode() != IndexedDB::TransactionMode::VersionChange);
     138    ASSERT(info.mode() != IDBTransactionMode::Versionchange);
    139139
    140140    // No transactions should ever come from the client after the client has already told us
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp

    r207761 r207937  
    4747    , m_transactionInfo(info)
    4848{
    49     if (m_transactionInfo.mode() == IndexedDB::TransactionMode::VersionChange)
     49    if (m_transactionInfo.mode() == IDBTransactionMode::Versionchange)
    5050        m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(m_databaseConnection->database().info());
    5151
     
    6161IDBDatabaseInfo* UniqueIDBDatabaseTransaction::originalDatabaseInfo() const
    6262{
    63     ASSERT(m_transactionInfo.mode() == IndexedDB::TransactionMode::VersionChange);
     63    ASSERT(m_transactionInfo.mode() == IDBTransactionMode::Versionchange);
    6464    return m_originalDatabaseInfo.get();
    6565}
     
    8585bool UniqueIDBDatabaseTransaction::isVersionChange() const
    8686{
    87     return m_transactionInfo.mode() == IndexedDB::TransactionMode::VersionChange;
     87    return m_transactionInfo.mode() == IDBTransactionMode::Versionchange;
    8888}
    8989
    9090bool UniqueIDBDatabaseTransaction::isReadOnly() const
    9191{
    92     return m_transactionInfo.mode() == IndexedDB::TransactionMode::ReadOnly;
     92    return m_transactionInfo.mode() == IDBTransactionMode::Readonly;
    9393}   
    9494
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp

    r202806 r207937  
    4242}
    4343
    44 IDBTransactionInfo IDBTransactionInfo::clientTransaction(const IDBClient::IDBConnectionProxy& connectionProxy, const Vector<String>& objectStores, IndexedDB::TransactionMode mode)
     44IDBTransactionInfo IDBTransactionInfo::clientTransaction(const IDBClient::IDBConnectionProxy& connectionProxy, const Vector<String>& objectStores, IDBTransactionMode mode)
    4545{
    4646    IDBTransactionInfo result((IDBResourceIdentifier(connectionProxy)));
     
    5454{
    5555    IDBTransactionInfo result((IDBResourceIdentifier(connection)));
    56     result.m_mode = IndexedDB::TransactionMode::VersionChange;
     56    result.m_mode = IDBTransactionMode::Versionchange;
    5757    result.m_newVersion = newVersion;
    5858    result.m_originalDatabaseInfo = std::make_unique<IDBDatabaseInfo>(originalDatabaseInfo);
     
    100100    String modeString;
    101101    switch (m_mode) {
    102     case IndexedDB::TransactionMode::ReadOnly:
    103         modeString = IDBTransaction::modeReadOnly();
     102    case IDBTransactionMode::Readonly:
     103        modeString = ASCIILiteral("readonly");
    104104        break;
    105     case IndexedDB::TransactionMode::ReadWrite:
    106         modeString = IDBTransaction::modeReadWrite();
     105    case IDBTransactionMode::Readwrite:
     106        modeString = ASCIILiteral("readwrite");
    107107        break;
    108     case IndexedDB::TransactionMode::VersionChange:
    109         modeString = IDBTransaction::modeVersionChange();
     108    case IDBTransactionMode::Versionchange:
     109        modeString = ASCIILiteral("versionchange");
    110110        break;
    111111    default:
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h

    r202806 r207937  
    3131#include "IDBDatabaseInfo.h"
    3232#include "IDBResourceIdentifier.h"
     33#include "IDBTransactionMode.h"
    3334#include "IndexedDB.h"
    3435#include <wtf/Vector.h>
     
    4647class IDBTransactionInfo {
    4748public:
    48     static IDBTransactionInfo clientTransaction(const IDBClient::IDBConnectionProxy&, const Vector<String>& objectStores, IndexedDB::TransactionMode);
     49    static IDBTransactionInfo clientTransaction(const IDBClient::IDBConnectionProxy&, const Vector<String>& objectStores, IDBTransactionMode);
    4950    static IDBTransactionInfo versionChange(const IDBServer::IDBConnectionToClient&, const IDBDatabaseInfo& originalDatabaseInfo, uint64_t newVersion);
    5051
     
    5859    const IDBResourceIdentifier& identifier() const { return m_identifier; }
    5960
    60     IndexedDB::TransactionMode mode() const { return m_mode; }
     61    IDBTransactionMode mode() const { return m_mode; }
    6162    uint64_t newVersion() const { return m_newVersion; }
    6263
     
    8081    IDBResourceIdentifier m_identifier;
    8182
    82     IndexedDB::TransactionMode m_mode { IndexedDB::TransactionMode::ReadOnly };
     83    IDBTransactionMode m_mode { IDBTransactionMode::Readonly };
    8384    uint64_t m_newVersion { 0 };
    8485    Vector<String> m_objectStores;
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r207909 r207937  
    29492949                838867351D13BA5F003697D0 /* RenderObjectEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 838867341D13BA59003697D0 /* RenderObjectEnums.h */; settings = {ATTRIBUTES = (Private, ); }; };
    29502950                838869EC1CE81EA300D16A9E /* JSTextCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 838869EB1CE81E9E00D16A9E /* JSTextCustom.cpp */; };
     2951                838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2952                838EF53B1DC14A7C008F0C39 /* JSIDBTransactionMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 838EF5391DC14A75008F0C39 /* JSIDBTransactionMode.cpp */; };
     2953                838EF53C1DC14A7C008F0C39 /* JSIDBTransactionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 838EF53A1DC14A75008F0C39 /* JSIDBTransactionMode.h */; };
    29512954                839AAFEC1A0C0C8D00605F99 /* HTMLWBRElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */; };
    29522955                839AAFED1A0C0C8D00605F99 /* HTMLWBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */; };
     
    1027310276                838867341D13BA59003697D0 /* RenderObjectEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderObjectEnums.h; sourceTree = "<group>"; };
    1027410277                838869EB1CE81E9E00D16A9E /* JSTextCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextCustom.cpp; sourceTree = "<group>"; };
     10278                838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBTransactionMode.h; sourceTree = "<group>"; };
     10279                838EF5371DC149DA008F0C39 /* IDBTransactionMode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDBTransactionMode.idl; sourceTree = "<group>"; };
     10280                838EF5391DC14A75008F0C39 /* JSIDBTransactionMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBTransactionMode.cpp; sourceTree = "<group>"; };
     10281                838EF53A1DC14A75008F0C39 /* JSIDBTransactionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBTransactionMode.h; sourceTree = "<group>"; };
    1027510282                839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLWBRElement.cpp; sourceTree = "<group>"; };
    1027610283                839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLWBRElement.h; sourceTree = "<group>"; };
     
    1883518842                                51645B511B9F889B00F789CE /* IDBTransaction.h */,
    1883618843                                51D719A6181106E00016DC51 /* IDBTransaction.idl */,
     18844                                838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */,
     18845                                838EF5371DC149DA008F0C39 /* IDBTransactionMode.idl */,
    1883718846                                516103AD1CADB9A30016B4C7 /* IDBValue.cpp */,
    1883818847                                516103AE1CADB9A30016B4C7 /* IDBValue.h */,
     
    2022720236                                511EF2B417F0FC4800E4FA16 /* JSIDBTransaction.cpp */,
    2022820237                                B656626E120B1227006EA85C /* JSIDBTransaction.h */,
     20238                                838EF5391DC14A75008F0C39 /* JSIDBTransactionMode.cpp */,
     20239                                838EF53A1DC14A75008F0C39 /* JSIDBTransactionMode.h */,
    2022920240                                269239911505E1AA009E57FC /* JSIDBVersionChangeEvent.cpp */,
    2023020241                                269239921505E1AA009E57FC /* JSIDBVersionChangeEvent.h */,
     
    2551925530                                65DF323A09D1DE65000BE325 /* JSCanvasGradient.h in Headers */,
    2552025531                                65DF323C09D1DE65000BE325 /* JSCanvasPattern.h in Headers */,
     25532                                838EF53C1DC14A7C008F0C39 /* JSIDBTransactionMode.h in Headers */,
    2552125533                                65DF323C09D1DE65001BE325 /* JSCanvasProxy.h in Headers */,
    2552225534                                49EED1451051969400099FAB /* JSCanvasRenderingContext2D.h in Headers */,
     
    2683626848                                A8CFF5E10A155A05000A4234 /* RootInlineBox.h in Headers */,
    2683726849                                49E911C90EF86D47009D0CAF /* RotateTransformOperation.h in Headers */,
     26850                                838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */,
    2683826851                                A73F95FF12C97BFE0031AAF9 /* RoundedRect.h in Headers */,
    2683926852                                07AB996918DA3C010018771E /* RTCConfiguration.h in Headers */,
     
    2897428987                                A81369DD097374F600D74463 /* HTMLOptionElement.cpp in Sources */,
    2897528988                                9327A94209968D1A0068A546 /* HTMLOptionsCollection.cpp in Sources */,
     28989                                838EF53B1DC14A7C008F0C39 /* JSIDBTransactionMode.cpp in Sources */,
    2897628990                                4AD01008127E642A0015035F /* HTMLOutputElement.cpp in Sources */,
    2897728991                                A8EA7CB20A192B9C00A8EF5F /* HTMLParagraphElement.cpp in Sources */,
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r207770 r207937  
    7373);
    7474
    75 my %dictionaryTypes = ();
    7675my %dictionaryTypeImplementationNameOverrides = ();
    77 
    78 my %enumTypeHash = ();
    7976my %enumTypeImplementationNameOverrides = ();
    8077
     
    142139my $cachedInterfaces = {};
    143140my $cachedExternalDictionaries = {};
     141my $cachedExternalEnumerations = {};
    144142
    145143sub assert
     
    182180
    183181    foreach my $dictionary (@{$useDocument->dictionaries}) {
    184         $dictionaryTypes{$dictionary->name} = 1;
    185182        if ($dictionary->extendedAttributes->{"ImplementedAs"}) {
    186183            $dictionaryTypeImplementationNameOverrides{$dictionary->name} = $dictionary->extendedAttributes->{"ImplementedAs"};
     
    189186
    190187    foreach my $enumeration (@{$useDocument->enumerations}) {
    191         $enumTypeHash{$enumeration->name} = $enumeration->values;
    192188        if ($enumeration->extendedAttributes->{"ImplementedAs"}) {
    193189            $enumTypeImplementationNameOverrides{$enumeration->name} = $enumeration->extendedAttributes->{"ImplementedAs"};
     
    224220        $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations);
    225221        $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
     222        return;
     223    }
     224   
     225    my $enumerations = $useDocument->enumerations;
     226    if (@$enumerations) {
     227        die "Multiple standalone enumerations per document are not supported" if @$enumerations > 1;
     228
     229        my $enumeration = @$enumerations[0];
     230        print "Generating $useGenerator bindings code for IDL enumeration \"" . $enumeration->name . "\"...\n" if $verbose;
     231        $codeGenerator->GenerateEnumeration($enumeration);
     232        $codeGenerator->WriteData($enumeration, $useOutputDir, $useOutputHeadersDir);
    226233        return;
    227234    }
     
    445452    my ($object, $type) = @_;
    446453
    447     return 1 if exists $enumTypeHash{$type};
    448     return 0;
     454    return defined($object->GetEnumByName($type));
     455}
     456
     457sub GetEnumByName
     458{
     459    my ($object, $name) = @_;
     460   
     461    die "GetEnumByName() was called with an undefined enumeration name" unless defined($name);
     462
     463    for my $enumeration (@{$useDocument->enumerations}) {
     464        return $enumeration if $enumeration->name eq $name;
     465    }
     466
     467    return $cachedExternalEnumerations->{$name} if exists($cachedExternalEnumerations->{$name});
     468
     469    # Find the IDL file associated with the dictionary.
     470    my $filename = $object->IDLFileForInterface($name) or return;
     471
     472    # Do a fast check to see if it seems to contain a dictionary.
     473    my $fileContents = slurp($filename);
     474
     475    if ($fileContents =~ /\benum\s+$name/gs) {
     476        # Parse the IDL.
     477        my $parser = IDLParser->new(1);
     478        my $document = $parser->Parse($filename, $defines, $preprocessor);
     479
     480        foreach my $enumeration (@{$document->enumerations}) {
     481            next unless $enumeration->name eq $name;
     482
     483            $cachedExternalEnumerations->{$name} = $enumeration;
     484            my $implementedAs = $enumeration->extendedAttributes->{ImplementedAs};
     485            $enumTypeImplementationNameOverrides{$enumeration->name} = $implementedAs if $implementedAs;
     486            return $enumeration;
     487        }
     488    }
     489    $cachedExternalEnumerations->{$name} = undef;
     490}
     491
     492# An enumeration defined in its own IDL file.
     493sub IsExternalEnumType
     494{
     495    my ($object, $type) = @_;
     496
     497    return $object->IsEnumType($type) && defined($cachedExternalEnumerations->{$type});
    449498}
    450499
     
    453502    my ($object, $type) = @_;
    454503
    455     return @{$enumTypeHash{$type}};
     504    my $enumeration = $object->GetEnumByName($type);
     505    die "ValidEnumValues() was with a type that is not an enumeration: " . $type unless defined($enumeration);
     506
     507    return $enumeration->values;
    456508}
    457509
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207912 r207937  
    133133}
    134134
     135sub GenerateEnumeration
     136{
     137    my ($object, $enumeration) = @_;
     138
     139    my $className = GetEnumerationClassName($enumeration->name);
     140    $object->GenerateEnumerationHeader($enumeration, $className);
     141    $object->GenerateEnumerationImplementation($enumeration, $className);
     142}
     143
    135144sub GenerateDictionary
    136145{
     
    289298    }
    290299
    291     if ($codeGenerator->IsExternalDictionaryType($idlType->name)) {
     300    if ($codeGenerator->IsExternalDictionaryType($idlType->name) || $codeGenerator->IsExternalEnumType($idlType->name)) {
    292301        AddToImplIncludes("JS" . $idlType->name . ".h", $conditional);
    293302        return;
     
    853862    }
    854863
     864    return $name if $codeGenerator->IsExternalEnumType($name);
    855865    return $name unless defined($interface);
     866
    856867    return GetNestedClassName($interface, $name);
    857868}
     
    867878}
    868879
     880sub GenerateEnumerationHeader
     881{
     882    my ($object, $enumeration, $className) = @_;
     883 
     884    # - Add default header template and header protection.
     885    push(@headerContentHeader, GenerateHeaderContentHeader($enumeration));
     886 
     887    $headerIncludes{"$className.h"} = 1;
     888    $headerIncludes{"JSDOMConvert.h"} = 1;
     889 
     890    push(@headerContent, "\nnamespace WebCore {\n\n");
     891    push(@headerContent, GenerateEnumerationHeaderContent($enumeration, $className));
     892    push(@headerContent, "} // namespace WebCore\n");
     893     
     894    my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
     895    push(@headerContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
     896}
     897 
     898sub GenerateEnumerationImplementation
     899{
     900    my ($object, $enumeration, $className) = @_;
     901 
     902    # - Add default header template
     903    push(@implContentHeader, GenerateImplementationContentHeader($enumeration));
     904   
     905    # FIXME: A little ugly to have this be a side effect instead of a return value.
     906    AddToImplIncludes("<runtime/JSString.h>");
     907    AddToImplIncludes("JSDOMConvert.h");
     908 
     909    push(@implContent, "\nusing namespace JSC;\n\n");
     910    push(@implContent, "namespace WebCore {\n\n");
     911    push(@implContent, GenerateEnumerationImplementationContent($enumeration, $className));
     912    push(@implContent, "} // namespace WebCore\n");
     913     
     914    my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
     915    push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
     916}
     917
     918sub GenerateEnumerationImplementationContent
     919{
     920    my ($enumeration, $className, $interface, $conditionalString) = @_;
     921   
     922    my $result = "";
     923    $result .= "#if ${conditionalString}\n\n" if $conditionalString;
     924
     925    # FIXME: Change to take VM& instead of ExecState*.
     926    $result .= "template<> JSString* convertEnumerationToJS(ExecState& state, $className enumerationValue)\n";
     927    $result .= "{\n";
     928    # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that.
     929    # FIXME: Might be nice to make the entire array be NeverDestroyed instead of each value, but not sure what the syntax for that is.
     930    AddToImplIncludes("<wtf/NeverDestroyed.h>");
     931    $result .= "    static NeverDestroyed<const String> values[] = {\n";
     932    foreach my $value (@{$enumeration->values}) {
     933        if ($value eq "") {
     934            $result .= "        emptyString(),\n";
     935        } else {
     936            $result .= "        ASCIILiteral(\"$value\"),\n";
     937        }
     938    }
     939    $result .= "    };\n";
     940    my $index = 0;
     941    foreach my $value (@{$enumeration->values}) {
     942        my $enumerationValueName = GetEnumerationValueName($value);
     943        $result .= "    static_assert(static_cast<size_t>(${className}::$enumerationValueName) == $index, \"${className}::$enumerationValueName is not $index as expected\");\n";
     944        $index++;
     945    }
     946    $result .= "    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
     947    $result .= "    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);\n";
     948    $result .= "}\n\n";
     949
     950    # FIXME: Change to take VM& instead of ExecState&.
     951    # FIXME: Consider using toStringOrNull to make exception checking faster.
     952    # FIXME: Consider finding a more efficient way to match against all the strings quickly.
     953    $result .= "template<> Optional<$className> parseEnumeration<$className>(ExecState& state, JSValue value)\n";
     954    $result .= "{\n";
     955    $result .= "    auto stringValue = value.toWTFString(&state);\n";
     956    foreach my $value (@{$enumeration->values}) {
     957        my $enumerationValueName = GetEnumerationValueName($value);
     958        if ($value eq "") {
     959            $result .= "    if (stringValue.isEmpty())\n";
     960        } else {
     961            $result .= "    if (stringValue == \"$value\")\n";
     962        }
     963        $result .= "        return ${className}::${enumerationValueName};\n";
     964    }
     965    $result .= "    return Nullopt;\n";
     966    $result .= "}\n\n";
     967
     968    $result .= "template<> $className convertEnumeration<$className>(ExecState& state, JSValue value)\n";
     969    $result .= "{\n";
     970    $result .= "    VM& vm = state.vm();\n";
     971    $result .= "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n";
     972    $result .= "    auto result = parseEnumeration<$className>(state, value);\n";
     973    $result .= "    if (UNLIKELY(!result)) {\n";
     974    $result .= "        throwTypeError(&state, throwScope);\n";
     975    $result .= "        return { };\n";
     976    $result .= "    }\n";
     977    $result .= "    return result.value();\n";
     978    $result .= "}\n\n";
     979
     980    $result .= "template<> const char* expectedEnumerationValues<$className>()\n";
     981    $result .= "{\n";
     982    $result .= "    return \"\\\"" . join ("\\\", \\\"", @{$enumeration->values}) . "\\\"\";\n";
     983    $result .= "}\n\n";
     984
     985    $result .= "#endif\n\n" if $conditionalString;
     986
     987    return $result;
     988}
     989
    869990sub GenerateEnumerationsImplementationContent
    870991{
     
    872993
    873994    return "" unless @$enumerations;
     995   
     996    # FIXME: A little ugly to have this be a side effect instead of a return value.
     997    AddToImplIncludes("<runtime/JSString.h>");
     998    AddToImplIncludes("JSDOMConvert.h");
    874999
    8751000    my $result = "";
     
    8781003
    8791004        my $className = GetEnumerationClassName($name, $interface);
    880 
    881         # FIXME: A little ugly to have this be a side effect instead of a return value.
    882         AddToImplIncludes("<runtime/JSString.h>");
    883 
    8841005        my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
    885         $result .= "#if ${conditionalString}\n\n" if $conditionalString;
    886 
    887         # FIXME: Change to take VM& instead of ExecState*.
    888         $result .= "template<> JSString* convertEnumerationToJS(ExecState& state, $className enumerationValue)\n";
    889         $result .= "{\n";
    890         # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that.
    891         # FIXME: Might be nice to make the entire array be NeverDestroyed instead of each value, but not sure what the syntax for that is.
    892         AddToImplIncludes("<wtf/NeverDestroyed.h>");
    893         $result .= "    static NeverDestroyed<const String> values[] = {\n";
    894         foreach my $value (@{$enumeration->values}) {
    895             if ($value eq "") {
    896                 $result .= "        emptyString(),\n";
    897             } else {
    898                 $result .= "        ASCIILiteral(\"$value\"),\n";
    899             }
    900         }
    901         $result .= "    };\n";
    902         my $index = 0;
    903         foreach my $value (@{$enumeration->values}) {
    904             my $enumerationValueName = GetEnumerationValueName($value);
    905             $result .= "    static_assert(static_cast<size_t>(${className}::$enumerationValueName) == $index, \"${className}::$enumerationValueName is not $index as expected\");\n";
    906             $index++;
    907         }
    908         $result .= "    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
    909         $result .= "    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);\n";
    910         $result .= "}\n\n";
    911 
    912         # FIXME: Change to take VM& instead of ExecState&.
    913         # FIXME: Consider using toStringOrNull to make exception checking faster.
    914         # FIXME: Consider finding a more efficient way to match against all the strings quickly.
    915         $result .= "template<> Optional<$className> parseEnumeration<$className>(ExecState& state, JSValue value)\n";
    916         $result .= "{\n";
    917         $result .= "    auto stringValue = value.toWTFString(&state);\n";
    918         foreach my $value (@{$enumeration->values}) {
    919             my $enumerationValueName = GetEnumerationValueName($value);
    920             if ($value eq "") {
    921                 $result .= "    if (stringValue.isEmpty())\n";
    922             } else {
    923                 $result .= "    if (stringValue == \"$value\")\n";
    924             }
    925             $result .= "        return ${className}::${enumerationValueName};\n";
    926         }
    927         $result .= "    return Nullopt;\n";
    928         $result .= "}\n\n";
    929 
    930         # FIXME: A little ugly to have this be a side effect instead of a return value.
    931         AddToImplIncludes("JSDOMConvert.h");
    932 
    933         $result .= "template<> $className convertEnumeration<$className>(ExecState& state, JSValue value)\n";
    934         $result .= "{\n";
    935         $result .= "    VM& vm = state.vm();\n";
    936         $result .= "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n";
    937         $result .= "    auto result = parseEnumeration<$className>(state, value);\n";
    938         $result .= "    if (UNLIKELY(!result)) {\n";
    939         $result .= "        throwTypeError(&state, throwScope);\n";
    940         $result .= "        return { };\n";
    941         $result .= "    }\n";
    942         $result .= "    return result.value();\n";
    943         $result .= "}\n\n";
    944 
    945         $result .= "template<> const char* expectedEnumerationValues<$className>()\n";
    946         $result .= "{\n";
    947         $result .= "    return \"\\\"" . join ("\\\", \\\"", @{$enumeration->values}) . "\\\"\";\n";
    948         $result .= "}\n\n";
    949 
    950         $result .= "#endif\n\n" if $conditionalString;
    951     }
     1006        $result .= GenerateEnumerationImplementationContent($enumeration, $className, $interface, $conditionalString);
     1007    }
     1008    return $result;
     1009}
     1010
     1011sub GenerateEnumerationHeaderContent
     1012{
     1013    my ($enumeration, $className, $conditionalString) = @_;
     1014
     1015    my $result = "";
     1016    $result .= "#if ${conditionalString}\n\n" if $conditionalString;
     1017    $result .= "template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, $className);\n\n";
     1018    $result .= "template<> Optional<$className> parseEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n";
     1019    $result .= "template<> $className convertEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n";
     1020    $result .= "template<> const char* expectedEnumerationValues<$className>();\n\n";
     1021    $result .= "#endif\n\n" if $conditionalString;
     1022   
    9521023    return $result;
    9531024}
     
    9651036
    9661037    my $result = "";
    967 
    9681038    foreach my $enumeration (@$enumerations) {
    969         my $name = $enumeration->name;
    970 
    971         my $className = GetEnumerationClassName($name, $interface);
    972 
     1039        my $className = GetEnumerationClassName($enumeration->name, $interface);
    9731040        my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
    974         $result .= "#if ${conditionalString}\n\n" if $conditionalString;
    975 
    976         $result .= "template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, $className);\n\n";
    977 
    978         $result .= "template<> Optional<$className> parseEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n";
    979         $result .= "template<> $className convertEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n";
    980         $result .= "template<> const char* expectedEnumerationValues<$className>();\n\n";
    981 
    982         $result .= "#endif\n\n" if $conditionalString;
     1041        $result .= GenerateEnumerationHeaderContent($enumeration, $className, $conditionalString);
    9831042    }
    9841043    return $result;
     
    43964455            }
    43974456
     4457            $implIncludes{"JS$className.h"} = 1 if $codeGenerator->IsExternalEnumType($type);
    43984458            push(@$outputArray, "$indent    $defineOptionalValue = parseEnumeration<$className>(*state, ${name}Value);\n");
    43994459            push(@$outputArray, "$indent    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n");
     
    53045364
    53055365    return ("to$type($value)", 1) if $codeGenerator->IsTypedArrayType($type);
    5306     return ("parseEnumeration<" . GetEnumerationClassName($type, $interface) . ">($stateReference, $value)", 1) if $codeGenerator->IsEnumType($type);
    5307 
     5366   
     5367    if ($codeGenerator->IsEnumType($type)) {
     5368        AddToImplIncludes("JS$type.h", $conditional) if $codeGenerator->IsExternalEnumType($type);
     5369        return ("parseEnumeration<" . GetEnumerationClassName($type, $interface) . ">($stateReference, $value)", 1);
     5370    }
     5371   
    53085372    AddToImplIncludes("JS$type.h", $conditional);
    53095373
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207912 r207937  
    5353#include "JSTestObj.h"
    5454#include "JSTestStandaloneDictionary.h"
     55#include "JSTestStandaloneEnumeration.h"
    5556#include "JSTestSubObj.h"
    5657#include "JSXPathNSResolver.h"
     
    961962JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionNullableStringSpecialMethod(JSC::ExecState*);
    962963JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithEnumArg(JSC::ExecState*);
     964JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithStandaloneEnumArg(JSC::ExecState*);
    963965JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalEnumArg(JSC::ExecState*);
    964966JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalEnumArgAndDefaultValue(JSC::ExecState*);
     
    15721574    { "nullableStringSpecialMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionNullableStringSpecialMethod), (intptr_t) (1) } },
    15731575    { "methodWithEnumArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithEnumArg), (intptr_t) (1) } },
     1576    { "methodWithStandaloneEnumArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithStandaloneEnumArg), (intptr_t) (1) } },
    15741577    { "methodWithOptionalEnumArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalEnumArg), (intptr_t) (0) } },
    15751578    { "methodWithOptionalEnumArgAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalEnumArgAndDefaultValue), (intptr_t) (0) } },
     
    51875190}
    51885191
     5192static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithStandaloneEnumArgCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&);
     5193
     5194EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithStandaloneEnumArg(ExecState* state)
     5195{
     5196    return BindingCaller<JSTestObj>::callOperation<jsTestObjPrototypeFunctionMethodWithStandaloneEnumArgCaller>(state, "methodWithStandaloneEnumArg");
     5197}
     5198
     5199static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithStandaloneEnumArgCaller(JSC::ExecState* state, JSTestObj* castedThis, JSC::ThrowScope& throwScope)
     5200{
     5201    UNUSED_PARAM(state);
     5202    UNUSED_PARAM(throwScope);
     5203    auto& impl = castedThis->wrapped();
     5204    if (UNLIKELY(state->argumentCount() < 1))
     5205        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     5206    auto enumArgValue = state->uncheckedArgument(0);
     5207    TestStandaloneEnumeration enumArg;
     5208    auto optionalValue = parseEnumeration<TestStandaloneEnumeration>(*state, enumArgValue);
     5209    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     5210    if (UNLIKELY(!optionalValue))
     5211        return throwArgumentMustBeEnumError(*state, throwScope, 0, "enumArg", "TestObject", "methodWithStandaloneEnumArg", expectedEnumerationValues<TestStandaloneEnumeration>());
     5212    enumArg = optionalValue.value();
     5213    impl.methodWithStandaloneEnumArg(enumArg);
     5214    return JSValue::encode(jsUndefined());
     5215}
     5216
    51895217static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalEnumArgCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&);
    51905218
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r207766 r207937  
    136136
    137137    void methodWithEnumArg(TestEnumType enumArg);
     138    void methodWithStandaloneEnumArg(TestStandaloneEnumeration enumArg);
    138139    void methodWithOptionalEnumArg(optional TestEnumType enumArg);
    139140    void methodWithOptionalEnumArgAndDefaultValue(optional TestEnumType enumArg = "EnumValue1");
  • trunk/Source/WebCore/bindings/scripts/test/TestStandaloneEnumeration.idl

    r207935 r207937  
    1  /*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
    3  * Copyright (C) 2011 Apple Inc. All rights reserved.
     1/*
     2 * Copyright (C) 2016 Apple Inc. All rights reserved.
    43 *
    5  * Redistribution and use in source and binary forms, with or without
     4 * Redistribution and use in source and binary form, with or without
    65 * modification, are permitted provided that the following conditions
    76 * are met:
     
    1211 *     notice, this list of conditions and the following disclaimer in the
    1312 *     documentation and/or other materials provided with the distribution.
     13 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
     14 *     its contributors may be used to endorse or promote products derived
     15 *     from this software without specific prior written permission.
    1416 *
    1517 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     
    2628
    2729[
    28     ActiveDOMObject,
    29     Conditional=INDEXED_DATABASE,
    30     EnabledAtRuntime=IndexedDB,
    31     SkipVTableValidation,
    32 ] interface IDBTransaction : EventTarget {
    33     readonly attribute DOMStringList objectStoreNames;
    34     readonly attribute DOMString mode;
    35     readonly attribute IDBDatabase db;
    36     readonly attribute DOMError error;
     30    Conditional=CONDITION,
     31] enum TestStandaloneEnumeration {
     32    "enumValue1",
     33    "enumValue2"
     34};
    3735
    38     [MayThrowException] IDBObjectStore objectStore(DOMString name);
    39     [MayThrowException] void abort();
    40 
    41     attribute EventHandler onabort;
    42     attribute EventHandler oncomplete;
    43     attribute EventHandler onerror;
    44 };
  • trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

    r207931 r207937  
    183183}
    184184
    185 static RefPtr<IDBTransaction> transactionForDatabase(IDBDatabase* idbDatabase, const String& objectStoreName, const String& mode = IDBTransaction::modeReadOnly())
     185static RefPtr<IDBTransaction> transactionForDatabase(IDBDatabase* idbDatabase, const String& objectStoreName, IDBTransactionMode mode = IDBTransactionMode::Readonly)
    186186{
    187187    auto result = idbDatabase->transaction(objectStoreName, mode);
     
    692692            return;
    693693
    694         auto idbTransaction = transactionForDatabase(&database, m_objectStoreName, IDBTransaction::modeReadWrite());
     694        auto idbTransaction = transactionForDatabase(&database, m_objectStoreName, IDBTransactionMode::Readwrite);
    695695        if (!idbTransaction) {
    696696            m_requestCallback->sendFailure("Could not get transaction");
Note: See TracChangeset for help on using the changeset viewer.