[Web IDL] Specify default parameter values for callback parameters
https://bugs.webkit.org/show_bug.cgi?id=157188
Reviewed by Darin Adler.
Specify default parameter values for callback parameters.
* Modules/geolocation/Geolocation.idl:
* Modules/notifications/Notification.cpp:
(WebCore::Notification::requestPermission):
* Modules/notifications/Notification.h:
* Modules/notifications/Notification.idl:
* Modules/notifications/NotificationCenter.idl:
* Modules/quota/StorageInfo.cpp:
(WebCore::StorageInfo::queryUsageAndQuota):
(WebCore::StorageInfo::requestQuota):
* Modules/quota/StorageInfo.h:
* Modules/quota/StorageInfo.idl:
* Modules/quota/StorageQuota.h:
* Modules/quota/StorageQuota.idl:
* Modules/webaudio/AudioContext.idl:
* Modules/webdatabase/DOMWindowWebDatabase.cpp:
(WebCore::DOMWindowWebDatabase::openDatabase):
* Modules/webdatabase/DOMWindowWebDatabase.h:
(WebCore::DOMWindowWebDatabase::DOMWindowWebDatabase):
(WebCore::DOMWindowWebDatabase::~DOMWindowWebDatabase):
* Modules/webdatabase/DOMWindowWebDatabase.idl:
* Modules/webdatabase/Database.cpp:
(WebCore::Database::runTransaction):
(WebCore::Database::changeVersion):
(WebCore::Database::transaction):
(WebCore::Database::readTransaction):
* Modules/webdatabase/Database.h:
* Modules/webdatabase/Database.idl:
* Modules/webdatabase/SQLTransaction.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
(CanUseWTFOptionalForParameter): Deleted.
* bindings/scripts/test/TestObj.idl:
* dom/DataTransferItem.h:
* dom/DataTransferItem.idl:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp
index 5b9fdb3..3e55902 100644
--- a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp
+++ b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp
@@ -37,16 +37,16 @@
namespace WebCore {
-RefPtr<Database> DOMWindowWebDatabase::openDatabase(DOMWindow& window, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
+RefPtr<Database> DOMWindowWebDatabase::openDatabase(DOMWindow& window, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, RefPtr<DatabaseCallback>&& creationCallback, ExceptionCode& ec)
{
if (!window.isCurrentlyDisplayedInFrame())
return nullptr;
- RefPtr<Database> database = nullptr;
+ RefPtr<Database> database;
DatabaseManager& dbManager = DatabaseManager::singleton();
DatabaseError error = DatabaseError::None;
if (dbManager.isAvailable() && window.document()->securityOrigin()->canAccessDatabase(window.document()->topOrigin())) {
- database = dbManager.openDatabase(window.document(), name, version, displayName, estimatedSize, creationCallback, error);
+ database = dbManager.openDatabase(window.document(), name, version, displayName, estimatedSize, WTFMove(creationCallback), error);
ASSERT(database || error != DatabaseError::None);
ec = DatabaseManager::exceptionCodeForDatabaseError(error);
} else
diff --git a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.h b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.h
index 656f883..1ce239c 100644
--- a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.h
+++ b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.h
@@ -42,11 +42,10 @@
class DOMWindowWebDatabase {
public:
- static RefPtr<Database> openDatabase(DOMWindow&, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode&);
+ static RefPtr<Database> openDatabase(DOMWindow&, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, RefPtr<DatabaseCallback>&& creationCallback, ExceptionCode&);
-private:
- DOMWindowWebDatabase() { };
- ~DOMWindowWebDatabase() { };
+ DOMWindowWebDatabase() = delete;
+ ~DOMWindowWebDatabase() = delete;
};
} // namespace WebCore
diff --git a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
index 15eb435..7a536d4 100644
--- a/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
+++ b/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.idl
@@ -26,6 +26,6 @@
[
] partial interface DOMWindow {
- [RaisesException] Database openDatabase(DOMString name, DOMString version, DOMString displayName, unsigned long estimatedSize, optional DatabaseCallback creationCallback);
+ [RaisesException] Database openDatabase(DOMString name, DOMString version, DOMString displayName, unsigned long estimatedSize, optional DatabaseCallback? creationCallback);
};
diff --git a/Source/WebCore/Modules/webdatabase/Database.cpp b/Source/WebCore/Modules/webdatabase/Database.cpp
index c08b861..813ca04 100644
--- a/Source/WebCore/Modules/webdatabase/Database.cpp
+++ b/Source/WebCore/Modules/webdatabase/Database.cpp
@@ -554,17 +554,17 @@
m_transactionInProgress = false;
}
-PassRefPtr<SQLTransactionBackend> Database::runTransaction(PassRefPtr<SQLTransaction> transaction, bool readOnly, const ChangeVersionData* data)
+RefPtr<SQLTransactionBackend> Database::runTransaction(Ref<SQLTransaction>&& transaction, bool readOnly, const ChangeVersionData* data)
{
LockHolder locker(m_transactionInProgressMutex);
if (!m_isTransactionQueueEnabled)
- return 0;
+ return nullptr;
RefPtr<SQLTransactionWrapper> wrapper;
if (data)
wrapper = ChangeVersionWrapper::create(data->oldVersion(), data->newVersion());
- RefPtr<SQLTransactionBackend> transactionBackend = SQLTransactionBackend::create(this, transaction, wrapper, readOnly);
+ RefPtr<SQLTransactionBackend> transactionBackend = SQLTransactionBackend::create(this, WTFMove(transaction), wrapper, readOnly);
m_transactionQueue.append(transactionBackend);
if (!m_transactionInProgress)
scheduleTransaction();
@@ -635,22 +635,20 @@
synchronizer.waitForTaskCompletion();
}
-void Database::changeVersion(const String& oldVersion, const String& newVersion,
- PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback,
- PassRefPtr<VoidCallback> successCallback)
+void Database::changeVersion(const String& oldVersion, const String& newVersion, RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback)
{
ChangeVersionData data(oldVersion, newVersion);
- runTransaction(callback, errorCallback, successCallback, false, &data);
+ runTransaction(WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback), false, &data);
}
-void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback)
+void Database::transaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback)
{
- runTransaction(callback, errorCallback, successCallback, false);
+ runTransaction(WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback), false);
}
-void Database::readTransaction(PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback)
+void Database::readTransaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback)
{
- runTransaction(callback, errorCallback, successCallback, true);
+ runTransaction(WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback), true);
}
String Database::stringIdentifier() const
@@ -732,11 +730,11 @@
void Database::runTransaction(RefPtr<SQLTransactionCallback>&& callback, RefPtr<SQLTransactionErrorCallback>&& errorCallback, RefPtr<VoidCallback>&& successCallback, bool readOnly, const ChangeVersionData* changeVersionData)
{
- RefPtr<SQLTransaction> transaction = SQLTransaction::create(*this, WTFMove(callback), WTFMove(successCallback), errorCallback.copyRef(), readOnly);
+ Ref<SQLTransaction> transaction = SQLTransaction::create(*this, WTFMove(callback), WTFMove(successCallback), errorCallback.copyRef(), readOnly);
- RefPtr<SQLTransactionBackend> transactionBackend = runTransaction(transaction.release(), readOnly, changeVersionData);
+ RefPtr<SQLTransactionBackend> transactionBackend = runTransaction(WTFMove(transaction), readOnly, changeVersionData);
if (!transactionBackend && errorCallback) {
- WTF::RefPtr<SQLTransactionErrorCallback> errorCallbackProtector = WTFMove(errorCallback);
+ RefPtr<SQLTransactionErrorCallback> errorCallbackProtector = WTFMove(errorCallback);
m_scriptExecutionContext->postTask([errorCallbackProtector](ScriptExecutionContext&) {
errorCallbackProtector->handleEvent(SQLError::create(SQLError::UNKNOWN_ERR, "database has been closed").ptr());
});
diff --git a/Source/WebCore/Modules/webdatabase/Database.h b/Source/WebCore/Modules/webdatabase/Database.h
index 3d466ef..f3a4740 100644
--- a/Source/WebCore/Modules/webdatabase/Database.h
+++ b/Source/WebCore/Modules/webdatabase/Database.h
@@ -64,7 +64,7 @@
unsigned long long maximumSize() const;
- PassRefPtr<SQLTransactionBackend> runTransaction(PassRefPtr<SQLTransaction>, bool readOnly, const ChangeVersionData*);
+ RefPtr<SQLTransactionBackend> runTransaction(Ref<SQLTransaction>&&, bool readOnly, const ChangeVersionData*);
void scheduleTransactionStep(SQLTransactionBackend*);
void inProgressTransactionCompleted();
@@ -78,10 +78,9 @@
// Direct support for the DOM API
String version() const;
- void changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionCallback>,
- PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
- void transaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
- void readTransaction(PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback> successCallback);
+ void changeVersion(const String& oldVersion, const String& newVersion, RefPtr<SQLTransactionCallback>&&, RefPtr<SQLTransactionErrorCallback>&&, RefPtr<VoidCallback>&& successCallback);
+ void transaction(RefPtr<SQLTransactionCallback>&&, RefPtr<SQLTransactionErrorCallback>&&, RefPtr<VoidCallback>&& successCallback);
+ void readTransaction(RefPtr<SQLTransactionCallback>&&, RefPtr<SQLTransactionErrorCallback>&&, RefPtr<VoidCallback>&& successCallback);
// Internal engine support
String stringIdentifier() const;
diff --git a/Source/WebCore/Modules/webdatabase/Database.idl b/Source/WebCore/Modules/webdatabase/Database.idl
index ceb3f0b..8df804b 100644
--- a/Source/WebCore/Modules/webdatabase/Database.idl
+++ b/Source/WebCore/Modules/webdatabase/Database.idl
@@ -28,8 +28,8 @@
interface Database {
readonly attribute DOMString version;
- void changeVersion(DOMString oldVersion, DOMString newVersion, optional SQLTransactionCallback callback, optional SQLTransactionErrorCallback errorCallback, optional VoidCallback successCallback);
- void transaction(SQLTransactionCallback callback, optional SQLTransactionErrorCallback errorCallback, optional VoidCallback successCallback);
- void readTransaction(SQLTransactionCallback callback, optional SQLTransactionErrorCallback errorCallback, optional VoidCallback successCallback);
+ void changeVersion(DOMString oldVersion, DOMString newVersion, optional SQLTransactionCallback? callback, optional SQLTransactionErrorCallback? errorCallback, optional VoidCallback? successCallback);
+ void transaction(SQLTransactionCallback callback, optional SQLTransactionErrorCallback? errorCallback, optional VoidCallback? successCallback);
+ void readTransaction(SQLTransactionCallback callback, optional SQLTransactionErrorCallback? errorCallback, optional VoidCallback? successCallback);
};
diff --git a/Source/WebCore/Modules/webdatabase/SQLTransaction.idl b/Source/WebCore/Modules/webdatabase/SQLTransaction.idl
index 516f696..2248c94 100644
--- a/Source/WebCore/Modules/webdatabase/SQLTransaction.idl
+++ b/Source/WebCore/Modules/webdatabase/SQLTransaction.idl
@@ -31,6 +31,6 @@
] interface SQLTransaction {
[Custom] void executeSql(DOMString sqlStatement,
ObjectArray arguments,
- optional SQLStatementCallback callback,
- optional SQLStatementErrorCallback errorCallback);
+ optional SQLStatementCallback? callback,
+ optional SQLStatementErrorCallback? errorCallback);
};