mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +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:
parent
980e7164fe
commit
72c9f56c66
Notes:
sideshowbarker
2024-07-17 01:04:03 +09:00
Author: https://github.com/awesomekling
Commit: 72c9f56c66
Pull-request: https://github.com/SerenityOS/serenity/pull/20550
337 changed files with 1229 additions and 1251 deletions
|
@ -27,7 +27,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
|
||||
WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
|
||||
void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
|
||||
{
|
||||
// 1. Let realm be the value of execution context's Realm component.
|
||||
auto realm = execution_context->realm;
|
||||
|
@ -38,7 +38,7 @@ WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const&
|
|||
|
||||
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
|
||||
// NOTE: See the functions defined for this class.
|
||||
auto settings_object = MUST_OR_THROW_OOM(realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context)));
|
||||
auto settings_object = realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context));
|
||||
|
||||
// 4. If reservedEnvironment is non-null, then:
|
||||
if (reserved_environment.has_value()) {
|
||||
|
@ -71,15 +71,13 @@ WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const&
|
|||
|
||||
// 7. Set realm's [[HostDefined]] field to settings object.
|
||||
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
|
||||
auto intrinsics = MUST_OR_THROW_OOM(realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm));
|
||||
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
||||
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
||||
realm->set_host_defined(move(host_defined));
|
||||
|
||||
// Non-Standard: We cannot fully initialize window object until *after* the we set up
|
||||
// the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
|
||||
TRY(window.initialize_web_interfaces({}));
|
||||
|
||||
return {};
|
||||
MUST(window.initialize_web_interfaces({}));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:responsible-document
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue