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

LibJS: Make Heap::allocate<T>() infallible

Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
This commit is contained in:
Andreas Kling 2023-08-13 13:05:26 +02:00
parent 980e7164fe
commit 72c9f56c66
337 changed files with 1229 additions and 1251 deletions

View file

@ -101,7 +101,7 @@ HTMLCanvasElement::HasOrCreatedContext HTMLCanvasElement::create_2d_context()
if (!m_context.has<Empty>())
return m_context.has<JS::NonnullGCPtr<CanvasRenderingContext2D>>() ? HasOrCreatedContext::Yes : HasOrCreatedContext::No;
m_context = CanvasRenderingContext2D::create(realm(), *this).release_value_but_fixme_should_propagate_errors();
m_context = CanvasRenderingContext2D::create(realm(), *this);
return HasOrCreatedContext::Yes;
}
@ -266,7 +266,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(JS::NonnullGCPtr<WebIDL::Ca
// 1. If result is non-null, then set result to a new Blob object, created in the relevant realm of this canvas element, representing result. [FILEAPI]
JS::GCPtr<FileAPI::Blob> blob_result;
if (file_result.has_value())
blob_result = TRY(FileAPI::Blob::create(realm(), file_result->buffer, TRY_OR_THROW_OOM(vm(), String::from_utf8(file_result->mime_type))));
blob_result = FileAPI::Blob::create(realm(), file_result->buffer, TRY_OR_THROW_OOM(vm(), String::from_utf8(file_result->mime_type)));
// 2. Invoke callback with « result ».
TRY(WebIDL::invoke_callback(*callback, {}, move(blob_result)));