mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-24 08:35:26 +00:00
LibJS+LibWeb: Use realm.create<T> instead of heap.allocate<T>
The main motivation behind this is to remove JS specifics of the Realm from the implementation of the Heap. As a side effect of this change, this is a bit nicer to read than the previous approach, and in my opinion, also makes it a little more clear that this method is specific to a JavaScript Realm.
This commit is contained in:
@@ -535,7 +535,7 @@ void WindowOrWorkerGlobalScopeMixin::queue_the_performance_observer_task()
|
||||
entries_as_gc_ptrs.append(*entry);
|
||||
|
||||
// 5. Let observerEntryList be a new PerformanceObserverEntryList, with its entry list set to entries.
|
||||
auto observer_entry_list = realm.heap().allocate<PerformanceTimeline::PerformanceObserverEntryList>(realm, realm, move(entries_as_gc_ptrs));
|
||||
auto observer_entry_list = realm.create<PerformanceTimeline::PerformanceObserverEntryList>(realm, move(entries_as_gc_ptrs));
|
||||
|
||||
// 6. Let droppedEntriesCount be null.
|
||||
Optional<u64> dropped_entries_count;
|
||||
@@ -642,17 +642,16 @@ JS::NonnullGCPtr<HighResolutionTime::Performance> WindowOrWorkerGlobalScopeMixin
|
||||
{
|
||||
auto& realm = this_impl().realm();
|
||||
if (!m_performance)
|
||||
m_performance = this_impl().heap().allocate<HighResolutionTime::Performance>(realm, realm);
|
||||
m_performance = realm.create<HighResolutionTime::Performance>(realm);
|
||||
return JS::NonnullGCPtr { *m_performance };
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<IndexedDB::IDBFactory> WindowOrWorkerGlobalScopeMixin::indexed_db()
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
auto& realm = this_impl().realm();
|
||||
|
||||
if (!m_indexed_db)
|
||||
m_indexed_db = vm.heap().allocate<IndexedDB::IDBFactory>(realm, realm);
|
||||
m_indexed_db = realm.create<IndexedDB::IDBFactory>(realm);
|
||||
return *m_indexed_db;
|
||||
}
|
||||
|
||||
@@ -790,7 +789,7 @@ JS::NonnullGCPtr<Crypto::Crypto> WindowOrWorkerGlobalScopeMixin::crypto()
|
||||
auto& realm = platform_object.realm();
|
||||
|
||||
if (!m_crypto)
|
||||
m_crypto = platform_object.heap().allocate<Crypto::Crypto>(realm, realm);
|
||||
m_crypto = realm.create<Crypto::Crypto>(realm);
|
||||
return JS::NonnullGCPtr { *m_crypto };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user