1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-14 17:40:33 +00:00 committed by Tim Flynn
parent 2a66fc6cae
commit 22089436ed
161 changed files with 367 additions and 370 deletions

View file

@ -16,7 +16,7 @@ namespace Web::FileAPI {
JS::NonnullGCPtr<Blob> Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type)
{
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type)));
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
}
// https://w3c.github.io/FileAPI/#convert-line-endings-to-native
@ -139,7 +139,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optio
{
// 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string.
if (!blob_parts.has_value() && !options.has_value())
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm));
return realm.heap().allocate<Blob>(realm, realm);
ByteBuffer byte_buffer {};
// 2. Let bytes be the result of processing blob parts given blobParts and options.
@ -164,7 +164,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(JS::Realm& realm, Optio
}
// 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above.
return JS::NonnullGCPtr(*realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type)));
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::construct_impl(JS::Realm& realm, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options)
@ -233,7 +233,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Opt
// b. S.size = span.
// c. S.type = relativeContentType.
auto byte_buffer = TRY_OR_RETURN_OOM(realm(), m_byte_buffer.slice(relative_start, span));
return JS::NonnullGCPtr(*heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type)));
return heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type));
}
// https://w3c.github.io/FileAPI/#dom-blob-text