1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate

Callers that are already in a fallible context will now TRY to allocate
cells. Callers in infallible contexts get a FIXME.
This commit is contained in:
Timothy Flynn 2023-01-28 13:39:44 -05:00 committed by Linus Groh
parent 109b190a19
commit b75b7f0c0d
178 changed files with 565 additions and 565 deletions

View file

@ -17,7 +17,7 @@ namespace Web::FileAPI {
JS::NonnullGCPtr<Blob> Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString type)
{
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
return realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type)).release_allocated_value_but_fixme_should_propagate_errors();
}
// https://w3c.github.io/FileAPI/#convert-line-endings-to-native
@ -145,7 +145,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 realm.heap().allocate<Blob>(realm, realm);
return MUST_OR_THROW_OOM(realm.heap().allocate<Blob>(realm, realm));
ByteBuffer byte_buffer {};
// 2. Let bytes be the result of processing blob parts given blobParts and options.
@ -170,7 +170,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 realm.heap().allocate<Blob>(realm, realm, move(byte_buffer), move(type));
return MUST_OR_THROW_OOM(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)
@ -239,7 +239,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_THROW_OOM(realm().vm(), m_byte_buffer.slice(relative_start, span));
return heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type));
return MUST_OR_THROW_OOM(heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type)));
}
// https://w3c.github.io/FileAPI/#dom-blob-text

View file

@ -66,7 +66,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(JS::Realm& realm, Vecto
// 4. F.name is set to n.
// 5. F.type is set to t.
// 6. F.lastModified is set to d.
return realm.heap().allocate<File>(realm, realm, move(bytes), move(name), move(type), last_modified);
return MUST_OR_THROW_OOM(realm.heap().allocate<File>(realm, realm, move(bytes), move(name), move(type), last_modified));
}
WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::construct_impl(JS::Realm& realm, Vector<BlobPart> const& file_bits, DeprecatedString const& file_name, Optional<FilePropertyBag> const& options)

View file

@ -13,7 +13,7 @@ namespace Web::FileAPI {
JS::NonnullGCPtr<FileList> FileList::create(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)
{
return realm.heap().allocate<FileList>(realm, realm, move(files));
return realm.heap().allocate<FileList>(realm, realm, move(files)).release_allocated_value_but_fixme_should_propagate_errors();
}
FileList::FileList(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files)