Diff
Modified: trunk/Source/WebCore/ChangeLog (287128 => 287129)
--- trunk/Source/WebCore/ChangeLog 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/ChangeLog 2021-12-16 11:31:09 UTC (rev 287129)
@@ -1,3 +1,43 @@
+2021-12-15 Antoine Quint <grao...@webkit.org>
+
+ ActiveDOMObject::suspendIfNeeded() should not be called within constructors
+ https://bugs.webkit.org/show_bug.cgi?id=233945
+
+ Reviewed by Darin Adler.
+
+ Step 2 where we convert the IDB code to use suspendIfNeeded() only within create() methods. This required
+ adding such methods and making the constructor private for IDBIndex and IDBObjectStore.
+
+ * Modules/indexeddb/IDBDatabase.cpp:
+ (WebCore::IDBDatabase::create):
+ (WebCore::IDBDatabase::IDBDatabase):
+ * Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp:
+ (WebCore::IDBDatabaseNameAndVersionRequest::create):
+ (WebCore::IDBDatabaseNameAndVersionRequest::IDBDatabaseNameAndVersionRequest):
+ * Modules/indexeddb/IDBIndex.cpp:
+ (WebCore::IDBIndex::create):
+ (WebCore::IDBIndex::IDBIndex):
+ * Modules/indexeddb/IDBIndex.h:
+ * Modules/indexeddb/IDBObjectStore.cpp:
+ (WebCore::IDBObjectStore::create):
+ (WebCore::IDBObjectStore::IDBObjectStore):
+ (WebCore::IDBObjectStore::index):
+ * Modules/indexeddb/IDBObjectStore.h:
+ * Modules/indexeddb/IDBOpenDBRequest.cpp:
+ (WebCore::IDBOpenDBRequest::createDeleteRequest):
+ (WebCore::IDBOpenDBRequest::createOpenRequest):
+ * Modules/indexeddb/IDBRequest.cpp:
+ (WebCore::IDBRequest::create):
+ (WebCore::IDBRequest::createObjectStoreGet):
+ (WebCore::IDBRequest::createIndexGet):
+ (WebCore::IDBRequest::IDBRequest):
+ * Modules/indexeddb/IDBTransaction.cpp:
+ (WebCore::IDBTransaction::create):
+ (WebCore::IDBTransaction::IDBTransaction):
+ (WebCore::IDBTransaction::objectStore):
+ (WebCore::IDBTransaction::createObjectStore):
+ (WebCore::IDBTransaction::createIndex):
+
2021-12-16 Vitaly Dyachkov <obyknoven...@me.com>
Flexbox ignores margins of absolute positioned children when `align-items: flex-end` or `justify-content: flex-end`
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -48,7 +48,9 @@
Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData)
{
- return adoptRef(*new IDBDatabase(context, connectionProxy, resultData));
+ auto database = adoptRef(*new IDBDatabase(context, connectionProxy, resultData));
+ database->suspendIfNeeded();
+ return database;
}
IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData)
@@ -59,7 +61,6 @@
, m_eventNames(eventNames())
{
LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64 " (%p)", m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier, this);
- suspendIfNeeded();
m_connectionProxy->registerDatabaseConnection(*this);
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -36,7 +36,9 @@
Ref<IDBDatabaseNameAndVersionRequest> IDBDatabaseNameAndVersionRequest::create(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, InfoCallback&& callback)
{
- return adoptRef(*new IDBDatabaseNameAndVersionRequest(context, connectionProxy, WTFMove(callback)));
+ auto result = adoptRef(*new IDBDatabaseNameAndVersionRequest(context, connectionProxy, WTFMove(callback)));
+ result->suspendIfNeeded();
+ return result;
}
IDBDatabaseNameAndVersionRequest::IDBDatabaseNameAndVersionRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, InfoCallback&& callback)
@@ -46,8 +48,6 @@
, m_callback(WTFMove(callback))
{
ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
-
- suspendIfNeeded();
}
void IDBDatabaseNameAndVersionRequest::complete(std::optional<Vector<IDBDatabaseNameAndVersion>>&& databases)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -42,6 +42,13 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(IDBIndex);
+UniqueRef<IDBIndex> IDBIndex::create(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
+{
+ auto result = UniqueRef(*new IDBIndex(context, info, objectStore));
+ result->suspendIfNeeded();
+ return result;
+}
+
IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore)
: ActiveDOMObject(&context)
, m_info(info)
@@ -49,8 +56,6 @@
, m_objectStore(objectStore)
{
ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
-
- suspendIfNeeded();
}
IDBIndex::~IDBIndex()
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h 2021-12-16 11:31:09 UTC (rev 287129)
@@ -29,6 +29,7 @@
#include "IDBIndexInfo.h"
#include "IDBRequest.h"
#include <wtf/IsoMalloc.h>
+#include <wtf/UniqueRef.h>
namespace JSC {
class CallFrame;
@@ -43,7 +44,7 @@
class IDBIndex final : public ActiveDOMObject {
WTF_MAKE_ISO_ALLOCATED(IDBIndex);
public:
- IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);
+ static UniqueRef<IDBIndex> create(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);
virtual ~IDBIndex();
@@ -85,6 +86,8 @@
void* objectStoreAsOpaqueRoot() { return &m_objectStore; }
private:
+ IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);
+
ExceptionOr<Ref<IDBRequest>> doCount(const IDBKeyRangeData&);
ExceptionOr<Ref<IDBRequest>> doGet(ExceptionOr<IDBKeyRangeData>);
ExceptionOr<Ref<IDBRequest>> doGetKey(ExceptionOr<IDBKeyRangeData>);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -55,6 +55,13 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(IDBObjectStore);
+UniqueRef<IDBObjectStore> IDBObjectStore::create(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
+{
+ auto result = UniqueRef(*new IDBObjectStore(context, info, transaction));
+ result->suspendIfNeeded();
+ return result;
+}
+
IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction)
: ActiveDOMObject(&context)
, m_info(info)
@@ -62,8 +69,6 @@
, m_transaction(transaction)
{
ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
-
- suspendIfNeeded();
}
IDBObjectStore::~IDBObjectStore()
@@ -520,11 +525,11 @@
if (!info)
return Exception { NotFoundError, "Failed to execute 'index' on 'IDBObjectStore': The specified index was not found."_s };
- auto index = makeUnique<IDBIndex>(*scriptExecutionContext(), *info, *this);
+ auto index = IDBIndex::create(*scriptExecutionContext(), *info, *this);
- Ref<IDBIndex> referencedIndex { *index };
+ Ref referencedIndex { index.get() };
- m_referencedIndexes.set(indexName, WTFMove(index));
+ m_referencedIndexes.set(indexName, index.moveToUniquePtr());
return referencedIndex;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h 2021-12-16 11:31:09 UTC (rev 287129)
@@ -32,6 +32,7 @@
#include "IDBObjectStoreInfo.h"
#include <wtf/IsoMalloc.h>
#include <wtf/Lock.h>
+#include <wtf/UniqueRef.h>
namespace JSC {
class CallFrame;
@@ -59,7 +60,7 @@
class IDBObjectStore final : public ActiveDOMObject {
WTF_MAKE_ISO_ALLOCATED(IDBObjectStore);
public:
- IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
+ static UniqueRef<IDBObjectStore> create(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
~IDBObjectStore();
const String& name() const;
@@ -113,6 +114,8 @@
void renameReferencedIndex(IDBIndex&, const String& newName);
private:
+ IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);
+
enum class InlineKeyCheck { Perform, DoNotPerform };
ExceptionOr<Ref<IDBRequest>> putOrAdd(JSC::JSGlobalObject&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck, RefPtr<SerializedScriptValue>&& = nullptr);
ExceptionOr<Ref<IDBRequest>> doCount(const IDBKeyRangeData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -46,12 +46,16 @@
Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier)
{
- return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
+ auto result = adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
+ result->suspendIfNeeded();
+ return result;
}
Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
{
- return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, version, IndexedDB::RequestType::Open));
+ auto result = adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, version, IndexedDB::RequestType::Open));
+ result->suspendIfNeeded();
+ return result;
}
IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -57,27 +57,37 @@
Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
{
- return adoptRef(*new IDBRequest(context, objectStore, transaction));
+ auto request = adoptRef(*new IDBRequest(context, objectStore, transaction));
+ request->suspendIfNeeded();
+ return request;
}
Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
{
- return adoptRef(*new IDBRequest(context, cursor, transaction));
+ auto request = adoptRef(*new IDBRequest(context, cursor, transaction));
+ request->suspendIfNeeded();
+ return request;
}
Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
{
- return adoptRef(*new IDBRequest(context, index, transaction));
+ auto request = adoptRef(*new IDBRequest(context, index, transaction));
+ request->suspendIfNeeded();
+ return request;
}
Ref<IDBRequest> IDBRequest::createObjectStoreGet(ScriptExecutionContext& context, IDBObjectStore& objectStore, IndexedDB::ObjectStoreRecordType type, IDBTransaction& transaction)
{
- return adoptRef(*new IDBRequest(context, objectStore, type, transaction));
+ auto request = adoptRef(*new IDBRequest(context, objectStore, type, transaction));
+ request->suspendIfNeeded();
+ return request;
}
Ref<IDBRequest> IDBRequest::createIndexGet(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
{
- return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
+ auto request = adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
+ request->suspendIfNeeded();
+ return request;
}
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, IndexedDB::RequestType requestType)
@@ -87,7 +97,6 @@
, m_connectionProxy(connectionProxy)
, m_requestType(requestType)
{
- suspendIfNeeded();
}
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
@@ -98,7 +107,6 @@
, m_source(&objectStore)
, m_connectionProxy(transaction.database().connectionProxy())
{
- suspendIfNeeded();
}
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
@@ -109,8 +117,6 @@
, m_pendingCursor(&cursor)
, m_connectionProxy(transaction.database().connectionProxy())
{
- suspendIfNeeded();
-
WTF::switchOn(cursor.source(),
[this] (const auto& value) { this->m_source = IDBRequest::Source { value }; }
);
@@ -126,7 +132,6 @@
, m_source(&index)
, m_connectionProxy(transaction.database().connectionProxy())
{
- suspendIfNeeded();
}
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IndexedDB::ObjectStoreRecordType type, IDBTransaction& transaction)
@@ -138,7 +143,6 @@
, m_connectionProxy(transaction.database().connectionProxy())
, m_requestedObjectStoreRecordType(type)
{
- suspendIfNeeded();
}
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (287128 => 287129)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2021-12-16 11:03:48 UTC (rev 287128)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp 2021-12-16 11:31:09 UTC (rev 287129)
@@ -65,12 +65,16 @@
Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info)
{
- return adoptRef(*new IDBTransaction(database, info, nullptr));
+ auto transaction = adoptRef(*new IDBTransaction(database, info, nullptr));
+ transaction->suspendIfNeeded();
+ return transaction;
}
Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest& request)
{
- return adoptRef(*new IDBTransaction(database, info, &request));
+ auto transaction = adoptRef(*new IDBTransaction(database, info, &request));
+ transaction->suspendIfNeeded();
+ return transaction;
}
IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest* request)
@@ -102,8 +106,6 @@
establishOnServer();
}
-
- suspendIfNeeded();
}
IDBTransaction::~IDBTransaction()
@@ -175,11 +177,11 @@
if (!info || (!found && !isVersionChange()))
return Exception { NotFoundError, "Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found."_s };
- auto objectStore = makeUnique<IDBObjectStore>(*scriptExecutionContext(), *info, *this);
- auto* rawObjectStore = objectStore.get();
- m_referencedObjectStores.set(objectStoreName, WTFMove(objectStore));
+ auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), *info, *this);
+ Ref objectStoreRef { objectStore.get() };
+ m_referencedObjectStores.set(objectStoreName, objectStore.moveToUniquePtr());
- return Ref<IDBObjectStore>(*rawObjectStore);
+ return objectStoreRef;
}
@@ -659,9 +661,9 @@
Locker locker { m_referencedObjectStoreLock };
- auto objectStore = makeUnique<IDBObjectStore>(*scriptExecutionContext(), info, *this);
- auto* rawObjectStore = objectStore.get();
- m_referencedObjectStores.set(info.name(), WTFMove(objectStore));
+ auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), info, *this);
+ Ref objectStoreRef { objectStore.get() };
+ m_referencedObjectStores.set(info.name(), objectStore.moveToUniquePtr());
LOG(IndexedDBOperations, "IDB create object store operation: %s", info.condensedLoggingString().utf8().data());
scheduleOperation(IDBClient::TransactionOperationImpl::create(*this, [protectedThis = Ref { *this }] (const auto& result) {
@@ -670,7 +672,7 @@
protectedThis->createObjectStoreOnServer(operation, info);
}), IsWriteOperation::Yes);
- return *rawObjectStore;
+ return objectStoreRef;
}
void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation& operation, const IDBObjectStoreInfo& info)
@@ -747,7 +749,7 @@
protectedThis->createIndexOnServer(operation, info);
}), IsWriteOperation::Yes);
- return makeUnique<IDBIndex>(*scriptExecutionContext(), info, objectStore);
+ return IDBIndex::create(*scriptExecutionContext(), info, objectStore).moveToUniquePtr();
}
void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operation, const IDBIndexInfo& info)