From 72c9f56c663645c0faf5fdb31ec31e15de2c0229 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Aug 2023 13:05:26 +0200 Subject: [PATCH] LibJS: Make Heap::allocate() 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 is no longer necessary. --- .../BindingsGenerator/IDLGenerators.cpp | 2 +- .../GenerateWindowOrWorkerInterfaces.cpp | 8 +- Tests/LibWasm/test-wasm.cpp | 2 +- .../Applications/Spreadsheet/Workbook.cpp | 2 +- .../LibJS/Contrib/Test262/262Object.cpp | 4 +- .../LibJS/Contrib/Test262/GlobalObject.cpp | 2 +- Userland/Libraries/LibJS/Heap/Heap.h | 4 +- Userland/Libraries/LibJS/Module.cpp | 2 +- .../LibJS/Runtime/AbstractOperations.cpp | 2 +- .../LibJS/Runtime/AbstractOperations.h | 2 +- .../LibJS/Runtime/AggregateError.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Array.cpp | 2 +- .../Libraries/LibJS/Runtime/ArrayBuffer.cpp | 6 +- .../Libraries/LibJS/Runtime/ArrayIterator.cpp | 2 +- .../LibJS/Runtime/AsyncFromSyncIterator.cpp | 2 +- .../Runtime/AsyncFunctionDriverWrapper.cpp | 4 +- .../Runtime/AsyncFunctionDriverWrapper.h | 2 +- .../LibJS/Runtime/AsyncGenerator.cpp | 2 +- .../Libraries/LibJS/Runtime/BigIntObject.cpp | 2 +- .../Libraries/LibJS/Runtime/BooleanObject.cpp | 2 +- .../Libraries/LibJS/Runtime/BoundFunction.cpp | 2 +- Userland/Libraries/LibJS/Runtime/DataView.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Date.cpp | 2 +- .../Runtime/ECMAScriptFunctionObject.cpp | 8 +- Userland/Libraries/LibJS/Runtime/Error.cpp | 48 ++-- .../LibJS/Runtime/GeneratorObject.cpp | 2 +- .../Runtime/Intl/CollatorCompareFunction.cpp | 2 +- .../Runtime/Intl/DateTimeFormatFunction.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/Locale.cpp | 2 +- .../Runtime/Intl/NumberFormatFunction.cpp | 2 +- .../LibJS/Runtime/Intl/SegmentIterator.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/Segments.cpp | 2 +- .../Libraries/LibJS/Runtime/Intrinsics.cpp | 126 ++++----- Userland/Libraries/LibJS/Runtime/Iterator.cpp | 4 +- Userland/Libraries/LibJS/Runtime/Iterator.h | 2 +- .../LibJS/Runtime/IteratorConstructor.cpp | 2 +- .../LibJS/Runtime/IteratorHelper.cpp | 2 +- .../LibJS/Runtime/IteratorPrototype.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Map.cpp | 2 +- .../Libraries/LibJS/Runtime/MapIterator.cpp | 2 +- .../LibJS/Runtime/NativeFunction.cpp | 4 +- .../Libraries/LibJS/Runtime/NumberObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Object.cpp | 6 +- Userland/Libraries/LibJS/Runtime/Promise.cpp | 2 +- .../LibJS/Runtime/PromiseCapability.cpp | 2 +- .../PromiseResolvingElementFunctions.cpp | 8 +- .../Runtime/PromiseResolvingFunction.cpp | 2 +- .../Libraries/LibJS/Runtime/ProxyObject.cpp | 2 +- .../Libraries/LibJS/Runtime/RegExpObject.cpp | 4 +- .../LibJS/Runtime/RegExpStringIterator.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Set.cpp | 2 +- .../Libraries/LibJS/Runtime/SetIterator.cpp | 2 +- .../LibJS/Runtime/StringConstructor.cpp | 2 +- .../LibJS/Runtime/StringIterator.cpp | 2 +- .../Libraries/LibJS/Runtime/StringObject.cpp | 4 +- .../Libraries/LibJS/Runtime/StringObject.h | 2 +- .../LibJS/Runtime/SuppressedError.cpp | 2 +- .../Libraries/LibJS/Runtime/SymbolObject.cpp | 2 +- .../LibJS/Runtime/Temporal/Temporal.cpp | 2 +- .../Libraries/LibJS/Runtime/TypedArray.cpp | 262 +++++++++--------- Userland/Libraries/LibJS/Runtime/Value.cpp | 2 +- Userland/Libraries/LibJS/Runtime/WeakMap.cpp | 2 +- Userland/Libraries/LibJS/Runtime/WeakRef.cpp | 4 +- Userland/Libraries/LibJS/Runtime/WeakSet.cpp | 2 +- .../LibJS/Runtime/WrappedFunction.cpp | 2 +- .../Libraries/LibTest/JavaScriptTestRunner.h | 2 +- .../LibWeb/Bindings/MainThreadVM.cpp | 2 +- .../LibWeb/Bindings/OptionConstructor.cpp | 2 +- .../Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSFontFaceRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSImportRule.cpp | 4 +- Userland/Libraries/LibWeb/CSS/CSSImportRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSKeyframeRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSKeyframeRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSKeyframesRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSKeyframesRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSMediaRule.cpp | 4 +- Userland/Libraries/LibWeb/CSS/CSSMediaRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSNamespaceRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSNamespaceRule.h | 2 +- Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp | 8 +- Userland/Libraries/LibWeb/CSS/CSSRuleList.h | 4 +- .../LibWeb/CSS/CSSStyleDeclaration.cpp | 8 +- .../LibWeb/CSS/CSSStyleDeclaration.h | 4 +- .../Libraries/LibWeb/CSS/CSSStyleRule.cpp | 4 +- Userland/Libraries/LibWeb/CSS/CSSStyleRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 4 +- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 2 +- .../Libraries/LibWeb/CSS/CSSSupportsRule.cpp | 4 +- .../Libraries/LibWeb/CSS/CSSSupportsRule.h | 2 +- Userland/Libraries/LibWeb/CSS/MediaList.cpp | 4 +- Userland/Libraries/LibWeb/CSS/MediaList.h | 2 +- .../Libraries/LibWeb/CSS/MediaQueryList.cpp | 4 +- .../Libraries/LibWeb/CSS/MediaQueryList.h | 2 +- .../LibWeb/CSS/MediaQueryListEvent.cpp | 4 +- .../LibWeb/CSS/MediaQueryListEvent.h | 2 +- .../Libraries/LibWeb/CSS/Parser/Helpers.cpp | 8 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 32 +-- .../CSS/ResolvedCSSStyleDeclaration.cpp | 4 +- .../LibWeb/CSS/ResolvedCSSStyleDeclaration.h | 2 +- Userland/Libraries/LibWeb/CSS/Screen.cpp | 4 +- Userland/Libraries/LibWeb/CSS/Screen.h | 2 +- .../Libraries/LibWeb/CSS/StyleSheetList.cpp | 4 +- .../Libraries/LibWeb/CSS/StyleSheetList.h | 2 +- .../Libraries/LibWeb/CSS/VisualViewport.cpp | 4 +- .../Libraries/LibWeb/CSS/VisualViewport.h | 2 +- Userland/Libraries/LibWeb/Crypto/Crypto.cpp | 6 +- Userland/Libraries/LibWeb/Crypto/Crypto.h | 2 +- .../Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 4 +- .../Libraries/LibWeb/Crypto/SubtleCrypto.h | 2 +- .../Libraries/LibWeb/DOM/AbortController.cpp | 2 +- Userland/Libraries/LibWeb/DOM/AbortSignal.cpp | 4 +- .../LibWeb/DOM/AccessibilityTreeNode.cpp | 4 +- .../LibWeb/DOM/AccessibilityTreeNode.h | 2 +- Userland/Libraries/LibWeb/DOM/Attr.cpp | 10 +- Userland/Libraries/LibWeb/DOM/Attr.h | 4 +- Userland/Libraries/LibWeb/DOM/Comment.cpp | 2 +- Userland/Libraries/LibWeb/DOM/CustomEvent.cpp | 4 +- Userland/Libraries/LibWeb/DOM/CustomEvent.h | 4 +- .../LibWeb/DOM/DOMImplementation.cpp | 14 +- .../Libraries/LibWeb/DOM/DOMImplementation.h | 2 +- .../Libraries/LibWeb/DOM/DOMTokenList.cpp | 4 +- Userland/Libraries/LibWeb/DOM/DOMTokenList.h | 2 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 124 ++++----- Userland/Libraries/LibWeb/DOM/Document.h | 4 +- .../Libraries/LibWeb/DOM/DocumentFragment.cpp | 2 +- .../Libraries/LibWeb/DOM/DocumentLoading.cpp | 2 +- .../Libraries/LibWeb/DOM/DocumentType.cpp | 4 +- Userland/Libraries/LibWeb/DOM/DocumentType.h | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 24 +- .../Libraries/LibWeb/DOM/ElementFactory.cpp | 214 +++++++------- Userland/Libraries/LibWeb/DOM/Event.cpp | 4 +- Userland/Libraries/LibWeb/DOM/Event.h | 2 +- Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 4 +- .../Libraries/LibWeb/DOM/HTMLCollection.cpp | 4 +- .../Libraries/LibWeb/DOM/HTMLCollection.h | 2 +- .../Libraries/LibWeb/DOM/IDLEventListener.cpp | 4 +- .../Libraries/LibWeb/DOM/IDLEventListener.h | 2 +- .../Libraries/LibWeb/DOM/LiveNodeList.cpp | 4 +- Userland/Libraries/LibWeb/DOM/LiveNodeList.h | 2 +- .../Libraries/LibWeb/DOM/MutationObserver.cpp | 2 +- .../Libraries/LibWeb/DOM/MutationRecord.cpp | 4 +- .../Libraries/LibWeb/DOM/MutationRecord.h | 2 +- .../Libraries/LibWeb/DOM/NamedNodeMap.cpp | 4 +- Userland/Libraries/LibWeb/DOM/NamedNodeMap.h | 2 +- Userland/Libraries/LibWeb/DOM/Node.cpp | 26 +- Userland/Libraries/LibWeb/DOM/NodeFilter.cpp | 4 +- Userland/Libraries/LibWeb/DOM/NodeFilter.h | 2 +- .../Libraries/LibWeb/DOM/NodeIterator.cpp | 2 +- .../Libraries/LibWeb/DOM/NodeOperations.cpp | 10 +- Userland/Libraries/LibWeb/DOM/ParentNode.cpp | 16 +- Userland/Libraries/LibWeb/DOM/Range.cpp | 26 +- Userland/Libraries/LibWeb/DOM/Range.h | 6 +- .../Libraries/LibWeb/DOM/StaticNodeList.cpp | 4 +- .../Libraries/LibWeb/DOM/StaticNodeList.h | 2 +- Userland/Libraries/LibWeb/DOM/StaticRange.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Text.cpp | 4 +- Userland/Libraries/LibWeb/DOM/TreeWalker.cpp | 4 +- Userland/Libraries/LibWeb/DOM/TreeWalker.h | 2 +- .../Libraries/LibWeb/DOMParsing/InnerHTML.cpp | 2 +- .../LibWeb/DOMParsing/XMLSerializer.cpp | 2 +- .../Libraries/LibWeb/Encoding/TextDecoder.cpp | 2 +- .../Libraries/LibWeb/Encoding/TextEncoder.cpp | 2 +- Userland/Libraries/LibWeb/Fetch/Body.cpp | 2 +- Userland/Libraries/LibWeb/Fetch/BodyInit.cpp | 4 +- .../Libraries/LibWeb/Fetch/FetchMethod.cpp | 2 +- .../LibWeb/Fetch/Fetching/Fetching.cpp | 4 +- Userland/Libraries/LibWeb/Fetch/Headers.cpp | 2 +- .../LibWeb/Fetch/HeadersIterator.cpp | 6 +- .../Libraries/LibWeb/Fetch/HeadersIterator.h | 2 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 4 +- .../LibWeb/Fetch/Infrastructure/HTTP/Bodies.h | 2 +- .../Fetch/Infrastructure/HTTP/Requests.cpp | 4 +- .../Fetch/Infrastructure/HTTP/Requests.h | 2 +- .../Fetch/Infrastructure/HTTP/Responses.cpp | 2 +- Userland/Libraries/LibWeb/Fetch/Request.cpp | 18 +- Userland/Libraries/LibWeb/Fetch/Request.h | 2 +- Userland/Libraries/LibWeb/Fetch/Response.cpp | 18 +- Userland/Libraries/LibWeb/Fetch/Response.h | 4 +- Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 20 +- Userland/Libraries/LibWeb/FileAPI/Blob.h | 4 +- Userland/Libraries/LibWeb/FileAPI/File.cpp | 2 +- .../Libraries/LibWeb/FileAPI/FileList.cpp | 4 +- Userland/Libraries/LibWeb/FileAPI/FileList.h | 2 +- .../Libraries/LibWeb/Geometry/DOMMatrix.cpp | 6 +- .../LibWeb/Geometry/DOMMatrixReadOnly.cpp | 4 +- .../Libraries/LibWeb/Geometry/DOMPoint.cpp | 2 +- .../LibWeb/Geometry/DOMPointReadOnly.cpp | 2 +- .../Libraries/LibWeb/Geometry/DOMRect.cpp | 10 +- Userland/Libraries/LibWeb/Geometry/DOMRect.h | 4 +- .../Libraries/LibWeb/Geometry/DOMRectList.cpp | 4 +- .../Libraries/LibWeb/Geometry/DOMRectList.h | 2 +- .../LibWeb/Geometry/DOMRectReadOnly.cpp | 6 +- .../LibWeb/Geometry/DOMRectReadOnly.h | 2 +- Userland/Libraries/LibWeb/HTML/AudioTrack.cpp | 2 +- .../Libraries/LibWeb/HTML/BrowsingContext.cpp | 21 +- .../Libraries/LibWeb/HTML/CanvasGradient.cpp | 6 +- .../Libraries/LibWeb/HTML/CanvasPattern.cpp | 2 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 6 +- .../LibWeb/HTML/CanvasRenderingContext2D.h | 2 +- Userland/Libraries/LibWeb/HTML/CloseEvent.cpp | 4 +- Userland/Libraries/LibWeb/HTML/CloseEvent.h | 2 +- .../CustomElements/CustomElementDefinition.h | 2 +- Userland/Libraries/LibWeb/HTML/DOMParser.cpp | 6 +- .../Libraries/LibWeb/HTML/DOMStringMap.cpp | 4 +- Userland/Libraries/LibWeb/HTML/DOMStringMap.h | 2 +- Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp | 4 +- Userland/Libraries/LibWeb/HTML/ErrorEvent.h | 2 +- Userland/Libraries/LibWeb/HTML/Focus.cpp | 4 +- .../Libraries/LibWeb/HTML/FormDataEvent.cpp | 2 +- .../LibWeb/HTML/HTMLCanvasElement.cpp | 4 +- .../LibWeb/HTML/HTMLDetailsElement.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLDocument.cpp | 4 +- Userland/Libraries/LibWeb/HTML/HTMLDocument.h | 2 +- .../Libraries/LibWeb/HTML/HTMLElement.cpp | 4 +- .../Libraries/LibWeb/HTML/HTMLFormElement.cpp | 6 +- .../LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- .../LibWeb/HTML/HTMLImageElement.cpp | 14 +- .../LibWeb/HTML/HTMLInputElement.cpp | 26 +- .../Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 12 +- .../LibWeb/HTML/HTMLMediaElement.cpp | 97 +++---- .../Libraries/LibWeb/HTML/HTMLMediaElement.h | 6 +- .../LibWeb/HTML/HTMLObjectElement.cpp | 6 +- .../LibWeb/HTML/HTMLOptionsCollection.cpp | 4 +- .../LibWeb/HTML/HTMLOptionsCollection.h | 2 +- .../LibWeb/HTML/HTMLScriptElement.cpp | 10 +- .../LibWeb/HTML/HTMLSelectElement.cpp | 2 +- .../LibWeb/HTML/HTMLTableElement.cpp | 4 +- .../LibWeb/HTML/HTMLTableRowElement.cpp | 2 +- .../LibWeb/HTML/HTMLTableSectionElement.cpp | 2 +- .../LibWeb/HTML/HTMLTemplateElement.cpp | 2 +- Userland/Libraries/LibWeb/HTML/History.cpp | 4 +- Userland/Libraries/LibWeb/HTML/History.h | 2 +- Userland/Libraries/LibWeb/HTML/ImageData.cpp | 2 +- .../Libraries/LibWeb/HTML/MessageChannel.cpp | 6 +- .../Libraries/LibWeb/HTML/MessageEvent.cpp | 4 +- Userland/Libraries/LibWeb/HTML/MessageEvent.h | 4 +- .../Libraries/LibWeb/HTML/MessagePort.cpp | 6 +- Userland/Libraries/LibWeb/HTML/MessagePort.h | 2 +- Userland/Libraries/LibWeb/HTML/Navigator.cpp | 12 +- Userland/Libraries/LibWeb/HTML/Navigator.h | 6 +- .../LibWeb/HTML/PageTransitionEvent.cpp | 4 +- .../LibWeb/HTML/PageTransitionEvent.h | 4 +- .../HTML/Parser/HTMLEncodingDetection.cpp | 10 +- .../LibWeb/HTML/Parser/HTMLParser.cpp | 24 +- Userland/Libraries/LibWeb/HTML/Path2D.cpp | 2 +- .../LibWeb/HTML/PromiseRejectionEvent.cpp | 4 +- .../LibWeb/HTML/PromiseRejectionEvent.h | 4 +- .../LibWeb/HTML/Scripting/Environments.cpp | 2 +- .../LibWeb/HTML/Scripting/ModuleScript.cpp | 2 +- .../WindowEnvironmentSettingsObject.cpp | 10 +- .../WindowEnvironmentSettingsObject.h | 2 +- .../WorkerEnvironmentSettingsObject.h | 4 +- Userland/Libraries/LibWeb/HTML/Storage.cpp | 4 +- Userland/Libraries/LibWeb/HTML/Storage.h | 2 +- .../LibWeb/HTML/StructuredSerialize.cpp | 2 +- .../Libraries/LibWeb/HTML/SubmitEvent.cpp | 4 +- Userland/Libraries/LibWeb/HTML/SubmitEvent.h | 2 +- .../Libraries/LibWeb/HTML/TextMetrics.cpp | 4 +- Userland/Libraries/LibWeb/HTML/TextMetrics.h | 2 +- Userland/Libraries/LibWeb/HTML/TrackEvent.cpp | 4 +- Userland/Libraries/LibWeb/HTML/TrackEvent.h | 4 +- Userland/Libraries/LibWeb/HTML/VideoTrack.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Window.cpp | 84 +++--- Userland/Libraries/LibWeb/HTML/Window.h | 18 +- Userland/Libraries/LibWeb/HTML/Worker.cpp | 10 +- .../LibWeb/HTML/WorkerGlobalScope.cpp | 2 +- .../Libraries/LibWeb/HTML/WorkerNavigator.cpp | 4 +- .../Libraries/LibWeb/HTML/WorkerNavigator.h | 2 +- .../LibWeb/HighResolutionTime/Performance.cpp | 4 +- .../IntersectionObserver.cpp | 2 +- .../IntersectionObserverEntry.cpp | 8 +- .../Libraries/LibWeb/Layout/TreeBuilder.cpp | 2 +- .../Libraries/LibWeb/MathML/MathMLElement.cpp | 2 +- .../Libraries/LibWeb/Page/EventHandler.cpp | 4 +- .../RequestIdleCallback/IdleDeadline.cpp | 4 +- .../LibWeb/RequestIdleCallback/IdleDeadline.h | 2 +- .../LibWeb/ResizeObserver/ResizeObserver.cpp | 2 +- .../LibWeb/SVG/SVGAnimatedLength.cpp | 4 +- .../Libraries/LibWeb/SVG/SVGAnimatedLength.h | 2 +- .../LibWeb/SVG/SVGAnimatedNumber.cpp | 4 +- .../Libraries/LibWeb/SVG/SVGAnimatedNumber.h | 2 +- .../Libraries/LibWeb/SVG/SVGCircleElement.cpp | 18 +- Userland/Libraries/LibWeb/SVG/SVGElement.cpp | 2 +- .../LibWeb/SVG/SVGEllipseElement.cpp | 24 +- .../LibWeb/SVG/SVGForeignObjectElement.cpp | 8 +- Userland/Libraries/LibWeb/SVG/SVGLength.cpp | 4 +- Userland/Libraries/LibWeb/SVG/SVGLength.h | 2 +- .../Libraries/LibWeb/SVG/SVGLineElement.cpp | 24 +- .../Libraries/LibWeb/SVG/SVGRectElement.cpp | 36 +-- .../Libraries/LibWeb/SVG/SVGUseElement.cpp | 16 +- .../Libraries/LibWeb/Selection/Selection.cpp | 16 +- .../Libraries/LibWeb/Selection/Selection.h | 2 +- .../LibWeb/Streams/AbstractOperations.cpp | 26 +- .../Streams/ByteLengthQueuingStrategy.cpp | 2 +- .../LibWeb/Streams/CountQueuingStrategy.cpp | 2 +- .../LibWeb/Streams/ReadableStream.cpp | 2 +- .../Streams/ReadableStreamDefaultReader.cpp | 2 +- .../LibWeb/Streams/TransformStream.cpp | 2 +- .../LibWeb/Streams/WritableStream.cpp | 2 +- .../Streams/WritableStreamDefaultWriter.cpp | 2 +- .../Libraries/LibWeb/UIEvents/FocusEvent.cpp | 2 +- .../LibWeb/UIEvents/KeyboardEvent.cpp | 12 +- .../Libraries/LibWeb/UIEvents/KeyboardEvent.h | 6 +- .../Libraries/LibWeb/UIEvents/MouseEvent.cpp | 4 +- .../Libraries/LibWeb/UIEvents/MouseEvent.h | 2 +- .../Libraries/LibWeb/UIEvents/UIEvent.cpp | 6 +- Userland/Libraries/LibWeb/UIEvents/UIEvent.h | 2 +- .../Libraries/LibWeb/UIEvents/WheelEvent.cpp | 4 +- .../Libraries/LibWeb/UIEvents/WheelEvent.h | 2 +- Userland/Libraries/LibWeb/URL/URL.cpp | 6 +- Userland/Libraries/LibWeb/URL/URL.h | 2 +- .../Libraries/LibWeb/URL/URLSearchParams.cpp | 2 +- .../LibWeb/URL/URLSearchParamsIterator.cpp | 4 +- .../LibWeb/UserTiming/PerformanceMark.cpp | 2 +- .../LibWeb/UserTiming/PerformanceMeasure.cpp | 4 +- .../LibWeb/UserTiming/PerformanceMeasure.h | 2 +- .../Libraries/LibWeb/WebAssembly/Instance.cpp | 6 +- .../Libraries/LibWeb/WebAssembly/Memory.cpp | 2 +- .../Libraries/LibWeb/WebAssembly/Module.cpp | 2 +- .../Libraries/LibWeb/WebAssembly/Table.cpp | 2 +- .../LibWeb/WebAssembly/WebAssembly.cpp | 10 +- .../LibWeb/WebAudio/AudioContext.cpp | 10 +- .../LibWeb/WebGL/WebGLContextEvent.cpp | 4 +- .../LibWeb/WebGL/WebGLContextEvent.h | 4 +- .../LibWeb/WebGL/WebGLRenderingContext.cpp | 4 +- .../Libraries/LibWeb/WebIDL/DOMException.cpp | 4 +- .../Libraries/LibWeb/WebSockets/WebSocket.cpp | 12 +- Userland/Libraries/LibWeb/XHR/FormData.cpp | 2 +- .../Libraries/LibWeb/XHR/FormDataIterator.cpp | 6 +- .../Libraries/LibWeb/XHR/FormDataIterator.h | 2 +- .../Libraries/LibWeb/XHR/ProgressEvent.cpp | 4 +- Userland/Libraries/LibWeb/XHR/ProgressEvent.h | 2 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 18 +- .../LibWeb/XML/XMLDocumentBuilder.cpp | 4 +- .../WebContent/WebContentConsoleClient.cpp | 2 +- .../WebContent/WebDriverConnection.cpp | 2 +- 337 files changed, 1229 insertions(+), 1251 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index dc4e2afd01..ca175163ee 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3473,7 +3473,7 @@ JS::ThrowCompletionOr> @constructor_class@::constru // 3. Set element's namespace to the HTML namespace. // 4. Set element's namespace prefix to null. // 5. Set element's local name to definition's local name. - auto element = realm.heap().allocate<@fully_qualified_name@>(realm, window.associated_document(), DOM::QualifiedName { definition->local_name().to_deprecated_string(), {}, Namespace::HTML }).release_allocated_value_but_fixme_should_propagate_errors(); + auto element = realm.heap().allocate<@fully_qualified_name@>(realm, window.associated_document(), DOM::QualifiedName { definition->local_name().to_deprecated_string(), {}, Namespace::HTML }); // https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface // Important steps from "internally create a new object implementing the interface" diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 52441b9619..98b66f2d71 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -157,7 +157,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm) { - auto namespace_object = heap().allocate<@namespace_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto namespace_object = heap().allocate<@namespace_class@>(realm, realm); m_namespaces.set("@interface_name@"sv, namespace_object); [[maybe_unused]] static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;)~~~"); @@ -189,10 +189,10 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea { auto& vm = realm.vm(); - auto prototype = heap().allocate<@prototype_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto prototype = heap().allocate<@prototype_class@>(realm, realm); m_prototypes.set("@interface_name@"sv, prototype); - auto constructor = heap().allocate<@constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto constructor = heap().allocate<@constructor_class@>(realm, realm); m_constructors.set("@interface_name@"sv, constructor); prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable); @@ -203,7 +203,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea gen.set("legacy_interface_name", legacy_constructor->name); gen.set("legacy_constructor_class", legacy_constructor->constructor_class); gen.append(R"~~~( - auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm); m_constructors.set("@legacy_interface_name@"sv, legacy_constructor); legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"_string), JS::Attribute::Configurable);)~~~"); diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 4466309c08..fe63f67b2d 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -56,7 +56,7 @@ public: static JS::ThrowCompletionOr create(JS::Realm& realm, Wasm::Module module, HashMap const& imports) { auto& vm = realm.vm(); - auto instance = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm.intrinsics().object_prototype())); + auto instance = realm.heap().allocate(realm, realm.intrinsics().object_prototype()); instance->m_module = move(module); Wasm::Linker linker(*instance->m_module); linker.link(imports); diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index 4e62247de6..ec53f15969 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -28,7 +28,7 @@ Workbook::Workbook(Vector>&& sheets, GUI::Window& parent_wi { auto& realm = *m_root_execution_context->realm; auto& vm = realm.vm(); - m_workbook_object = vm.heap().allocate(realm, realm, *this).release_allocated_value_but_fixme_should_propagate_errors(); + m_workbook_object = vm.heap().allocate(realm, realm, *this); realm.global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes); m_main_execution_context.this_value = &realm.global_object(); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp index c07bce1c37..d39a277560 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/262Object.cpp @@ -30,8 +30,8 @@ void $262Object::initialize(Realm& realm) { Base::initialize(realm); - m_agent = MUST(vm().heap().allocate(realm, realm)); - m_is_htmldda = MUST(vm().heap().allocate(realm, realm)); + m_agent = vm().heap().allocate(realm, realm); + m_is_htmldda = vm().heap().allocate(realm, realm); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 87be56cf3d..3741b2671c 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -18,7 +18,7 @@ void GlobalObject::initialize(Realm& realm) { Base::initialize(realm); - m_$262 = MUST(vm().heap().allocate<$262Object>(realm, realm)); + m_$262 = vm().heap().allocate<$262Object>(realm, realm); // https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions u8 attr = Attribute::Writable | Attribute::Configurable; diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 807347b5b7..657e195816 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -43,7 +43,7 @@ public: } template - ThrowCompletionOr> allocate(Realm& realm, Args&&... args) + NonnullGCPtr allocate(Realm& realm, Args&&... args) { auto* memory = allocate_cell(sizeof(T)); new (memory) T(forward(args)...); diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp index 714a8d15e8..38ad302488 100644 --- a/Userland/Libraries/LibJS/Module.cpp +++ b/Userland/Libraries/LibJS/Module.cpp @@ -114,7 +114,7 @@ Object* Module::module_namespace_create(VM& vm, Vector unam // 6. Let sortedExports be a List whose elements are the elements of exports ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn. // 7. Set M.[[Exports]] to sortedExports. // 8. Create own properties of M corresponding to the definitions in 28.3. - auto module_namespace = vm.heap().allocate(realm, realm, this, move(unambiguous_names)).release_allocated_value_but_fixme_should_propagate_errors(); + auto module_namespace = vm.heap().allocate(realm, realm, this, move(unambiguous_names)); // 9. Set module.[[Namespace]] to M. m_namespace = make_handle(module_namespace); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 7bc12fea66..12aee23a26 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1103,7 +1103,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector< // 7. Set obj.[[Set]] as specified in 10.4.4.4. // 8. Set obj.[[Delete]] as specified in 10.4.4.5. // 9. Set obj.[[Prototype]] to %Object.prototype%. - auto object = vm.heap().allocate(realm, realm, environment).release_allocated_value_but_fixme_should_propagate_errors(); + auto object = vm.heap().allocate(realm, realm, environment); // 14. Let index be 0. // 15. Repeat, while index < len, diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index 2146fb4e02..6be2d303d0 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -149,7 +149,7 @@ ThrowCompletionOr> ordinary_create_from_constructor(VM& vm, Func { auto& realm = *vm.current_realm(); auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, forward(args)..., *prototype)); + return realm.heap().allocate(realm, forward(args)..., *prototype); } // 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp index ce73fdac7e..b1b55bdbf4 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr AggregateError::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().aggregate_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().aggregate_error_prototype()); } AggregateError::AggregateError(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 204628bf17..90d5ca057c 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -32,7 +32,7 @@ ThrowCompletionOr> Array::create(Realm& realm, u64 length, O // 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »). // 4. Set A.[[Prototype]] to proto. // 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1. - auto array = MUST_OR_THROW_OOM(realm.heap().allocate(realm, *prototype)); + auto array = realm.heap().allocate(realm, *prototype); // 6. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }). MUST(array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false })); diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index bd4b3c5065..8e3ef6eff8 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -17,17 +17,17 @@ ThrowCompletionOr> ArrayBuffer::create(Realm& realm, s if (buffer.is_error()) return realm.vm().throw_completion(ErrorType::NotEnoughMemoryToAllocate, byte_length); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, buffer.release_value(), realm.intrinsics().array_buffer_prototype())); + return realm.heap().allocate(realm, buffer.release_value(), realm.intrinsics().array_buffer_prototype()); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer buffer) { - return realm.heap().allocate(realm, move(buffer), realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, move(buffer), realm.intrinsics().array_buffer_prototype()); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer* buffer) { - return realm.heap().allocate(realm, buffer, realm.intrinsics().array_buffer_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, buffer, realm.intrinsics().array_buffer_prototype()); } ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp index 662a679667..e2d5ac9980 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, array, iteration_kind, realm.intrinsics().array_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, array, iteration_kind, realm.intrinsics().array_iterator_prototype()); } ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index a28fe0f908..ab18c3ce70 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr AsyncFromSyncIterator::create(Realm& realm, IteratorRecord sync_iterator_record) { - return realm.heap().allocate(realm, realm, sync_iterator_record).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, sync_iterator_record); } AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, IteratorRecord sync_iterator_record) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index d718666e2e..6daa34bf50 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -14,12 +14,12 @@ namespace JS { -ThrowCompletionOr AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object) +NonnullGCPtr AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object) { auto top_level_promise = Promise::create(realm); // Note: This generates a handle to itself, which it clears upon completing its execution // The top_level_promise is also kept alive by this Wrapper - auto wrapper = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *generator_object, *top_level_promise)); + auto wrapper = realm.heap().allocate(realm, realm, *generator_object, *top_level_promise); // Prime the generator: // This runs until the first `await value;` wrapper->continue_async_execution(realm.vm(), js_undefined(), true, IsInitialExecution::Yes); diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h index 7f3fd38514..5ddcd86ec0 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h @@ -23,7 +23,7 @@ public: Yes, }; - static ThrowCompletionOr create(Realm&, GeneratorObject*); + [[nodiscard]] static NonnullGCPtr create(Realm&, GeneratorObject*); virtual ~AsyncFunctionDriverWrapper() override = default; void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp index 178fdde703..58f8aa7f86 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGenerator.cpp @@ -20,7 +20,7 @@ ThrowCompletionOr> AsyncGenerator::create(Realm& re // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) auto generating_function_prototype = TRY(generating_function->get(vm.names.prototype)); auto generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm)); - auto object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context))); + auto object = realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context)); object->m_generating_function = generating_function; object->m_frame = move(frame); object->m_previous_value = initial_value; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp index bdb946df7a..c0e7b73934 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BigIntObject::create(Realm& realm, BigInt& bigint) { - return realm.heap().allocate(realm, bigint, realm.intrinsics().bigint_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, bigint, realm.intrinsics().bigint_prototype()); } BigIntObject::BigIntObject(BigInt& bigint, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp index edf2262a3a..37d9f0ca80 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BooleanObject::create(Realm& realm, bool value) { - return realm.heap().allocate(realm, value, realm.intrinsics().boolean_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, value, realm.intrinsics().boolean_prototype()); } BooleanObject::BooleanObject(bool value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index 6c0bc8d7cb..82e34d745f 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -26,7 +26,7 @@ ThrowCompletionOr> BoundFunction::create(Realm& real // 7. Set obj.[[BoundTargetFunction]] to targetFunction. // 8. Set obj.[[BoundThis]] to boundThis. // 9. Set obj.[[BoundArguments]] to boundArgs. - auto object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype)); + auto object = realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype); // 10. Return obj. return object; diff --git a/Userland/Libraries/LibJS/Runtime/DataView.cpp b/Userland/Libraries/LibJS/Runtime/DataView.cpp index 6249eb9dcd..905e553772 100644 --- a/Userland/Libraries/LibJS/Runtime/DataView.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataView.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset) { - return realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, realm.intrinsics().data_view_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, realm.intrinsics().data_view_prototype()); } DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index c64e61b40f..655c57b105 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -25,7 +25,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast(ns_per_day) NonnullGCPtr Date::create(Realm& realm, double date_value) { - return realm.heap().allocate(realm, date_value, realm.intrinsics().date_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, date_value, realm.intrinsics().date_prototype()); } Date::Date(double date_value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 670fa03ab9..e3867e11db 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -48,12 +48,12 @@ NonnullGCPtr ECMAScriptFunctionObject::create(Realm& r prototype = realm.intrinsics().async_generator_function_prototype(); break; } - return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } NonnullGCPtr ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Vector local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) { - return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector formal_parameters, i32 function_length, Vector local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) @@ -118,7 +118,7 @@ void ECMAScriptFunctionObject::initialize(Realm& realm) Object* prototype = nullptr; switch (m_kind) { case FunctionKind::Normal: - prototype = MUST(vm.heap().allocate(realm, realm.intrinsics().new_ordinary_function_prototype_object_shape())); + prototype = vm.heap().allocate(realm, realm.intrinsics().new_ordinary_function_prototype_object_shape()); MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true })); break; case FunctionKind::Generator: @@ -1088,7 +1088,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() // NOTE: Async functions are entirely transformed to generator functions, and wrapped in a custom driver that returns a promise // See AwaitExpression::generate_bytecode() for the transformation. if (m_kind == FunctionKind::Async) - return { Completion::Type::Return, TRY(AsyncFunctionDriverWrapper::create(realm, generator_object)), {} }; + return { Completion::Type::Return, AsyncFunctionDriverWrapper::create(realm, generator_object), {} }; VERIFY(m_kind == FunctionKind::Generator); return { Completion::Type::Return, generator_object, {} }; diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index 1d43647d9c..92795ccc27 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -32,7 +32,7 @@ SourceRange const& TracebackFrame::source_range() const NonnullGCPtr Error::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().error_prototype()); } NonnullGCPtr Error::create(Realm& realm, String message) @@ -119,29 +119,29 @@ ThrowCompletionOr Error::stack_string(VM& vm) const return stack_string_builder.to_string(); } -#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - NonnullGCPtr ClassName::create(Realm& realm) \ - { \ - return realm.heap().allocate(realm, realm.intrinsics().snake_name##_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \ - } \ - \ - NonnullGCPtr ClassName::create(Realm& realm, String message) \ - { \ - auto& vm = realm.vm(); \ - auto error = ClassName::create(realm); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - error->define_direct_property(vm.names.message, PrimitiveString::create(vm, move(message)), attr); \ - return error; \ - } \ - \ - ThrowCompletionOr> ClassName::create(Realm& realm, StringView message) \ - { \ - return create(realm, TRY_OR_THROW_OOM(realm.vm(), String::from_utf8(message))); \ - } \ - \ - ClassName::ClassName(Object& prototype) \ - : Error(prototype) \ - { \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + NonnullGCPtr ClassName::create(Realm& realm) \ + { \ + return realm.heap().allocate(realm, realm.intrinsics().snake_name##_prototype()); \ + } \ + \ + NonnullGCPtr ClassName::create(Realm& realm, String message) \ + { \ + auto& vm = realm.vm(); \ + auto error = ClassName::create(realm); \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + error->define_direct_property(vm.names.message, PrimitiveString::create(vm, move(message)), attr); \ + return error; \ + } \ + \ + ThrowCompletionOr> ClassName::create(Realm& realm, StringView message) \ + { \ + return create(realm, TRY_OR_THROW_OOM(realm.vm(), String::from_utf8(message))); \ + } \ + \ + ClassName::ClassName(Object& prototype) \ + : Error(prototype) \ + { \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 1c7fc6e9bf..6dc17b279e 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -28,7 +28,7 @@ ThrowCompletionOr> GeneratorObject::create(Realm& generating_function_prototype = TRY(generating_function->get(vm.names.prototype)); } auto generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm)); - auto object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context))); + auto object = realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context)); object->m_generating_function = generating_function; object->m_frame = move(frame); object->m_previous_value = initial_value; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index ce573ff057..52ed7123a6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { NonnullGCPtr CollatorCompareFunction::create(Realm& realm, Collator& collator) { - return realm.heap().allocate(realm, realm, collator).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, collator); } CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 11e93ed387..6eebeb635b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { // 11.5.4 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions NonnullGCPtr DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format) { - return realm.heap().allocate(realm, date_time_format, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, date_time_format, realm.intrinsics().function_prototype()); } DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index 1e0ec59743..23b697baf3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { ThrowCompletionOr> Locale::create(Realm& realm, ::Locale::LocaleID locale_id) { - auto locale = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm.intrinsics().intl_locale_prototype())); + auto locale = realm.heap().allocate(realm, realm.intrinsics().intl_locale_prototype()); locale->set_locale(TRY_OR_THROW_OOM(realm.vm(), locale_id.to_string())); for (auto& extension : locale_id.extensions) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index 16cfadb39f..8e8e6433a3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { // 15.5.2 Number Format Functions, https://tc39.es/ecma402/#sec-number-format-functions NonnullGCPtr NumberFormatFunction::create(Realm& realm, NumberFormat& number_format) { - return realm.heap().allocate(realm, number_format, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, number_format, realm.intrinsics().function_prototype()); } NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index 756293f580..9fd403db5d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -19,7 +19,7 @@ NonnullGCPtr SegmentIterator::create(Realm& realm, Segmenter& s // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return realm.heap().allocate(realm, realm, segmenter, move(string), segments).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, segmenter, move(string), segments); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp index e6d1cf9819..b62e99f094 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -18,7 +18,7 @@ NonnullGCPtr Segments::create(Realm& realm, Segmenter& segmenter, Utf1 // 3. Set segments.[[SegmentsSegmenter]] to segmenter. // 4. Set segments.[[SegmentsString]] to string. // 5. Return segments. - return realm.heap().allocate(realm, realm, segmenter, move(string)).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, segmenter, move(string)); } // 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index 48a603066d..40502e234c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -194,27 +194,27 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) #define __JS_ENUMERATE(ClassName, snake_name) \ VERIFY(!m_##snake_name##_prototype); \ - m_##snake_name##_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_##snake_name##_prototype = heap().allocate(realm, realm); JS_ENUMERATE_ITERATOR_PROTOTYPES #undef __JS_ENUMERATE // These must be initialized separately as they have no companion constructor - m_async_from_sync_iterator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_async_generator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_generator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_intl_segments_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_wrap_for_valid_iterator_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_async_from_sync_iterator_prototype = heap().allocate(realm, realm); + m_async_generator_prototype = heap().allocate(realm, realm); + m_generator_prototype = heap().allocate(realm, realm); + m_intl_segments_prototype = heap().allocate(realm, realm); + m_wrap_for_valid_iterator_prototype = heap().allocate(realm, realm); // These must be initialized before allocating... // - AggregateErrorPrototype, which uses ErrorPrototype as its prototype // - AggregateErrorConstructor, which uses ErrorConstructor as its prototype // - AsyncFunctionConstructor, which uses FunctionConstructor as its prototype - m_error_prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_error_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); - m_function_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_error_prototype = heap().allocate(realm, realm); + m_error_constructor = heap().allocate(realm, realm); + m_function_constructor = heap().allocate(realm, realm); // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype - m_proxy_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_proxy_constructor = heap().allocate(realm, realm); // Global object functions m_eval_function = NativeFunction::create(realm, GlobalObject::eval, 1, vm.names.eval, &realm); @@ -229,7 +229,7 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) m_escape_function = NativeFunction::create(realm, GlobalObject::escape, 1, vm.names.escape, &realm); m_unescape_function = NativeFunction::create(realm, GlobalObject::unescape, 1, vm.names.unescape, &realm); - m_object_constructor = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + m_object_constructor = heap().allocate(realm, realm); // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror% m_throw_type_error_function = NativeFunction::create( @@ -274,52 +274,52 @@ constexpr inline bool IsTypedArrayConstructor = false; JS_ENUMERATE_TYPED_ARRAYS #undef __JS_ENUMERATE -#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \ - void Intrinsics::initialize_##snake_namespace##snake_name() \ - { \ - auto& vm = this->vm(); \ - \ - VERIFY(!m_##snake_namespace##snake_name##_prototype); \ - VERIFY(!m_##snake_namespace##snake_name##_constructor); \ - if constexpr (IsTypedArrayConstructor) { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, *typed_array_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm, *typed_array_constructor()).release_allocated_value_but_fixme_should_propagate_errors(); \ - } else { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ - } \ - \ - /* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \ - if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else if constexpr (IsSame) \ - initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - else \ - initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ - } \ - \ - NonnullGCPtr Intrinsics::snake_namespace##snake_name##_constructor() \ - { \ - if (!m_##snake_namespace##snake_name##_constructor) \ - initialize_##snake_namespace##snake_name(); \ - return *m_##snake_namespace##snake_name##_constructor; \ - } \ - \ - NonnullGCPtr Intrinsics::snake_namespace##snake_name##_prototype() \ - { \ - if (!m_##snake_namespace##snake_name##_prototype) \ - initialize_##snake_namespace##snake_name(); \ - return *m_##snake_namespace##snake_name##_prototype; \ +#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \ + void Intrinsics::initialize_##snake_namespace##snake_name() \ + { \ + auto& vm = this->vm(); \ + \ + VERIFY(!m_##snake_namespace##snake_name##_prototype); \ + VERIFY(!m_##snake_namespace##snake_name##_constructor); \ + if constexpr (IsTypedArrayConstructor) { \ + m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, *typed_array_prototype()); \ + m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm, *typed_array_constructor()); \ + } else { \ + m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, m_realm); \ + m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm); \ + } \ + \ + /* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \ + if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else if constexpr (IsSame) \ + initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + else \ + initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \ + } \ + \ + NonnullGCPtr Intrinsics::snake_namespace##snake_name##_constructor() \ + { \ + if (!m_##snake_namespace##snake_name##_constructor) \ + initialize_##snake_namespace##snake_name(); \ + return *m_##snake_namespace##snake_name##_constructor; \ + } \ + \ + NonnullGCPtr Intrinsics::snake_namespace##snake_name##_prototype() \ + { \ + if (!m_##snake_namespace##snake_name##_prototype) \ + initialize_##snake_namespace##snake_name(); \ + return *m_##snake_namespace##snake_name##_prototype; \ } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ @@ -339,12 +339,12 @@ JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE_INNER -#define __JS_ENUMERATE(ClassName, snake_name) \ - NonnullGCPtr Intrinsics::snake_name##_object() \ - { \ - if (!m_##snake_name##_object) \ - m_##snake_name##_object = heap().allocate(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \ - return *m_##snake_name##_object; \ +#define __JS_ENUMERATE(ClassName, snake_name) \ + NonnullGCPtr Intrinsics::snake_name##_object() \ + { \ + if (!m_##snake_name##_object) \ + m_##snake_name##_object = heap().allocate(m_realm, m_realm); \ + return *m_##snake_name##_object; \ } JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS #undef __JS_ENUMERATE diff --git a/Userland/Libraries/LibJS/Runtime/Iterator.cpp b/Userland/Libraries/LibJS/Runtime/Iterator.cpp index 2cb4447c25..8a1f2ce746 100644 --- a/Userland/Libraries/LibJS/Runtime/Iterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Iterator.cpp @@ -15,9 +15,9 @@ namespace JS { -ThrowCompletionOr> Iterator::create(Realm& realm, Object& prototype, IteratorRecord iterated) +NonnullGCPtr Iterator::create(Realm& realm, Object& prototype, IteratorRecord iterated) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, prototype, move(iterated))); + return realm.heap().allocate(realm, prototype, move(iterated)); } Iterator::Iterator(Object& prototype, IteratorRecord iterated) diff --git a/Userland/Libraries/LibJS/Runtime/Iterator.h b/Userland/Libraries/LibJS/Runtime/Iterator.h index f826ca3876..fefa8fc57e 100644 --- a/Userland/Libraries/LibJS/Runtime/Iterator.h +++ b/Userland/Libraries/LibJS/Runtime/Iterator.h @@ -27,7 +27,7 @@ class Iterator : public Object { JS_OBJECT(Iterator, Object); public: - static ThrowCompletionOr> create(Realm&, Object& prototype, IteratorRecord iterated); + static NonnullGCPtr create(Realm&, Object& prototype, IteratorRecord iterated); IteratorRecord const& iterated() const { return m_iterated; } diff --git a/Userland/Libraries/LibJS/Runtime/IteratorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/IteratorConstructor.cpp index 8ad7ff1ad8..1b104e84a9 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorConstructor.cpp @@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorConstructor::from) // 4. Let wrapper be OrdinaryObjectCreate(%WrapForValidIteratorPrototype%, « [[Iterated]] »). // 5. Set wrapper.[[Iterated]] to iteratorRecord. - auto wrapper = MUST_OR_THROW_OOM(Iterator::create(realm, realm.intrinsics().wrap_for_valid_iterator_prototype(), move(iterator_record))); + auto wrapper = Iterator::create(realm, realm.intrinsics().wrap_for_valid_iterator_prototype(), move(iterator_record)); // 6. Return wrapper. return wrapper; diff --git a/Userland/Libraries/LibJS/Runtime/IteratorHelper.cpp b/Userland/Libraries/LibJS/Runtime/IteratorHelper.cpp index 011e1439b8..345ec4ca15 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorHelper.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorHelper.cpp @@ -13,7 +13,7 @@ namespace JS { ThrowCompletionOr> IteratorHelper::create(Realm& realm, IteratorRecord underlying_iterator, Closure closure, Optional abrupt_closure) { - return TRY(realm.heap().allocate(realm, realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), move(closure), move(abrupt_closure))); + return realm.heap().allocate(realm, realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), move(closure), move(abrupt_closure)); } IteratorHelper::IteratorHelper(Realm& realm, Object& prototype, IteratorRecord underlying_iterator, Closure closure, Optional abrupt_closure) diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 7788489422..c7c84cf8d3 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -439,7 +439,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::flat_map) // 4. Let iterated be ? GetIteratorDirect(O). auto iterated = TRY(get_iterator_direct(vm, object)); - auto flat_map_iterator = MUST_OR_THROW_OOM(vm.heap().allocate(realm)); + auto flat_map_iterator = vm.heap().allocate(realm); // 5. Let closure be a new Abstract Closure with no parameters that captures iterated and mapper and performs the following steps when called: IteratorHelper::Closure closure = [flat_map_iterator, mapper = NonnullGCPtr { mapper.as_function() }](auto& vm, auto& iterator) mutable -> ThrowCompletionOr { diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp index 6bc86460ab..7ec3ec8966 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.cpp +++ b/Userland/Libraries/LibJS/Runtime/Map.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Map::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().map_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().map_prototype()); } Map::Map(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp index 79442203c7..99c17b52a3 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, map, iteration_kind, realm.intrinsics().map_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, map, iteration_kind, realm.intrinsics().map_iterator_prototype()); } MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index 2af038f072..54cd62ff8b 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -36,7 +36,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf // 7. Set func.[[Extensible]] to true. // 8. Set func.[[Realm]] to realm. // 9. Set func.[[InitialName]] to null. - auto function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()).release_allocated_value_but_fixme_should_propagate_errors(); + auto function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()); // 10. Perform SetFunctionLength(func, length). function->set_function_length(length); @@ -53,7 +53,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf NonnullGCPtr NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, SafeFunction(VM&)> function) { - return realm.heap().allocate(realm, name, move(function), realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, name, move(function), realm.intrinsics().function_prototype()); } NativeFunction::NativeFunction(SafeFunction(VM&)> native_function, Object* prototype, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp index 343f93f735..632d0b99d7 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr NumberObject::create(Realm& realm, double value) { - return realm.heap().allocate(realm, value, realm.intrinsics().number_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, value, realm.intrinsics().number_prototype()); } NumberObject::NumberObject(double value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index a34ae29d98..79f3e31e4a 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -29,10 +29,10 @@ static HashMap, HashMap Object::create(Realm& realm, Object* prototype) { if (!prototype) - return realm.heap().allocate(realm, realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().empty_object_shape()); if (prototype == realm.intrinsics().object_prototype()) - return realm.heap().allocate(realm, realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors(); - return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().new_object_shape()); + return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype); } Object::Object(GlobalObjectTag, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index 1cdf32ccfd..51eb1f078f 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr promise_resolve(VM& vm, Object& constructor, Value va NonnullGCPtr Promise::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().promise_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().promise_prototype()); } // 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects diff --git a/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp b/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp index 427442771a..4fa80c7d7a 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp @@ -59,7 +59,7 @@ ThrowCompletionOr> new_promise_capability(VM& vm // 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1). // 3. Let resolvingFunctions be the Record { [[Resolve]]: undefined, [[Reject]]: undefined }. - auto resolving_functions = TRY(vm.heap().allocate(realm)); + auto resolving_functions = vm.heap().allocate(realm); // 4. Let executorClosure be a new Abstract Closure with parameters (resolve, reject) that captures resolvingFunctions and performs the following steps when called: auto executor_closure = [resolving_functions](auto& vm) -> ThrowCompletionOr { diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 99499971e2..c62f8f955c 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -55,7 +55,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor) NonnullGCPtr PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -87,7 +87,7 @@ ThrowCompletionOr PromiseAllResolveElementFunction::resolve_element() NonnullGCPtr PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -128,7 +128,7 @@ ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_elemen NonnullGCPtr PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -169,7 +169,7 @@ ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element NonnullGCPtr PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return realm.heap().allocate(realm, index, errors, capability, remaining_elements, realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, index, errors, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp index d0b636731b..d4d178d963 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function) { - return realm.heap().allocate(realm, promise, already_resolved, move(function), realm.intrinsics().function_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, promise, already_resolved, move(function), realm.intrinsics().function_prototype()); } PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index e3f270fcd2..c91b06c1ba 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -17,7 +17,7 @@ namespace JS { NonnullGCPtr ProxyObject::create(Realm& realm, Object& target, Object& handler) { - return realm.heap().allocate(realm, target, handler, realm.intrinsics().object_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, target, handler, realm.intrinsics().object_prototype()); } ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index d05d7e6294..6d41cdf058 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -132,12 +132,12 @@ ThrowCompletionOr parse_regex_pattern(VM& vm, StringView patte NonnullGCPtr RegExpObject::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().regexp_prototype()); } NonnullGCPtr RegExpObject::create(Realm& realm, Regex regex, DeprecatedString pattern, DeprecatedString flags) { - return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype()); } RegExpObject::RegExpObject(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp index c0074c5c11..1c90485934 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { // 22.2.9.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator NonnullGCPtr RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode) { - return realm.heap().allocate(realm, realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode); } RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode) diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index ab39498fc9..c603ba3749 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Set::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().set_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().set_prototype()); } Set::Set(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp index 120c98a332..cdef48b2d8 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind) { - return realm.heap().allocate(realm, set, iteration_kind, realm.intrinsics().set_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, set, iteration_kind, realm.intrinsics().set_iterator_prototype()); } SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 65c9e96bae..f616e2d320 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -79,7 +79,7 @@ ThrowCompletionOr> StringConstructor::construct(FunctionObj // 4. Return StringCreate(s, ? GetPrototypeFromConstructor(NewTarget, "%String.prototype%")). auto* prototype = TRY(get_prototype_from_constructor(vm, new_target, &Intrinsics::string_prototype)); - return MUST_OR_THROW_OOM(StringObject::create(realm, *primitive_string, *prototype)); + return StringObject::create(realm, *primitive_string, *prototype); } // 22.1.2.1 String.fromCharCode ( ...codeUnits ), https://tc39.es/ecma262/#sec-string.fromcharcode diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp index e559728648..e7b790cea2 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr StringIterator::create(Realm& realm, String string) { - return realm.heap().allocate(realm, move(string), realm.intrinsics().string_iterator_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, move(string), realm.intrinsics().string_iterator_prototype()); } StringIterator::StringIterator(String string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 75fb3aeb09..ea04c0f994 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -15,7 +15,7 @@ namespace JS { // 10.4.3.4 StringCreate ( value, prototype ), https://tc39.es/ecma262/#sec-stringcreate -ThrowCompletionOr> StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype) +NonnullGCPtr StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype) { // 1. Let S be MakeBasicObject(« [[Prototype]], [[Extensible]], [[StringData]] »). // 2. Set S.[[Prototype]] to prototype. @@ -26,7 +26,7 @@ ThrowCompletionOr> StringObject::create(Realm& realm, // 7. Let length be the length of value. // 8. Perform ! DefinePropertyOrThrow(S, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }). // 9. Return S. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, primitive_string, prototype)); + return realm.heap().allocate(realm, primitive_string, prototype); } StringObject::StringObject(PrimitiveString& string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.h b/Userland/Libraries/LibJS/Runtime/StringObject.h index 5774681933..9be24bcea0 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.h +++ b/Userland/Libraries/LibJS/Runtime/StringObject.h @@ -14,7 +14,7 @@ class StringObject : public Object { JS_OBJECT(StringObject, Object); public: - static ThrowCompletionOr> create(Realm&, PrimitiveString&, Object& prototype); + [[nodiscard]] static NonnullGCPtr create(Realm&, PrimitiveString&, Object& prototype); virtual void initialize(Realm&) override; virtual ~StringObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp index b98ce1a46f..92f463bce6 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedError.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr SuppressedError::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().suppressed_error_prototype()); } SuppressedError::SuppressedError(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp index 37b4f506b2..a727bb43b9 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr SymbolObject::create(Realm& realm, Symbol& primitive_symbol) { - return realm.heap().allocate(realm, primitive_symbol, realm.intrinsics().symbol_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, primitive_symbol, realm.intrinsics().symbol_prototype()); } SymbolObject::SymbolObject(Symbol& symbol, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index 54a79d362a..dd69f8a5df 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -36,7 +36,7 @@ void Temporal::initialize(Realm& realm) define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.Now, MUST(heap().allocate(realm, realm)), attr); + define_direct_property(vm.names.Now, heap().allocate(realm, realm), attr); define_intrinsic_accessor(vm.names.Calendar, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_calendar_constructor(); }); define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); }); define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); }); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index c21d9022dd..202f72061d 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -419,137 +419,137 @@ void TypedArrayBase::visit_edges(Visitor& visitor) visitor.visit(m_viewed_array_buffer); } -#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \ - ThrowCompletionOr> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \ - { \ - auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \ - auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, *prototype, length, *array_buffer)); \ - } \ - \ - ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ - { \ - auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ - return create(realm, length, *array_buffer); \ - } \ - \ - NonnullGCPtr ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \ - { \ - return realm.heap().allocate(realm, realm.intrinsics().snake_name##_prototype(), length, array_buffer).release_allocated_value_but_fixme_should_propagate_errors(); \ - } \ - \ - ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ - : TypedArray(prototype, \ - bit_cast(&Intrinsics::snake_name##_constructor), length, array_buffer) \ - { \ - if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \ - m_content_type = ContentType::BigInt; \ - else \ - m_content_type = ContentType::Number; \ - } \ - \ - ClassName::~ClassName() \ - { \ - } \ - \ - DeprecatedFlyString const& ClassName::element_name() const \ - { \ - return vm().names.ClassName.as_string(); \ - } \ - \ - PrototypeName::PrototypeName(Object& prototype) \ - : Object(ConstructWithPrototypeTag::Tag, prototype) \ - { \ - } \ - \ - PrototypeName::~PrototypeName() \ - { \ - } \ - \ - void PrototypeName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - Base::initialize(realm); \ - define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ - } \ - \ - ConstructorName::ConstructorName(Realm& realm, Object& prototype) \ - : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \ - { \ - } \ - \ - ConstructorName::~ConstructorName() \ - { \ - } \ - \ - void ConstructorName::initialize(Realm& realm) \ - { \ - auto& vm = this->vm(); \ - Base::initialize(realm); \ - \ - /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \ - define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \ - \ - /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \ - define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ - \ - define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \ - } \ - \ - /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - ThrowCompletionOr ConstructorName::call() \ - { \ - auto& vm = this->vm(); \ - return vm.throw_completion(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ - } \ - \ - /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ - ThrowCompletionOr> ConstructorName::construct(FunctionObject& new_target) \ - { \ - auto& vm = this->vm(); \ - auto& realm = *vm.current_realm(); \ - \ - if (vm.argument_count() == 0) \ - return TRY(ClassName::create(realm, 0, new_target)); \ - \ - auto first_argument = vm.argument(0); \ - if (first_argument.is_object()) { \ - auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \ - if (first_argument.as_object().is_typed_array()) { \ - auto& arg_typed_array = static_cast(first_argument.as_object()); \ - TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \ - } else if (is(first_argument.as_object())) { \ - auto& array_buffer = static_cast(first_argument.as_object()); \ - TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \ - vm.argument(1), vm.argument(2))); \ - } else { \ - auto iterator = TRY(first_argument.get_method(vm, vm.well_known_symbol_iterator())); \ - if (iterator) { \ - auto values = TRY(iterator_to_list(vm, TRY(get_iterator_from_method(vm, first_argument, *iterator)))); \ - TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \ - } else { \ - TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \ - } \ - } \ - return typed_array; \ - } \ - \ - auto array_length_or_error = first_argument.to_index(vm); \ - if (array_length_or_error.is_error()) { \ - auto error = array_length_or_error.release_error(); \ - if (error.value()->is_object() && is(error.value()->as_object())) { \ - /* Re-throw more specific RangeError */ \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - } \ - return error; \ - } \ - auto array_length = array_length_or_error.release_value(); \ - if (array_length > NumericLimits::max() / sizeof(Type)) \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - /* FIXME: What is the best/correct behavior here? */ \ - if (Checked::multiplication_would_overflow(array_length, sizeof(Type))) \ - return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ - return TRY(ClassName::create(realm, array_length, new_target)); \ +#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \ + ThrowCompletionOr> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \ + { \ + auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \ + auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ + return realm.heap().allocate(realm, *prototype, length, *array_buffer); \ + } \ + \ + ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ + { \ + auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ + return create(realm, length, *array_buffer); \ + } \ + \ + NonnullGCPtr ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \ + { \ + return realm.heap().allocate(realm, realm.intrinsics().snake_name##_prototype(), length, array_buffer); \ + } \ + \ + ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ + : TypedArray(prototype, \ + bit_cast(&Intrinsics::snake_name##_constructor), length, array_buffer) \ + { \ + if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \ + m_content_type = ContentType::BigInt; \ + else \ + m_content_type = ContentType::Number; \ + } \ + \ + ClassName::~ClassName() \ + { \ + } \ + \ + DeprecatedFlyString const& ClassName::element_name() const \ + { \ + return vm().names.ClassName.as_string(); \ + } \ + \ + PrototypeName::PrototypeName(Object& prototype) \ + : Object(ConstructWithPrototypeTag::Tag, prototype) \ + { \ + } \ + \ + PrototypeName::~PrototypeName() \ + { \ + } \ + \ + void PrototypeName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + Base::initialize(realm); \ + define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ + } \ + \ + ConstructorName::ConstructorName(Realm& realm, Object& prototype) \ + : TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \ + { \ + } \ + \ + ConstructorName::~ConstructorName() \ + { \ + } \ + \ + void ConstructorName::initialize(Realm& realm) \ + { \ + auto& vm = this->vm(); \ + Base::initialize(realm); \ + \ + /* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \ + define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \ + \ + /* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \ + define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ + \ + define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \ + } \ + \ + /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ + ThrowCompletionOr ConstructorName::call() \ + { \ + auto& vm = this->vm(); \ + return vm.throw_completion(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ + } \ + \ + /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ + ThrowCompletionOr> ConstructorName::construct(FunctionObject& new_target) \ + { \ + auto& vm = this->vm(); \ + auto& realm = *vm.current_realm(); \ + \ + if (vm.argument_count() == 0) \ + return TRY(ClassName::create(realm, 0, new_target)); \ + \ + auto first_argument = vm.argument(0); \ + if (first_argument.is_object()) { \ + auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \ + if (first_argument.as_object().is_typed_array()) { \ + auto& arg_typed_array = static_cast(first_argument.as_object()); \ + TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \ + } else if (is(first_argument.as_object())) { \ + auto& array_buffer = static_cast(first_argument.as_object()); \ + TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \ + vm.argument(1), vm.argument(2))); \ + } else { \ + auto iterator = TRY(first_argument.get_method(vm, vm.well_known_symbol_iterator())); \ + if (iterator) { \ + auto values = TRY(iterator_to_list(vm, TRY(get_iterator_from_method(vm, first_argument, *iterator)))); \ + TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \ + } else { \ + TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \ + } \ + } \ + return typed_array; \ + } \ + \ + auto array_length_or_error = first_argument.to_index(vm); \ + if (array_length_or_error.is_error()) { \ + auto error = array_length_or_error.release_error(); \ + if (error.value()->is_object() && is(error.value()->as_object())) { \ + /* Re-throw more specific RangeError */ \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + } \ + return error; \ + } \ + auto array_length = array_length_or_error.release_value(); \ + if (array_length > NumericLimits::max() / sizeof(Type)) \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + /* FIXME: What is the best/correct behavior here? */ \ + if (Checked::multiplication_would_overflow(array_length, sizeof(Type))) \ + return vm.throw_completion(ErrorType::InvalidLength, "typed array"); \ + return TRY(ClassName::create(realm, array_length, new_target)); \ } #undef __JS_ENUMERATE diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index b6cab1da15..42147d823d 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -566,7 +566,7 @@ ThrowCompletionOr> Value::to_object(VM& vm) const // String case STRING_TAG: // Return a new String object whose [[StringData]] internal slot is set to argument. See 22.1 for a description of String objects. - return MUST_OR_THROW_OOM(StringObject::create(realm, const_cast(as_string()), realm.intrinsics().string_prototype())); + return StringObject::create(realm, const_cast(as_string()), realm.intrinsics().string_prototype()); // Symbol case SYMBOL_TAG: // Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 20.4 for a description of Symbol objects. diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp index e17d342858..e8ea40a0a9 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakMap::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().weak_map_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().weak_map_prototype()); } WeakMap::WeakMap(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp index 10c8762321..05a745878d 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp @@ -10,12 +10,12 @@ namespace JS { NonnullGCPtr WeakRef::create(Realm& realm, Object& value) { - return realm.heap().allocate(realm, value, realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, value, realm.intrinsics().weak_ref_prototype()); } NonnullGCPtr WeakRef::create(Realm& realm, Symbol& value) { - return realm.heap().allocate(realm, value, realm.intrinsics().weak_ref_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, value, realm.intrinsics().weak_ref_prototype()); } WeakRef::WeakRef(Object& value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp index 5efa3bf020..be911056bd 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakSet::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().weak_set_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm.intrinsics().weak_set_prototype()); } WeakSet::WeakSet(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp index 1869384410..4234568663 100644 --- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr> WrappedFunction::create(Realm& // 5. Set wrapped.[[WrappedTargetFunction]] to Target. // 6. Set wrapped.[[Realm]] to callerRealm. auto& prototype = *caller_realm.intrinsics().function_prototype(); - auto wrapped = MUST_OR_THROW_OOM(vm.heap().allocate(realm, caller_realm, target, prototype)); + auto wrapped = vm.heap().allocate(realm, caller_realm, target, prototype); // 7. Let result be CopyNameAndLength(wrapped, Target). auto result = copy_name_and_length(vm, *wrapped, target); diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index 3585cd0de9..8d204ca8ec 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -292,7 +292,7 @@ inline JSFileResult TestRunner::run_file_test(DeprecatedString const& test_path) *g_vm, [&](JS::Realm& realm_) -> JS::GlobalObject* { realm = &realm_; - global_object = g_vm->heap().allocate(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors(); + global_object = g_vm->heap().allocate(*realm, *realm); return global_object; }, nullptr)); diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index bb7895612c..dd42da33e8 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -174,7 +174,7 @@ ErrorOr initialize_main_thread_vm() /* .promise = */ promise, /* .reason = */ promise.result(), }; - auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), HTML::EventNames::rejectionhandled, event_init).release_value_but_fixme_should_propagate_errors(); + auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), HTML::EventNames::rejectionhandled, event_init); window.dispatch_event(promise_rejection_event); }); break; diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 9fd74eaa80..89a116604a 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -53,7 +53,7 @@ JS::ThrowCompletionOr> OptionConstructor::construct if (vm.argument_count() > 0) { auto text = TRY(vm.argument(0).to_deprecated_string(vm)); if (!text.is_empty()) { - auto new_text_node = MUST_OR_THROW_OOM(vm.heap().allocate(realm, document, text)); + auto new_text_node = vm.heap().allocate(realm, document, text); MUST(option_element->append_child(*new_text_node)); } } diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index 3514169609..30114d6c9d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -14,9 +14,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) +JS::NonnullGCPtr CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(font_face))); + return realm.heap().allocate(realm, realm, move(font_face)); } CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h index b467045efd..6986b3ae99 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -16,7 +16,7 @@ class CSSFontFaceRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FontFace&&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FontFace&&); virtual ~CSSFontFaceRule() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 9431043444..568e2e623b 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -19,10 +19,10 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSImportRule::create(AK::URL url, DOM::Document& document) +JS::NonnullGCPtr CSSImportRule::create(AK::URL url, DOM::Document& document) { auto& realm = document.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, move(url), document)); + return realm.heap().allocate(realm, move(url), document); } CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index c11b07a21a..9687ca070e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -22,7 +22,7 @@ class CSSImportRule final WEB_PLATFORM_OBJECT(CSSImportRule, CSSRule); public: - static WebIDL::ExceptionOr> create(AK::URL, DOM::Document&); + [[nodiscard]] static JS::NonnullGCPtr create(AK::URL, DOM::Document&); virtual ~CSSImportRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp index 3724d46ccc..cbeb924583 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp @@ -11,9 +11,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations) +JS::NonnullGCPtr CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, key, declarations)); + return realm.heap().allocate(realm, realm, key, declarations); } void CSSKeyframeRule::visit_edges(Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h index ba49322c76..36d76a8f5c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSKeyframeRule.h @@ -20,7 +20,7 @@ class CSSKeyframeRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule); public: - static WebIDL::ExceptionOr> create(JS::Realm& realm, CSS::Percentage key, CSSStyleDeclaration& declarations); + static JS::NonnullGCPtr create(JS::Realm&, CSS::Percentage key, CSSStyleDeclaration&); virtual ~CSSKeyframeRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp index a9e7bf25e2..5d9d5fbea4 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp @@ -10,9 +10,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSKeyframesRule::create(JS::Realm& realm, AK::FlyString name, Vector> keyframes) +JS::NonnullGCPtr CSSKeyframesRule::create(JS::Realm& realm, AK::FlyString name, Vector> keyframes) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(name), move(keyframes))); + return realm.heap().allocate(realm, realm, move(name), move(keyframes)); } void CSSKeyframesRule::visit_edges(Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.h b/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.h index ab074f1b7a..741287c128 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSKeyframesRule.h @@ -21,7 +21,7 @@ class CSSKeyframesRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule); public: - static WebIDL::ExceptionOr> create(JS::Realm& realm, FlyString name, Vector> keyframes); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString name, Vector>); virtual ~CSSKeyframesRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp index 83720bfecc..b21fcecd06 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp @@ -12,9 +12,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules) +JS::NonnullGCPtr CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, media_queries, rules)); + return realm.heap().allocate(realm, realm, media_queries, rules); } CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules) diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h index 492ecc8ace..ce3a496168 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h @@ -18,7 +18,7 @@ class CSSMediaRule final : public CSSConditionRule { WEB_PLATFORM_OBJECT(CSSMediaRule, CSSConditionRule); public: - static WebIDL::ExceptionOr> create(JS::Realm&, MediaList& media_queries, CSSRuleList&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, MediaList& media_queries, CSSRuleList&); virtual ~CSSMediaRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp index 86f2cf963c..271098a6e2 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp @@ -21,9 +21,9 @@ CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional { } -WebIDL::ExceptionOr> CSSNamespaceRule::create(JS::Realm& realm, Optional prefix, AK::StringView namespace_uri) +JS::NonnullGCPtr CSSNamespaceRule::create(JS::Realm& realm, Optional prefix, AK::StringView namespace_uri) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, prefix, namespace_uri)); + return realm.heap().allocate(realm, realm, prefix, namespace_uri); } void CSSNamespaceRule::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.h index 59a1ae1bc4..42d6adcdb8 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSNamespaceRule.h @@ -14,7 +14,7 @@ class CSSNamespaceRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSNamespaceRule, CSSRule); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Optional prefix, StringView namespace_uri); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Optional prefix, StringView namespace_uri); virtual ~CSSNamespaceRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index c9172a04bc..4ab2a040ee 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -18,9 +18,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) +JS::NonnullGCPtr CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) { - auto rule_list = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto rule_list = realm.heap().allocate(realm, realm); for (auto* rule : rules) rule_list->m_rules.append(*rule); return rule_list; @@ -31,9 +31,9 @@ CSSRuleList::CSSRuleList(JS::Realm& realm) { } -WebIDL::ExceptionOr> CSSRuleList::create_empty(JS::Realm& realm) +JS::NonnullGCPtr CSSRuleList::create_empty(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } void CSSRuleList::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h index 1fcbf9cf6f..455a9de93c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h @@ -23,8 +23,8 @@ class CSSRuleList : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(CSSRuleList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, JS::MarkedVector const&); - static WebIDL::ExceptionOr> create_empty(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, JS::MarkedVector const&); + [[nodiscard]] static JS::NonnullGCPtr create_empty(JS::Realm&); ~CSSRuleList() = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index bbd7f8686b..352f1fee3f 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -26,9 +26,9 @@ void CSSStyleDeclaration::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "CSSStyleDeclaration")); } -WebIDL::ExceptionOr> PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector properties, HashMap custom_properties) +JS::NonnullGCPtr PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector properties, HashMap custom_properties) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(properties), move(custom_properties))); + return realm.heap().allocate(realm, realm, move(properties), move(custom_properties)); } PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector properties, HashMap custom_properties) @@ -45,10 +45,10 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const return CSS::string_from_property_id(m_properties[index].property_id); } -WebIDL::ExceptionOr> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector properties, HashMap custom_properties) +JS::NonnullGCPtr ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector properties, HashMap custom_properties) { auto& realm = element.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, element, move(properties), move(custom_properties))); + return realm.heap().allocate(realm, element, move(properties), move(custom_properties)); } ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector properties, HashMap custom_properties) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 9450304f81..1766738932 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -53,7 +53,7 @@ class PropertyOwningCSSStyleDeclaration : public CSSStyleDeclaration { friend class ElementInlineCSSStyleDeclaration; public: - static WebIDL::ExceptionOr> + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector, HashMap custom_properties); virtual ~PropertyOwningCSSStyleDeclaration() override = default; @@ -93,7 +93,7 @@ class ElementInlineCSSStyleDeclaration final : public PropertyOwningCSSStyleDecl WEB_PLATFORM_OBJECT(ElementInlineCSSStyleDeclaration, PropertyOwningCSSStyleDeclaration); public: - static WebIDL::ExceptionOr> create(DOM::Element&, Vector properties, HashMap custom_properties); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Element&, Vector, HashMap custom_properties); virtual ~ElementInlineCSSStyleDeclaration() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index a8024525c5..dfd5283844 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -12,9 +12,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSStyleRule::create(JS::Realm& realm, Vector>&& selectors, CSSStyleDeclaration& declaration) +JS::NonnullGCPtr CSSStyleRule::create(JS::Realm& realm, Vector>&& selectors, CSSStyleDeclaration& declaration) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(selectors), declaration)); + return realm.heap().allocate(realm, realm, move(selectors), declaration); } CSSStyleRule::CSSStyleRule(JS::Realm& realm, Vector>&& selectors, CSSStyleDeclaration& declaration) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index 4450999492..0a9c57054a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -18,7 +18,7 @@ class CSSStyleRule final : public CSSRule { WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Vector>&&, CSSStyleDeclaration&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector>&&, CSSStyleDeclaration&); virtual ~CSSStyleRule() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index e3e7b779d8..f0c3ba784d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -15,9 +15,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) +JS::NonnullGCPtr CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, rules, media, move(location))); + return realm.heap().allocate(realm, realm, rules, media, move(location)); } CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 452a84d7b9..7298ef9e82 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -23,7 +23,7 @@ class CSSStyleSheet final WEB_PLATFORM_OBJECT(CSSStyleSheet, StyleSheet); public: - static WebIDL::ExceptionOr> create(JS::Realm&, CSSRuleList& rules, MediaList& media, Optional location); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, CSSRuleList&, MediaList&, Optional location); virtual ~CSSStyleSheet() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp index ff32ead910..d318e8d811 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp @@ -11,9 +11,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) +JS::NonnullGCPtr CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(supports), rules)); + return realm.heap().allocate(realm, realm, move(supports), rules); } CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h index 23f033409a..acc19052e8 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h @@ -19,7 +19,7 @@ class CSSSupportsRule final : public CSSConditionRule { WEB_PLATFORM_OBJECT(CSSSupportsRule, CSSConditionRule); public: - static WebIDL::ExceptionOr> create(JS::Realm&, NonnullRefPtr&&, CSSRuleList&); + static JS::NonnullGCPtr create(JS::Realm&, NonnullRefPtr&&, CSSRuleList&); virtual ~CSSSupportsRule() = default; diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp index 26146d7df3..03bbe397cd 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp @@ -13,9 +13,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> MediaList::create(JS::Realm& realm, Vector>&& media) +JS::NonnullGCPtr MediaList::create(JS::Realm& realm, Vector>&& media) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(media))); + return realm.heap().allocate(realm, realm, move(media)); } MediaList::MediaList(JS::Realm& realm, Vector>&& media) diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.h b/Userland/Libraries/LibWeb/CSS/MediaList.h index 50788a58bf..d68a732351 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaList.h @@ -20,7 +20,7 @@ class MediaList final : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(MediaList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Vector>&& media); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector>&&); ~MediaList() = default; DeprecatedString media_text() const; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp index 309e39f929..b306655ad7 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -15,9 +15,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> MediaQueryList::create(DOM::Document& document, Vector>&& media) +JS::NonnullGCPtr MediaQueryList::create(DOM::Document& document, Vector>&& media) { - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document, move(media))); + return document.heap().allocate(document.realm(), document, move(media)); } MediaQueryList::MediaQueryList(DOM::Document& document, Vector>&& media) diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h index 40f281028f..d554adf31a 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h @@ -17,7 +17,7 @@ class MediaQueryList final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget); public: - static WebIDL::ExceptionOr> create(DOM::Document&, Vector>&&); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Document&, Vector>&&); virtual ~MediaQueryList() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp index bdadffae1c..137092c4e5 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp @@ -10,9 +10,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init) +JS::NonnullGCPtr MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h index 8e4310bf46..3dcb7ac41e 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h @@ -20,7 +20,7 @@ class MediaQueryListEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(MediaQueryListEvent, DOM::Event); public: - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr construct_impl(JS::Realm&, FlyString const& event_name, MediaQueryListEventInit const& = {}); virtual ~MediaQueryListEvent() override; diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp index 1515e75f77..362a40c385 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp @@ -18,9 +18,9 @@ namespace Web { CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional location) { if (css.is_empty()) { - auto rule_list = CSS::CSSRuleList::create_empty(context.realm()).release_value_but_fixme_should_propagate_errors(); - auto media_list = CSS::MediaList::create(context.realm(), {}).release_value_but_fixme_should_propagate_errors(); - return CSS::CSSStyleSheet::create(context.realm(), rule_list, media_list, location).release_value_but_fixme_should_propagate_errors(); + auto rule_list = CSS::CSSRuleList::create_empty(context.realm()); + auto media_list = CSS::MediaList::create(context.realm(), {}); + return CSS::CSSStyleSheet::create(context.realm(), rule_list, media_list, location); } auto parser = CSS::Parser::Parser::create(context, css).release_value_but_fixme_should_propagate_errors(); return parser.parse_as_css_stylesheet(location); @@ -29,7 +29,7 @@ CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& cont CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const& context, StringView css, DOM::Element& element) { if (css.is_empty()) - return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {}).release_value_but_fixme_should_propagate_errors(); + return CSS::ElementInlineCSSStyleDeclaration::create(element, {}, {}); auto parser = CSS::Parser::Parser::create(context, css).release_value_but_fixme_should_propagate_errors(); return parser.parse_as_style_attribute(element); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index ae2d19718d..0f9c4a6d60 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -161,9 +161,9 @@ CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional location) rules.append(rule); } - auto rule_list = CSSRuleList::create(m_context.realm(), rules).release_value_but_fixme_should_propagate_errors(); - auto media_list = MediaList::create(m_context.realm(), {}).release_value_but_fixme_should_propagate_errors(); - return CSSStyleSheet::create(m_context.realm(), rule_list, media_list, move(location)).release_value_but_fixme_should_propagate_errors(); + auto rule_list = CSSRuleList::create(m_context.realm(), rules); + auto media_list = MediaList::create(m_context.realm(), {}); + return CSSStyleSheet::create(m_context.realm(), rule_list, media_list, move(location)); } Optional Parser::parse_as_selector(SelectorParsingMode parsing_mode) @@ -2360,7 +2360,7 @@ ElementInlineCSSStyleDeclaration* Parser::parse_as_style_attribute(DOM::Element& { auto declarations_and_at_rules = parse_a_list_of_declarations(m_token_stream); auto [properties, custom_properties] = extract_properties(declarations_and_at_rules); - return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors(); + return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties)); } Optional Parser::parse_url_function(ComponentValue const& component_value) @@ -3149,7 +3149,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) } if (url.has_value()) - return CSSImportRule::create(url.value(), const_cast(*m_context.document())).release_value_but_fixme_should_propagate_errors(); + return CSSImportRule::create(url.value(), const_cast(*m_context.document())); dbgln_if(CSS_PARSER_DEBUG, "Unable to parse url from @import rule"); return {}; } @@ -3166,9 +3166,9 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) if (auto* child_rule = convert_to_rule(raw_rule)) child_rules.append(child_rule); } - auto media_list = MediaList::create(m_context.realm(), move(media_query_list)).release_value_but_fixme_should_propagate_errors(); - auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors(); - return CSSMediaRule::create(m_context.realm(), media_list, rule_list).release_value_but_fixme_should_propagate_errors(); + auto media_list = MediaList::create(m_context.realm(), move(media_query_list)); + auto rule_list = CSSRuleList::create(m_context.realm(), child_rules); + return CSSMediaRule::create(m_context.realm(), media_list, rule_list); } if (rule->at_rule_name().equals_ignoring_ascii_case("supports"sv)) { auto supports_tokens = TokenStream { rule->prelude() }; @@ -3191,8 +3191,8 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) child_rules.append(child_rule); } - auto rule_list = CSSRuleList::create(m_context.realm(), child_rules).release_value_but_fixme_should_propagate_errors(); - return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list).release_value_but_fixme_should_propagate_errors(); + auto rule_list = CSSRuleList::create(m_context.realm(), child_rules); + return CSSSupportsRule::create(m_context.realm(), supports.release_nonnull(), rule_list); } if (rule->at_rule_name().equals_ignoring_ascii_case("keyframes"sv)) { auto prelude_stream = TokenStream { rule->prelude() }; @@ -3286,7 +3286,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) auto block_declarations = parse_a_list_of_declarations(block_stream); auto style = convert_to_style_declaration(block_declarations); for (auto& selector : selectors) { - auto keyframe_rule = CSSKeyframeRule::create(m_context.realm(), selector, *style).release_value_but_fixme_should_propagate_errors(); + auto keyframe_rule = CSSKeyframeRule::create(m_context.realm(), selector, *style); keyframes.append(keyframe_rule); } } else { @@ -3294,7 +3294,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) } } - return CSSKeyframesRule::create(m_context.realm(), name, move(keyframes)).release_value_but_fixme_should_propagate_errors(); + return CSSKeyframesRule::create(m_context.realm(), name, move(keyframes)); } if (rule->at_rule_name().equals_ignoring_ascii_case("namespace"sv)) { // https://drafts.csswg.org/css-namespaces/#syntax @@ -3325,7 +3325,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) return {}; } - return CSSNamespaceRule::create(m_context.realm(), prefix, namespace_uri).release_value_but_fixme_should_propagate_errors(); + return CSSNamespaceRule::create(m_context.realm(), prefix, namespace_uri); } // FIXME: More at rules! @@ -3363,7 +3363,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr rule) return {}; } - return CSSStyleRule::create(m_context.realm(), move(selectors.value()), *declaration).release_value_but_fixme_should_propagate_errors(); + return CSSStyleRule::create(m_context.realm(), move(selectors.value()), *declaration); } auto Parser::extract_properties(Vector const& declarations_and_at_rules) -> PropertiesAndCustomProperties @@ -3392,7 +3392,7 @@ auto Parser::extract_properties(Vector const& declarations_ PropertyOwningCSSStyleDeclaration* Parser::convert_to_style_declaration(Vector const& declarations_and_at_rules) { auto [properties, custom_properties] = extract_properties(declarations_and_at_rules); - return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties)).release_value_but_fixme_should_propagate_errors(); + return PropertyOwningCSSStyleDeclaration::create(m_context.realm(), move(properties), move(custom_properties)); } Optional Parser::convert_to_style_property(Declaration const& declaration) @@ -6133,7 +6133,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream& tokens) unicode_range.empend(0x0u, 0x10FFFFu); } - return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) }).release_value_but_fixme_should_propagate_errors(); + return CSSFontFaceRule::create(m_context.realm(), FontFace { font_family.release_value(), weight, slope, move(src), move(unicode_range) }); } Vector Parser::parse_font_face_src(TokenStream& component_values) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 638c0e333e..92b25d447f 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -48,9 +48,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> ResolvedCSSStyleDeclaration::create(DOM::Element& element) +JS::NonnullGCPtr ResolvedCSSStyleDeclaration::create(DOM::Element& element) { - return MUST_OR_THROW_OOM(element.realm().heap().allocate(element.realm(), element)); + return element.realm().heap().allocate(element.realm(), element); } ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h index f5bc44bbf5..93a367f7af 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h @@ -14,7 +14,7 @@ class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration { WEB_PLATFORM_OBJECT(ResolvedCSSStyleDeclaration, CSSStyleDeclaration); public: - static WebIDL::ExceptionOr> create(DOM::Element& element); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Element&); virtual ~ResolvedCSSStyleDeclaration() override = default; diff --git a/Userland/Libraries/LibWeb/CSS/Screen.cpp b/Userland/Libraries/LibWeb/CSS/Screen.cpp index 087244286f..2533ceae2c 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.cpp +++ b/Userland/Libraries/LibWeb/CSS/Screen.cpp @@ -13,9 +13,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> Screen::create(HTML::Window& window) +JS::NonnullGCPtr Screen::create(HTML::Window& window) { - return MUST_OR_THROW_OOM(window.heap().allocate(window.realm(), window)); + return window.heap().allocate(window.realm(), window); } Screen::Screen(HTML::Window& window) diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h index 9f8ec1d165..a416576e46 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.h +++ b/Userland/Libraries/LibWeb/CSS/Screen.h @@ -17,7 +17,7 @@ class Screen final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Screen, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(HTML::Window&); + [[nodiscard]] static JS::NonnullGCPtr create(HTML::Window&); i32 width() const { return screen_rect().width(); } i32 height() const { return screen_rect().height(); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp index 2d2805ad31..ce01e8e344 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -62,10 +62,10 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) m_document->invalidate_style(); } -WebIDL::ExceptionOr> StyleSheetList::create(DOM::Document& document) +JS::NonnullGCPtr StyleSheetList::create(DOM::Document& document) { auto& realm = document.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document)); + return realm.heap().allocate(realm, document); } StyleSheetList::StyleSheetList(DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index 455ad6ed58..5cdc22d7f7 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -16,7 +16,7 @@ class StyleSheetList : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(StyleSheetList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(DOM::Document& document); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Document&); void add_sheet(CSSStyleSheet&); void remove_sheet(CSSStyleSheet&); diff --git a/Userland/Libraries/LibWeb/CSS/VisualViewport.cpp b/Userland/Libraries/LibWeb/CSS/VisualViewport.cpp index 92cb7d0422..0afa19e727 100644 --- a/Userland/Libraries/LibWeb/CSS/VisualViewport.cpp +++ b/Userland/Libraries/LibWeb/CSS/VisualViewport.cpp @@ -15,9 +15,9 @@ namespace Web::CSS { -WebIDL::ExceptionOr> VisualViewport::create(DOM::Document& document) +JS::NonnullGCPtr VisualViewport::create(DOM::Document& document) { - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document)); + return document.heap().allocate(document.realm(), document); } VisualViewport::VisualViewport(DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/CSS/VisualViewport.h b/Userland/Libraries/LibWeb/CSS/VisualViewport.h index 19d1453900..c471bb7fe4 100644 --- a/Userland/Libraries/LibWeb/CSS/VisualViewport.h +++ b/Userland/Libraries/LibWeb/CSS/VisualViewport.h @@ -15,7 +15,7 @@ class VisualViewport final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget); public: - static WebIDL::ExceptionOr> create(DOM::Document&); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Document&); virtual ~VisualViewport() override = default; diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 1666df5535..17d9fc380e 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -15,9 +15,9 @@ namespace Web::Crypto { -WebIDL::ExceptionOr> Crypto::create(JS::Realm& realm) +JS::NonnullGCPtr Crypto::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } Crypto::Crypto(JS::Realm& realm) @@ -31,7 +31,7 @@ void Crypto::initialize(JS::Realm& realm) { Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "Crypto")); - m_subtle = MUST(SubtleCrypto::create(realm)); + m_subtle = SubtleCrypto::create(realm); } JS::NonnullGCPtr Crypto::subtle() const diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h index 74d3c002fc..bfb6fb3440 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.h +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h @@ -16,7 +16,7 @@ class Crypto : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~Crypto() override; diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index a419e4f16b..97b9dd2986 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -14,9 +14,9 @@ namespace Web::Crypto { -WebIDL::ExceptionOr> SubtleCrypto::create(JS::Realm& realm) +JS::NonnullGCPtr SubtleCrypto::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } SubtleCrypto::SubtleCrypto(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h index 4f95682396..42203505cc 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -15,7 +15,7 @@ class SubtleCrypto final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SubtleCrypto, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~SubtleCrypto() override; diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.cpp b/Userland/Libraries/LibWeb/DOM/AbortController.cpp index 3c99d8e5ff..22cadee5bd 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortController.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { WebIDL::ExceptionOr> AbortController::construct_impl(JS::Realm& realm) { auto signal = TRY(AbortSignal::construct_impl(realm)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(signal))); + return realm.heap().allocate(realm, realm, move(signal)); } // https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index 3664198f55..a6b22b15fe 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -14,7 +14,7 @@ namespace Web::DOM { WebIDL::ExceptionOr> AbortSignal::construct_impl(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } AbortSignal::AbortSignal(JS::Realm& realm) @@ -60,7 +60,7 @@ void AbortSignal::signal_abort(JS::Value reason) m_abort_algorithms.clear(); // 5. Fire an event named abort at signal. - dispatch_event(Event::create(realm(), HTML::EventNames::abort).release_value_but_fixme_should_propagate_errors()); + dispatch_event(Event::create(realm(), HTML::EventNames::abort)); } void AbortSignal::set_onabort(WebIDL::CallbackType* event_handler) diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp index 263d67b94c..1073496424 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp @@ -13,9 +13,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> AccessibilityTreeNode::create(Document* document, DOM::Node const* value) +JS::NonnullGCPtr AccessibilityTreeNode::create(Document* document, DOM::Node const* value) { - return MUST_OR_THROW_OOM(document->heap().allocate(document->realm(), value)); + return document->heap().allocate(document->realm(), value); } AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr value) diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h index d2f1ee24e7..9b7301b3c8 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h @@ -17,7 +17,7 @@ namespace Web::DOM { class AccessibilityTreeNode final : public JS::Cell { JS_CELL(AccessibilityTreeNode, JS::Cell) public: - static WebIDL::ExceptionOr> create(Document*, DOM::Node const*); + static JS::NonnullGCPtr create(Document*, DOM::Node const*); virtual ~AccessibilityTreeNode() override = default; JS::GCPtr value() const { return m_value; } diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index a0148bb65d..152344a7e8 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -15,19 +15,19 @@ namespace Web::DOM { -WebIDL::ExceptionOr> Attr::create(Document& document, DeprecatedFlyString local_name, DeprecatedString value, Element* owner_element) +JS::NonnullGCPtr Attr::create(Document& document, DeprecatedFlyString local_name, DeprecatedString value, Element* owner_element) { - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element)); + return document.heap().allocate(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element); } -WebIDL::ExceptionOr> Attr::create(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element) +JS::NonnullGCPtr Attr::create(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element) { - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document, move(qualified_name), move(value), owner_element)); + return document.heap().allocate(document.realm(), document, move(qualified_name), move(value), owner_element); } JS::NonnullGCPtr Attr::clone(Document& document) { - return *heap().allocate(realm(), document, m_qualified_name, m_value, nullptr).release_allocated_value_but_fixme_should_propagate_errors(); + return *heap().allocate(realm(), document, m_qualified_name, m_value, nullptr); } Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString value, Element* owner_element) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h index 5ba24c6095..4d171c04e1 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.h +++ b/Userland/Libraries/LibWeb/DOM/Attr.h @@ -18,8 +18,8 @@ class Attr final : public Node { WEB_PLATFORM_OBJECT(Attr, Node); public: - static WebIDL::ExceptionOr> create(Document&, QualifiedName, DeprecatedString value = "", Element* = nullptr); - static WebIDL::ExceptionOr> create(Document&, DeprecatedFlyString local_name, DeprecatedString value = "", Element* = nullptr); + [[nodiscard]] static JS::NonnullGCPtr create(Document&, QualifiedName, DeprecatedString value = "", Element* = nullptr); + [[nodiscard]] static JS::NonnullGCPtr create(Document&, DeprecatedFlyString local_name, DeprecatedString value = "", Element* = nullptr); JS::NonnullGCPtr clone(Document&); virtual ~Attr() override = default; diff --git a/Userland/Libraries/LibWeb/DOM/Comment.cpp b/Userland/Libraries/LibWeb/DOM/Comment.cpp index ebf250cd9e..4bb02c55ec 100644 --- a/Userland/Libraries/LibWeb/DOM/Comment.cpp +++ b/Userland/Libraries/LibWeb/DOM/Comment.cpp @@ -20,7 +20,7 @@ Comment::Comment(Document& document, DeprecatedString const& data) WebIDL::ExceptionOr> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data) { auto& window = verify_cast(realm.global_object()); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, window.associated_document(), data)); + return realm.heap().allocate(realm, window.associated_document(), data); } void Comment::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp index 6684dc164c..5f9e2ec275 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp @@ -11,9 +11,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init) +JS::NonnullGCPtr CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.h b/Userland/Libraries/LibWeb/DOM/CustomEvent.h index 3fd62c5f55..9c92bfa4b9 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.h +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.h @@ -21,8 +21,8 @@ class CustomEvent : public Event { WEB_PLATFORM_OBJECT(CustomEvent, Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, CustomEventInit const& = {}); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const&); virtual ~CustomEvent() override; diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index 1fb91d5d5a..4af9e16963 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -17,10 +17,10 @@ namespace Web::DOM { -WebIDL::ExceptionOr> DOMImplementation::create(Document& document) +JS::NonnullGCPtr DOMImplementation::create(Document& document) { auto& realm = document.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document)); + return realm.heap().allocate(realm, document); } DOMImplementation::DOMImplementation(Document& document) @@ -47,7 +47,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor) WebIDL::ExceptionOr> DOMImplementation::create_document(DeprecatedString const& namespace_, DeprecatedString const& qualified_name, JS::GCPtr doctype) const { // FIXME: This should specifically be an XML document. - auto xml_document = TRY(Document::create(realm())); + auto xml_document = Document::create(realm()); xml_document->set_ready_for_post_load_tasks(true); @@ -77,12 +77,12 @@ WebIDL::ExceptionOr> DOMImplementation::create_docume // https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument JS::NonnullGCPtr DOMImplementation::create_html_document(DeprecatedString const& title) const { - auto html_document = Document::create(realm()).release_value_but_fixme_should_propagate_errors(); + auto html_document = Document::create(realm()); html_document->set_content_type("text/html"); html_document->set_ready_for_post_load_tasks(true); - auto doctype = heap().allocate(realm(), html_document).release_allocated_value_but_fixme_should_propagate_errors(); + auto doctype = heap().allocate(realm(), html_document); doctype->set_name("html"); MUST(html_document->append_child(*doctype)); @@ -96,7 +96,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(DeprecatedStr auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); MUST(head_element->append_child(title_element)); - auto text_node = heap().allocate(realm(), html_document, title).release_allocated_value_but_fixme_should_propagate_errors(); + auto text_node = heap().allocate(realm(), html_document, title); MUST(title_element->append_child(*text_node)); } @@ -112,7 +112,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(DeprecatedStr WebIDL::ExceptionOr> DOMImplementation::create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id) { TRY(Document::validate_qualified_name(realm(), qualified_name)); - auto document_type = TRY(DocumentType::create(document())); + auto document_type = DocumentType::create(document()); document_type->set_name(qualified_name); document_type->set_public_id(public_id); document_type->set_system_id(system_id); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 2f56d89cdb..410bf623aa 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -17,7 +17,7 @@ class DOMImplementation final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(Document&); + [[nodiscard]] static JS::NonnullGCPtr create(Document&); virtual ~DOMImplementation(); WebIDL::ExceptionOr> create_document(DeprecatedString const&, DeprecatedString const&, JS::GCPtr) const; diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 8dc2ae9fe4..6acc4555ca 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -52,10 +52,10 @@ inline void replace_in_ordered_set(Vector& set, StringView ite namespace Web::DOM { -WebIDL::ExceptionOr> DOMTokenList::create(Element& associated_element, DeprecatedFlyString associated_attribute) +JS::NonnullGCPtr DOMTokenList::create(Element& associated_element, DeprecatedFlyString associated_attribute) { auto& realm = associated_element.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, associated_element, move(associated_attribute))); + return realm.heap().allocate(realm, associated_element, move(associated_attribute)); } // https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2 diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index 798e266d50..3bc06b62b9 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -24,7 +24,7 @@ class DOMTokenList final : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(DOMTokenList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(Element& associated_element, DeprecatedFlyString associated_attribute); + [[nodiscard]] static JS::NonnullGCPtr create(Element& associated_element, DeprecatedFlyString associated_attribute); ~DOMTokenList() = default; void associated_attribute_changed(StringView value); diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 358e59e035..3706b556a3 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -200,7 +200,7 @@ WebIDL::ExceptionOr> Document::create_and_initialize( Bindings::main_thread_vm(), [&](JS::Realm& realm) -> JS::Object* { // - For the global object, create a new Window object. - window = HTML::Window::create(realm).release_value_but_fixme_should_propagate_errors(); + window = HTML::Window::create(realm); return window; }, [&](JS::Realm&) -> JS::Object* { @@ -232,12 +232,12 @@ WebIDL::ExceptionOr> Document::create_and_initialize( // FIXME: Why do we assume `creation_url` is non-empty here? Is this a spec bug? // FIXME: Why do we assume `top_level_creation_url` is non-empty here? Is this a spec bug? - TRY(HTML::WindowEnvironmentSettingsObject::setup( + HTML::WindowEnvironmentSettingsObject::setup( creation_url.value(), move(realm_execution_context), navigation_params.reserved_environment, top_level_creation_url.value(), - top_level_origin)); + top_level_origin); } // FIXME: 7. Let loadTimingInfo be a new document load timing info with its navigation start time set to response's timing info's start time. @@ -252,7 +252,7 @@ WebIDL::ExceptionOr> Document::create_and_initialize( // FIXME: and cross-origin opener policy is navigationParams's cross-origin opener policy, // FIXME: load timing info is loadTimingInfo, // and navigation id is navigationParams's id. - auto document = TRY(HTML::HTMLDocument::create(window->realm())); + auto document = HTML::HTMLDocument::create(window->realm()); document->m_type = type; document->m_content_type = move(content_type); document->set_origin(navigation_params.origin); @@ -310,9 +310,9 @@ WebIDL::ExceptionOr> Document::construct_impl(JS::Rea return Document::create(realm); } -WebIDL::ExceptionOr> Document::create(JS::Realm& realm, AK::URL const& url) +JS::NonnullGCPtr Document::create(JS::Realm& realm, AK::URL const& url) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, url)); + return realm.heap().allocate(realm, realm, url); } Document::Document(JS::Realm& realm, const AK::URL& url) @@ -341,7 +341,7 @@ void Document::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "Document")); - m_selection = MUST(heap().allocate(realm, realm, *this)); + m_selection = heap().allocate(realm, realm, *this); m_list_of_available_images = make(); } @@ -1162,7 +1162,7 @@ void Document::set_hovered_node(Node* node) // FIXME: Check if we need to dispatch these events in a specific order. for (auto target = old_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) { // FIXME: Populate the event with mouse coordinates, etc. - target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave).release_value_but_fixme_should_propagate_errors()); + target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave)); } } @@ -1171,7 +1171,7 @@ void Document::set_hovered_node(Node* node) // FIXME: Check if we need to dispatch these events in a specific order. for (auto target = m_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) { // FIXME: Populate the event with mouse coordinates, etc. - target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter).release_value_but_fixme_should_propagate_errors()); + target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter)); } } } @@ -1180,7 +1180,7 @@ JS::NonnullGCPtr Document::get_elements_by_name(DeprecatedString { return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [name](Element const& element) { return element.name() == name; - }).release_value_but_fixme_should_propagate_errors(); + }); } JS::NonnullGCPtr Document::get_elements_by_class_name(DeprecatedFlyString const& class_names) @@ -1195,14 +1195,14 @@ JS::NonnullGCPtr Document::get_elements_by_class_name(Deprecated return false; } return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } // https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-applets JS::NonnullGCPtr Document::applets() { if (!m_applets) - m_applets = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](auto&) { return false; }).release_value_but_fixme_should_propagate_errors(); + m_applets = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](auto&) { return false; }); return *m_applets; } @@ -1212,7 +1212,7 @@ JS::NonnullGCPtr Document::anchors() if (!m_anchors) { m_anchors = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return is(element) && element.has_attribute(HTML::AttributeNames::name); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_anchors; } @@ -1223,7 +1223,7 @@ JS::NonnullGCPtr Document::images() if (!m_images) { m_images = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_images; } @@ -1234,7 +1234,7 @@ JS::NonnullGCPtr Document::embeds() if (!m_embeds) { m_embeds = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_embeds; } @@ -1251,7 +1251,7 @@ JS::NonnullGCPtr Document::links() if (!m_links) { m_links = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return (is(element) || is(element)) && element.has_attribute(HTML::AttributeNames::href); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_links; } @@ -1262,7 +1262,7 @@ JS::NonnullGCPtr Document::forms() if (!m_forms) { m_forms = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_forms; } @@ -1273,7 +1273,7 @@ JS::NonnullGCPtr Document::scripts() if (!m_scripts) { m_scripts = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_scripts; } @@ -1284,7 +1284,7 @@ JS::NonnullGCPtr Document::all() if (!m_all) { m_all = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) { return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_all; } @@ -1417,17 +1417,17 @@ WebIDL::ExceptionOr> Document::create_element_ns(Depre JS::NonnullGCPtr Document::create_document_fragment() { - return heap().allocate(realm(), *this).release_allocated_value_but_fixme_should_propagate_errors(); + return heap().allocate(realm(), *this); } JS::NonnullGCPtr Document::create_text_node(DeprecatedString const& data) { - return heap().allocate(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors(); + return heap().allocate(realm(), *this, data); } JS::NonnullGCPtr Document::create_comment(DeprecatedString const& data) { - return heap().allocate(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors(); + return heap().allocate(realm(), *this, data); } // https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction @@ -1438,12 +1438,12 @@ WebIDL::ExceptionOr> Document::create_pr // FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException. // 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this. - return MUST_OR_THROW_OOM(heap().allocate(realm(), *this, data, target)); + return heap().allocate(realm(), *this, data, target); } JS::NonnullGCPtr Document::create_range() { - return Range::create(*this).release_value_but_fixme_should_propagate_errors(); + return Range::create(*this); } // https://dom.spec.whatwg.org/#dom-document-createevent @@ -1458,44 +1458,44 @@ WebIDL::ExceptionOr> Document::create_event(DeprecatedSt // 2. If interface is an ASCII case-insensitive match for any of the strings in the first column in the following table, // then set constructor to the interface in the second column on the same row as the matching string: if (Infra::is_ascii_case_insensitive_match(interface, "beforeunloadevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create BeforeUnloadEvent + event = Event::create(realm, FlyString {}); // FIXME: Create BeforeUnloadEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "compositionevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create CompositionEvent + event = Event::create(realm, FlyString {}); // FIXME: Create CompositionEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "customevent"sv)) { - event = TRY(CustomEvent::create(realm, FlyString {})); + event = CustomEvent::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "devicemotionevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DeviceMotionEvent + event = Event::create(realm, FlyString {}); // FIXME: Create DeviceMotionEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "deviceorientationevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DeviceOrientationEvent + event = Event::create(realm, FlyString {}); // FIXME: Create DeviceOrientationEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "dragevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create DragEvent + event = Event::create(realm, FlyString {}); // FIXME: Create DragEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "event"sv) || Infra::is_ascii_case_insensitive_match(interface, "events"sv)) { - event = TRY(Event::create(realm, FlyString {})); + event = Event::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "focusevent"sv)) { - event = TRY(UIEvents::FocusEvent::create(realm, FlyString {})); + event = UIEvents::FocusEvent::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "hashchangeevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create HashChangeEvent + event = Event::create(realm, FlyString {}); // FIXME: Create HashChangeEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "htmlevents"sv)) { - event = TRY(Event::create(realm, FlyString {})); + event = Event::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "keyboardevent"sv)) { - event = TRY(UIEvents::KeyboardEvent::create(realm, String {})); + event = UIEvents::KeyboardEvent::create(realm, String {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "messageevent"sv)) { - event = TRY(HTML::MessageEvent::create(realm, String {})); + event = HTML::MessageEvent::create(realm, String {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "mouseevent"sv) || Infra::is_ascii_case_insensitive_match(interface, "mouseevents"sv)) { - event = TRY(UIEvents::MouseEvent::create(realm, FlyString {})); + event = UIEvents::MouseEvent::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "storageevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create StorageEvent + event = Event::create(realm, FlyString {}); // FIXME: Create StorageEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "svgevents"sv)) { - event = TRY(Event::create(realm, FlyString {})); + event = Event::create(realm, FlyString {}); } else if (Infra::is_ascii_case_insensitive_match(interface, "textevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create CompositionEvent + event = Event::create(realm, FlyString {}); // FIXME: Create CompositionEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "touchevent"sv)) { - event = TRY(Event::create(realm, FlyString {})); // FIXME: Create TouchEvent + event = Event::create(realm, FlyString {}); // FIXME: Create TouchEvent } else if (Infra::is_ascii_case_insensitive_match(interface, "uievent"sv) || Infra::is_ascii_case_insensitive_match(interface, "uievents"sv)) { - event = TRY(UIEvents::UIEvent::create(realm, FlyString {})); + event = UIEvents::UIEvent::create(realm, FlyString {}); } // 3. If constructor is null, then throw a "NotSupportedError" DOMException. @@ -1896,7 +1896,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value) } // 4. Fire an event named readystatechange at document. - dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange)); } Page* Document::page() @@ -1948,7 +1948,7 @@ void Document::completely_finish_loading() // 5. Otherwise, if container is non-null, then queue an element task on the DOM manipulation task source given container to fire an event named load at container. else if (container) { container->queue_an_element_task(HTML::Task::Source::DOMManipulation, [container] { - container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load)); }); } @@ -2037,7 +2037,7 @@ bool Document::is_active() const } // https://html.spec.whatwg.org/multipage/history.html#dom-document-location -WebIDL::ExceptionOr> Document::location() +JS::GCPtr Document::location() { // The Document object's location attribute's getter must return this Document object's relevant global object's Location object, // if this Document object is fully active, and null otherwise. @@ -2045,7 +2045,7 @@ WebIDL::ExceptionOr> Document::location() if (!is_fully_active()) return nullptr; - return TRY(window().location()); + return window().location(); } // https://html.spec.whatwg.org/multipage/interaction.html#dom-document-hidden @@ -2084,7 +2084,7 @@ void Document::update_the_visibility_state(HTML::VisibilityState visibility_stat // FIXME: 3. Run any page visibility change steps which may be defined in other specifications, with visibility state and document. // 4. Fire an event named visibilitychange at document, with its bubbles attribute initialized to true. - auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange).release_value_but_fixme_should_propagate_errors(); + auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange); event->set_bubbles(true); dispatch_event(event); } @@ -2105,7 +2105,7 @@ void Document::run_the_resize_steps() return; m_last_viewport_size = viewport_size; - window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize).release_value_but_fixme_should_propagate_errors()); + window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize)); schedule_layout_update(); } @@ -2117,14 +2117,14 @@ void Document::run_the_scroll_steps() for (auto& target : m_pending_scroll_event_targets) { // 1. If target is a Document, fire an event named scroll that bubbles at target and fire an event named scroll at the VisualViewport that is associated with target. if (is(*target)) { - auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors(); + auto event = DOM::Event::create(realm(), HTML::EventNames::scroll); event->set_bubbles(true); target->dispatch_event(event); // FIXME: Fire at the associated VisualViewport } // 2. Otherwise, fire an event named scroll at target. else { - auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors(); + auto event = DOM::Event::create(realm(), HTML::EventNames::scroll); target->dispatch_event(event); } } @@ -2164,7 +2164,7 @@ void Document::evaluate_media_queries_and_report_changes() CSS::MediaQueryListEventInit init; init.media = String::from_deprecated_string(media_query_list->media()).release_value_but_fixme_should_propagate_errors(); init.matches = now_matches; - auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init).release_value_but_fixme_should_propagate_errors(); + auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init); event->set_is_trusted(true); media_query_list->dispatch_event(*event); } @@ -2191,7 +2191,7 @@ void Document::evaluate_media_rules() DOMImplementation* Document::implementation() { if (!m_implementation) - m_implementation = DOMImplementation::create(*this).release_value_but_fixme_should_propagate_errors(); + m_implementation = DOMImplementation::create(*this); return m_implementation; } @@ -2323,7 +2323,7 @@ JS::NonnullGCPtr Document::create_node_iterator(Node& root, unsign // https://dom.spec.whatwg.org/#dom-document-createtreewalker JS::NonnullGCPtr Document::create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr filter) { - return TreeWalker::create(root, what_to_show, filter).release_value_but_fixme_should_propagate_errors(); + return TreeWalker::create(root, what_to_show, filter); } void Document::register_node_iterator(Badge, NodeIterator& node_iterator) @@ -2386,7 +2386,7 @@ void Document::check_favicon_after_loading_link_resource() return false; return static_cast(element).has_loaded_icon(); - }).release_value_but_fixme_should_propagate_errors(); + }); if (favicon_link_elements->length() == 0) { dbgln_if(SPAM_DEBUG, "No favicon found to be used"); @@ -2437,7 +2437,7 @@ JS::GCPtr Document::lookup_custom_element_definit return nullptr; // 3. Let registry be document's relevant global object's CustomElementRegistry object. - auto registry = window().custom_elements().release_value_but_fixme_should_propagate_errors(); + auto registry = window().custom_elements(); // 4. If there is custom element definition in registry with name and local name both equal to localName, return that custom element definition. auto converted_local_name = String::from_deprecated_string(local_name).release_value_but_fixme_should_propagate_errors(); @@ -2458,7 +2458,7 @@ JS::GCPtr Document::lookup_custom_element_definit CSS::StyleSheetList& Document::style_sheets() { if (!m_style_sheets) - m_style_sheets = CSS::StyleSheetList::create(*this).release_value_but_fixme_should_propagate_errors(); + m_style_sheets = CSS::StyleSheetList::create(*this); return *m_style_sheets; } @@ -2470,7 +2470,7 @@ CSS::StyleSheetList const& Document::style_sheets() const JS::NonnullGCPtr Document::history() { if (!m_history) - m_history = HTML::History::create(realm(), *this).release_value_but_fixme_should_propagate_errors(); + m_history = HTML::History::create(realm(), *this); return *m_history; } @@ -2747,7 +2747,7 @@ void Document::unload(bool recursive_flag, Optional un // then fire an event named unload at document's relevant global object, with legacy target override flag set. // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event() // We should reorganize this so that the flag appears explicitly here instead. - auto event = DOM::Event::create(realm(), HTML::EventNames::unload).release_value_but_fixme_should_propagate_errors(); + auto event = DOM::Event::create(realm(), HTML::EventNames::unload); global_object().dispatch_event(event); } @@ -2860,7 +2860,7 @@ JS::NonnullGCPtr Document::appropriate_template_contents_owner_do // 1. If doc does not yet have an associated inert template document, then: if (!m_associated_inert_template_document) { // 1. Let new doc be a new Document (whose browsing context is null). This is "a Document created by this algorithm" for the purposes of the step above. - auto new_document = HTML::HTMLDocument::create(realm()).release_value_but_fixme_should_propagate_errors(); + auto new_document = HTML::HTMLDocument::create(realm()); new_document->m_created_for_appropriate_template_contents = true; // 2. If doc is an HTML document, mark new doc as an HTML document also. @@ -2880,7 +2880,7 @@ JS::NonnullGCPtr Document::appropriate_template_contents_owner_do DeprecatedString Document::dump_accessibility_tree_as_json() { StringBuilder builder; - auto accessibility_tree = AccessibilityTreeNode::create(this, nullptr).release_value_but_fixme_should_propagate_errors(); + auto accessibility_tree = AccessibilityTreeNode::create(this, nullptr); build_accessibility_tree(*&accessibility_tree); auto json = MUST(JsonObjectSerializer<>::try_create(builder)); @@ -2950,7 +2950,7 @@ HTML::ListOfAvailableImages const& Document::list_of_available_images() const JS::NonnullGCPtr Document::visual_viewport() { if (!m_visual_viewport) - m_visual_viewport = CSS::VisualViewport::create(*this).release_value_but_fixme_should_propagate_errors(); + m_visual_viewport = CSS::VisualViewport::create(*this); return *m_visual_viewport; } @@ -3025,7 +3025,7 @@ void Document::queue_an_intersection_observer_entry(IntersectionObserver::Inters auto& realm = this->realm(); // 1. Construct an IntersectionObserverEntry, passing in time, rootBounds, boundingClientRect, intersectionRect, isIntersecting, and target. - auto entry = realm.heap().allocate(realm, realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target).release_allocated_value_but_fixme_should_propagate_errors(); + auto entry = realm.heap().allocate(realm, realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target); // 2. Append it to observer’s internal [[QueuedEntries]] slot. observer.queue_entry({}, entry); diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index cac5a93d22..3addf25a26 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -91,7 +91,7 @@ public: static WebIDL::ExceptionOr> create_and_initialize(Type, DeprecatedString content_type, HTML::NavigationParams); - static WebIDL::ExceptionOr> create(JS::Realm&, AK::URL const& url = "about:blank"sv); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, AK::URL const& url = "about:blank"sv); static WebIDL::ExceptionOr> construct_impl(JS::Realm&); virtual ~Document() override; @@ -362,7 +362,7 @@ public: JS::NonnullGCPtr history(); JS::NonnullGCPtr history() const; - WebIDL::ExceptionOr> location(); + [[nodiscard]] JS::GCPtr location(); size_t number_of_things_delaying_the_load_event() { return m_number_of_things_delaying_the_load_event; } void increment_number_of_things_delaying_the_load_event(Badge); diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp index c9db334904..297cbcca00 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -35,7 +35,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element) WebIDL::ExceptionOr> DocumentFragment::construct_impl(JS::Realm& realm) { auto& window = verify_cast(realm.global_object()); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, window.associated_document())); + return realm.heap().allocate(realm, window.associated_document()); } } diff --git a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp index 947d6bd76d..bc90501ec3 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -119,7 +119,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data MUST(head_element->append_child(title_element)); auto basename = LexicalPath::basename(document.url().serialize_path()); - auto title_text = document.heap().allocate(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())).release_allocated_value_but_fixme_should_propagate_errors(); + auto title_text = document.heap().allocate(document.realm(), document, DeprecatedString::formatted("{} [{}x{}]", basename, bitmap->width(), bitmap->height())); MUST(title_element->append_child(*title_text)); auto body_element = DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp index 4127bc5474..567ff1eca0 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp @@ -9,9 +9,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> DocumentType::create(Document& document) +JS::NonnullGCPtr DocumentType::create(Document& document) { - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document)); + return document.heap().allocate(document.realm(), document); } DocumentType::DocumentType(Document& document) diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.h b/Userland/Libraries/LibWeb/DOM/DocumentType.h index 32c7afa287..d16464d69e 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.h @@ -18,7 +18,7 @@ class DocumentType final WEB_PLATFORM_OBJECT(DocumentType, Node); public: - static WebIDL::ExceptionOr> create(Document&); + [[nodiscard]] static JS::NonnullGCPtr create(Document&); virtual ~DocumentType() override = default; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 4f3b11d131..13b81e587b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -75,7 +75,7 @@ void Element::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "Element")); - m_attributes = MUST(NamedNodeMap::create(*this)); + m_attributes = NamedNodeMap::create(*this); } void Element::visit_edges(Cell::Visitor& visitor) @@ -130,7 +130,7 @@ WebIDL::ExceptionOr Element::set_attribute(DeprecatedFlyString const& name // 4. If attribute is null, create an attribute whose local name is qualifiedName, value is value, and node document is this’s node document, then append this attribute to this, and then return. if (!attribute) { - auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value)); + auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, value); m_attributes->append_attribute(new_attribute); attribute = new_attribute.ptr(); @@ -264,7 +264,7 @@ WebIDL::ExceptionOr Element::toggle_attribute(DeprecatedFlyString const& n if (!attribute) { // 1. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this’s node document, then append this attribute to this, and then return true. if (!force.has_value() || force.value()) { - auto new_attribute = TRY(Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, "")); + auto new_attribute = Attr::create(document(), insert_as_lowercase ? name.to_lowercase() : name, ""); m_attributes->append_attribute(new_attribute); attribute_changed(new_attribute->local_name(), ""); @@ -476,7 +476,7 @@ Element::RequiredInvalidationAfterStyleChange Element::recompute_style() NonnullRefPtr Element::resolved_css_values() { - auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this).release_value_but_fixme_should_propagate_errors(); + auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this); auto properties = CSS::StyleProperties::create(); for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) { @@ -493,7 +493,7 @@ NonnullRefPtr Element::resolved_css_values() DOMTokenList* Element::class_list() { if (!m_class_list) - m_class_list = DOMTokenList::create(*this, HTML::AttributeNames::class_).release_value_but_fixme_should_propagate_errors(); + m_class_list = DOMTokenList::create(*this, HTML::AttributeNames::class_); return m_class_list; } @@ -528,7 +528,7 @@ WebIDL::ExceptionOr> Element::attach_shadow(ShadowR return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host"); // 5. Let shadow be a new shadow root whose node document is this’s node document, host is this, and mode is init["mode"]. - auto shadow = MUST_OR_THROW_OOM(heap().allocate(realm(), document(), *this, init.mode)); + auto shadow = heap().allocate(realm(), document(), *this, init.mode); // 6. Set shadow’s delegates focus to init["delegatesFocus"]. shadow->set_delegates_focus(init.delegates_focus); @@ -651,7 +651,7 @@ JS::NonnullGCPtr Element::get_elements_by_class_name(DeprecatedF return false; } return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } // https://dom.spec.whatwg.org/#element-shadow-host @@ -676,7 +676,7 @@ void Element::set_shadow_root(JS::GCPtr shadow_root) CSS::CSSStyleDeclaration* Element::style_for_bindings() { if (!m_inline_style) - m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {}).release_value_but_fixme_should_propagate_errors(); + m_inline_style = CSS::ElementInlineCSSStyleDeclaration::create(*this, {}, {}); return m_inline_style; } @@ -723,7 +723,7 @@ JS::NonnullGCPtr Element::get_bounding_client_rect() const VERIFY(document().browsing_context()); auto viewport_offset = document().browsing_context()->viewport_scroll_offset(); - return Geometry::DOMRect::create(realm(), paintable_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type()).release_value_but_fixme_should_propagate_errors(); + return Geometry::DOMRect::create(realm(), paintable_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type()); } // https://drafts.csswg.org/cssom-view/#dom-element-getclientrects @@ -736,7 +736,7 @@ JS::NonnullGCPtr Element::get_client_rects() const // 1. If the element on which it was invoked does not have an associated layout box return an empty DOMRectList object and stop this algorithm. if (!layout_node() || !layout_node()->is_box()) - return Geometry::DOMRectList::create(realm(), move(rects)).release_value_but_fixme_should_propagate_errors(); + return Geometry::DOMRectList::create(realm(), move(rects)); // FIXME: 2. If the element has an associated SVG layout box return a DOMRectList object containing a single DOMRect object that describes // the bounding box of the element as defined by the SVG specification, applying the transforms that apply to the element and its ancestors. @@ -750,7 +750,7 @@ JS::NonnullGCPtr Element::get_client_rects() const auto bounding_rect = get_bounding_client_rect(); rects.append(*bounding_rect); - return Geometry::DOMRectList::create(realm(), move(rects)).release_value_but_fixme_should_propagate_errors(); + return Geometry::DOMRectList::create(realm(), move(rects)); } int Element::client_top() const @@ -1364,7 +1364,7 @@ WebIDL::ExceptionOr> Element::insert_adjacent_element(Depreca WebIDL::ExceptionOr Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data) { // 1. Let text be a new Text node whose data is data and node document is this’s node document. - auto text = MUST_OR_THROW_OOM(heap().allocate(realm(), document(), data)); + auto text = heap().allocate(realm(), document(), data); // 2. Run insert adjacent, given this, where, and text. // Spec Note: This method returns nothing because it existed before we had a chance to design it. diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 017233f915..1c2fad9521 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -270,221 +270,221 @@ bool is_unknown_html_element(DeprecatedFlyString const& tag_name) } // https://html.spec.whatwg.org/#elements-in-the-dom:element-interface -static WebIDL::ExceptionOr> create_html_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) +static JS::NonnullGCPtr create_html_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) { auto lowercase_tag_name = qualified_name.local_name().to_lowercase(); if (lowercase_tag_name == HTML::TagNames::a) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::area) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::audio) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::base) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::blink) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::body) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::br) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::button) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::canvas) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::data) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::datalist) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::details) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::dialog) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::dir) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::div) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::dl) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::embed) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::fieldset) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::font) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::form) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::frame) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::frameset) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::head) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::hr) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::html) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::iframe) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::img) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::input) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::label) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::legend) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::li) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::link) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::map) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::marquee) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::menu) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::meta) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::meter) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::object) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::ol) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::optgroup) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::option) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::output) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::p) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::param) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::picture) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); // NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification. if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::progress) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::script) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::select) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::slot) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::source) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::span) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::style) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::summary) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::caption) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::table) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::tr) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::template_) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::textarea) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::time) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::title) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::track) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::ul) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name == HTML::TagNames::video) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (lowercase_tag_name.is_one_of( HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::noscript, // Obsolete HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (HTML::is_valid_custom_element_name(qualified_name.local_name())) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); } -static WebIDL::ExceptionOr> create_svg_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) +static JS::GCPtr create_svg_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) { auto const& local_name = qualified_name.local_name(); if (local_name == SVG::TagNames::svg) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); // FIXME: Support SVG's mixedCase tag names properly. if (local_name.equals_ignoring_ascii_case(SVG::TagNames::clipPath)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::circle) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name.equals_ignoring_ascii_case(SVG::TagNames::defs)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::ellipse) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::line) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::linearGradient) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::mask) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::path) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::polygon) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::polyline) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::radialGradient) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::rect) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::g) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::stop) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::style) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::symbol) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::text) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::title) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::tspan) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); if (local_name == SVG::TagNames::use) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); return nullptr; } -static WebIDL::ExceptionOr> create_mathml_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) +static JS::GCPtr create_mathml_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) { - auto const& local_name = TRY_OR_THROW_OOM(realm.vm(), FlyString::from_deprecated_fly_string(qualified_name.local_name())); + auto const& local_name = MUST(FlyString::from_deprecated_fly_string(qualified_name.local_name())); if (local_name.is_one_of(MathML::TagNames::annotation, MathML::TagNames::annotation_xml, MathML::TagNames::maction, MathML::TagNames::math, MathML::TagNames::merror, MathML::TagNames::mfrac, MathML::TagNames::mi, MathML::TagNames::mmultiscripts, MathML::TagNames::mn, MathML::TagNames::mo, MathML::TagNames::mover, MathML::TagNames::mpadded, MathML::TagNames::mphantom, MathML::TagNames::mprescripts, MathML::TagNames::mroot, MathML::TagNames::mrow, MathML::TagNames::ms, MathML::TagNames::mspace, MathML::TagNames::msqrt, MathML::TagNames::mstyle, MathML::TagNames::msub, MathML::TagNames::msubsup, MathML::TagNames::msup, MathML::TagNames::mtable, MathML::TagNames::mtd, MathML::TagNames::mtext, MathML::TagNames::mtr, MathML::TagNames::munder, MathML::TagNames::munderover, MathML::TagNames::semantics)) - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document, move(qualified_name))); + return realm.heap().allocate(realm, document, move(qualified_name)); return nullptr; } @@ -511,7 +511,7 @@ WebIDL::ExceptionOr> create_element(Document& document // 2. Set result to a new element that implements interface, with no attributes, namespace set to the HTML namespace, // namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null, // is value set to is, and node document set to document. - auto element = TRY(create_html_element(realm, document, QualifiedName { local_name, prefix, Namespace::HTML })); + auto element = create_html_element(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); // 3. If the synchronous custom elements flag is set, then run this step while catching any exceptions: if (synchronous_custom_elements_flag) { @@ -596,7 +596,7 @@ WebIDL::ExceptionOr> create_element(Document& document // 2. Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document. - JS::NonnullGCPtr element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }).release_allocated_value_but_fixme_should_propagate_errors(); + JS::NonnullGCPtr element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); element->set_custom_element_state(CustomElementState::Failed); return element; } @@ -607,7 +607,7 @@ WebIDL::ExceptionOr> create_element(Document& document // 2. Otherwise: // 1. Set result to a new element that implements the HTMLElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to null, and node document set to document. - JS::NonnullGCPtr element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }).release_allocated_value_but_fixme_should_propagate_errors(); + auto element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); element->set_custom_element_state(CustomElementState::Undefined); // 2. Enqueue a custom element upgrade reaction given result and definition. @@ -624,7 +624,7 @@ WebIDL::ExceptionOr> create_element(Document& document auto qualified_name = QualifiedName { local_name, prefix, namespace_ }; if (namespace_ == Namespace::HTML) { - auto element = TRY(create_html_element(realm, document, move(qualified_name))); + auto element = create_html_element(realm, document, move(qualified_name)); element->set_is_value(move(is_value)); element->set_custom_element_state(CustomElementState::Uncustomized); @@ -637,7 +637,7 @@ WebIDL::ExceptionOr> create_element(Document& document } if (namespace_ == Namespace::SVG) { - auto element = TRY(create_svg_element(realm, document, qualified_name)); + auto element = create_svg_element(realm, document, qualified_name); if (element) { element->set_is_value(move(is_value)); element->set_custom_element_state(CustomElementState::Uncustomized); @@ -646,7 +646,7 @@ WebIDL::ExceptionOr> create_element(Document& document } if (namespace_ == Namespace::MathML) { - auto element = TRY(create_mathml_element(realm, document, qualified_name)); + auto element = create_mathml_element(realm, document, qualified_name); if (element) { element->set_is_value(move(is_value)); element->set_custom_element_state(CustomElementState::Uncustomized); @@ -660,7 +660,7 @@ WebIDL::ExceptionOr> create_element(Document& document // https://dom.spec.whatwg.org/#concept-element-interface // The element interface for any name and namespace is Element, unless stated otherwise. dbgln("Potential FIXME: Creating unknown generic element '{}' in namespace '{}'", local_name, namespace_); - JS::NonnullGCPtr element = realm.heap().allocate(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors(); + auto element = realm.heap().allocate(realm, document, move(qualified_name)); element->set_is_value(move(is_value)); element->set_custom_element_state(CustomElementState::Uncustomized); return element; diff --git a/Userland/Libraries/LibWeb/DOM/Event.cpp b/Userland/Libraries/LibWeb/DOM/Event.cpp index 9031e06e67..3998137470 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.cpp +++ b/Userland/Libraries/LibWeb/DOM/Event.cpp @@ -14,9 +14,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init) +JS::NonnullGCPtr Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index 53a158be2b..b6645130bb 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -45,7 +45,7 @@ public: using Path = Vector; - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, EventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, EventInit const& event_init = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, EventInit const& event_init); Event(JS::Realm&, FlyString const& type); diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index 98133b3135..f61efb6ccd 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -49,7 +49,7 @@ EventTarget::~EventTarget() = default; WebIDL::ExceptionOr> EventTarget::construct_impl(JS::Realm& realm) { // The new EventTarget() constructor steps are to do nothing. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } void EventTarget::initialize(JS::Realm& realm) @@ -581,7 +581,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl // 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback. auto listener = realm.heap().allocate_without_realm(); listener->type = name; - listener->callback = IDLEventListener::create(realm, *callback).release_value_but_fixme_should_propagate_errors(); + listener->callback = IDLEventListener::create(realm, *callback); // 6. Add an event listener with eventTarget and listener. add_an_event_listener(*listener); diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index e76fca5c68..9eb8d5dd7f 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -13,9 +13,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> HTMLCollection::create(ParentNode& root, Scope scope, Function filter) +JS::NonnullGCPtr HTMLCollection::create(ParentNode& root, Scope scope, Function filter) { - return MUST_OR_THROW_OOM(root.heap().allocate(root.realm(), root, scope, move(filter))); + return root.heap().allocate(root.realm(), root, scope, move(filter)); } HTMLCollection::HTMLCollection(ParentNode& root, Scope scope, Function filter) diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index 3383980d7e..49faad306f 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -34,7 +34,7 @@ public: Children, Descendants, }; - static WebIDL::ExceptionOr> create(ParentNode& root, Scope, Function filter); + [[nodiscard]] static JS::NonnullGCPtr create(ParentNode& root, Scope, Function filter); virtual ~HTMLCollection() override; diff --git a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp index 22e8a40d63..fadd6b4918 100644 --- a/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp +++ b/Userland/Libraries/LibWeb/DOM/IDLEventListener.cpp @@ -10,9 +10,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr callback) +JS::NonnullGCPtr IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr callback) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(callback))); + return realm.heap().allocate(realm, realm, move(callback)); } IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr callback) diff --git a/Userland/Libraries/LibWeb/DOM/IDLEventListener.h b/Userland/Libraries/LibWeb/DOM/IDLEventListener.h index eadb1893dd..672714babb 100644 --- a/Userland/Libraries/LibWeb/DOM/IDLEventListener.h +++ b/Userland/Libraries/LibWeb/DOM/IDLEventListener.h @@ -28,7 +28,7 @@ class IDLEventListener final : public JS::Object { JS_OBJECT(IDLEventListener, JS::Object); public: - static WebIDL::ExceptionOr> create(JS::Realm&, JS::NonnullGCPtr); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, JS::NonnullGCPtr); IDLEventListener(JS::Realm&, JS::NonnullGCPtr); virtual ~IDLEventListener() = default; diff --git a/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp b/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp index cf12fe9c1f..e3743ff454 100644 --- a/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/LiveNodeList.cpp @@ -12,9 +12,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> LiveNodeList::create(JS::Realm& realm, Node& root, Scope scope, Function filter) +JS::NonnullGCPtr LiveNodeList::create(JS::Realm& realm, Node& root, Scope scope, Function filter) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, root, scope, move(filter))); + return realm.heap().allocate(realm, realm, root, scope, move(filter)); } LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Scope scope, Function filter) diff --git a/Userland/Libraries/LibWeb/DOM/LiveNodeList.h b/Userland/Libraries/LibWeb/DOM/LiveNodeList.h index f9d527519a..cffd68aafa 100644 --- a/Userland/Libraries/LibWeb/DOM/LiveNodeList.h +++ b/Userland/Libraries/LibWeb/DOM/LiveNodeList.h @@ -23,7 +23,7 @@ public: Descendants, }; - static WebIDL::ExceptionOr> create(JS::Realm&, Node& root, Scope, Function filter); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Node& root, Scope, Function filter); virtual ~LiveNodeList() override; virtual u32 length() const override; diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index 9b877ff206..8c42f3fb2d 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { WebIDL::ExceptionOr> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr callback) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, callback)); + return realm.heap().allocate(realm, realm, callback); } // https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index cd74d8e2a1..8a1af51767 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -12,9 +12,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) +JS::NonnullGCPtr MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value)); + return realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value); } MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h index bb2f16d94f..690103d3cf 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.h +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h @@ -16,7 +16,7 @@ class MutationRecord : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); virtual ~MutationRecord() override; diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 044e72150f..c168a2aeb5 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -13,10 +13,10 @@ namespace Web::DOM { -WebIDL::ExceptionOr> NamedNodeMap::create(Element& element) +JS::NonnullGCPtr NamedNodeMap::create(Element& element) { auto& realm = element.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, element)); + return realm.heap().allocate(realm, element); } NamedNodeMap::NamedNodeMap(Element& element) diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index 09d283c0eb..7a7e46d21e 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -22,7 +22,7 @@ class NamedNodeMap : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(NamedNodeMap, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(Element&); + [[nodiscard]] static JS::NonnullGCPtr create(Element&); ~NamedNodeMap() = default; virtual bool is_supported_property_index(u32 index) const override; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index ba73680a6f..66ef92be48 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -777,7 +777,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) else if (is(this)) { // Document auto document_ = verify_cast(this); - auto document_copy = Document::create(this->realm(), document_->url()).release_value_but_fixme_should_propagate_errors(); + auto document_copy = Document::create(this->realm(), document_->url()); // Set copy’s encoding, content type, URL, origin, type, and mode to those of node. document_copy->set_encoding(document_->encoding()); @@ -790,7 +790,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) } else if (is(this)) { // DocumentType auto document_type = verify_cast(this); - auto document_type_copy = heap().allocate(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors(); + auto document_type_copy = heap().allocate(realm(), *document); // Set copy’s name, public ID, and system ID to those of node. document_type_copy->set_name(document_type->name()); @@ -807,26 +807,26 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) auto text = verify_cast(this); // Set copy’s data to that of node. - auto text_copy = heap().allocate(realm(), *document, text->data()).release_allocated_value_but_fixme_should_propagate_errors(); + auto text_copy = heap().allocate(realm(), *document, text->data()); copy = move(text_copy); } else if (is(this)) { // Comment auto comment = verify_cast(this); // Set copy’s data to that of node. - auto comment_copy = heap().allocate(realm(), *document, comment->data()).release_allocated_value_but_fixme_should_propagate_errors(); + auto comment_copy = heap().allocate(realm(), *document, comment->data()); copy = move(comment_copy); } else if (is(this)) { // ProcessingInstruction auto processing_instruction = verify_cast(this); // Set copy’s target and data to those of node. - auto processing_instruction_copy = heap().allocate(realm(), *document, processing_instruction->data(), processing_instruction->target()).release_allocated_value_but_fixme_should_propagate_errors(); + auto processing_instruction_copy = heap().allocate(realm(), *document, processing_instruction->data(), processing_instruction->target()); copy = processing_instruction_copy; } // Otherwise, Do nothing. else if (is(this)) { - copy = heap().allocate(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors(); + copy = heap().allocate(realm(), *document); } // FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise. @@ -937,7 +937,7 @@ JS::NonnullGCPtr Node::child_nodes() if (!m_child_nodes) { m_child_nodes = LiveNodeList::create(realm(), *this, LiveNodeList::Scope::Children, [](auto&) { return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_child_nodes; } @@ -1259,7 +1259,7 @@ void Node::string_replace_all(DeprecatedString const& string) // 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document. if (!string.is_empty()) - node = heap().allocate(realm(), document(), string).release_allocated_value_but_fixme_should_propagate_errors(); + node = heap().allocate(realm(), document(), string); // 3. Replace all with node within parent. replace_all(node); @@ -1517,14 +1517,14 @@ void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribu if (interested_observers.is_empty()) return; - auto added_nodes_list = StaticNodeList::create(realm(), move(added_nodes)).release_value_but_fixme_should_propagate_errors(); - auto removed_nodes_list = StaticNodeList::create(realm(), move(removed_nodes)).release_value_but_fixme_should_propagate_errors(); + auto added_nodes_list = StaticNodeList::create(realm(), move(added_nodes)); + auto removed_nodes_list = StaticNodeList::create(realm(), move(removed_nodes)); // 4. For each observer → mappedOldValue of interestedObservers: for (auto& interested_observer : interested_observers) { // 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue, // addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling. - auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value).release_value_but_fixme_should_propagate_errors(); + auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value); // 2. Enqueue record to observer’s record queue. interested_observer.key->enqueue_record({}, move(record)); @@ -1661,7 +1661,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) return; if (element->include_in_accessibility_tree()) { - auto current_node = AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors(); + auto current_node = AccessibilityTreeNode::create(&document(), this); parent.append_child(current_node); if (has_child_nodes()) { for_each_child([¤t_node](DOM::Node& child) { @@ -1674,7 +1674,7 @@ void Node::build_accessibility_tree(AccessibilityTreeNode& parent) }); } } else if (is_text()) { - parent.append_child(AccessibilityTreeNode::create(&document(), this).release_value_but_fixme_should_propagate_errors()); + parent.append_child(AccessibilityTreeNode::create(&document(), this)); if (has_child_nodes()) { for_each_child([&parent](DOM::Node& child) { child.build_accessibility_tree(parent); diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp index 8342de9dc8..accc89fc19 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp @@ -10,9 +10,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) +JS::NonnullGCPtr NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, callback)); + return realm.heap().allocate(realm, realm, callback); } NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback) diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.h b/Userland/Libraries/LibWeb/DOM/NodeFilter.h index aa6cb55156..387c01cbe1 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.h +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.h @@ -15,7 +15,7 @@ class NodeFilter final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(NodeFilter, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, WebIDL::CallbackType&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, WebIDL::CallbackType&); virtual ~NodeFilter() = default; diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp index bb9caf2cb9..e61576c771 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -51,7 +51,7 @@ WebIDL::ExceptionOr> NodeIterator::create(Node& r // 2. Set iterator’s root and iterator’s reference to root. // 3. Set iterator’s pointer before reference to true. auto& realm = root.realm(); - auto iterator = MUST_OR_THROW_OOM(realm.heap().allocate(realm, root)); + auto iterator = realm.heap().allocate(realm, root); // 4. Set iterator’s whatToShow to whatToShow. iterator->m_what_to_show = what_to_show; diff --git a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp index 91649fc8b2..1ebd908e0b 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp @@ -22,19 +22,19 @@ WebIDL::ExceptionOr> convert_nodes_to_single_node(Vector< // 4. Otherwise, set node to a new DocumentFragment node whose node document is document, and then append each node in nodes, if any, to it. // 5. Return node. - auto potentially_convert_string_to_text_node = [&document](Variant, DeprecatedString> const& node) -> JS::ThrowCompletionOr> { + auto potentially_convert_string_to_text_node = [&document](Variant, DeprecatedString> const& node) -> JS::NonnullGCPtr { if (node.has>()) return *node.get>(); - return MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document, node.get())); + return document.heap().allocate(document.realm(), document, node.get()); }; if (nodes.size() == 1) - return TRY(potentially_convert_string_to_text_node(nodes.first())); + return potentially_convert_string_to_text_node(nodes.first()); - auto document_fragment = MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), document)); + auto document_fragment = document.heap().allocate(document.realm(), document); for (auto& unconverted_node : nodes) { - auto node = TRY(potentially_convert_string_to_text_node(unconverted_node)); + auto node = potentially_convert_string_to_text_node(unconverted_node); (void)TRY(document_fragment->append_child(node)); } diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index ff9acd9936..db38f3af5d 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -115,7 +115,7 @@ JS::NonnullGCPtr ParentNode::children() if (!m_children) { m_children = HTMLCollection::create(*this, HTMLCollection::Scope::Children, [](Element const&) { return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_children; } @@ -128,7 +128,7 @@ JS::NonnullGCPtr ParentNode::get_elements_by_tag_name(Deprecated if (qualified_name == "*") { return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) { return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } // 2. Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements: @@ -140,13 +140,13 @@ JS::NonnullGCPtr ParentNode::get_elements_by_tag_name(Deprecated // - Whose namespace is not the HTML namespace and whose qualified name is qualifiedName. return element.qualified_name() == qualified_name; - }).release_value_but_fixme_should_propagate_errors(); + }); } // 3. Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose qualified name is qualifiedName. return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [qualified_name](Element const& element) { return element.qualified_name() == qualified_name; - }).release_value_but_fixme_should_propagate_errors(); + }); } // https://dom.spec.whatwg.org/#concept-getelementsbytagnamens @@ -162,27 +162,27 @@ JS::NonnullGCPtr ParentNode::get_elements_by_tag_name_ns(Depreca if (namespace_ == "*" && local_name == "*") { return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const&) { return true; - }).release_value_but_fixme_should_propagate_errors(); + }); } // 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose local name is localName. if (namespace_ == "*") { return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [local_name](Element const& element) { return element.local_name() == local_name; - }).release_value_but_fixme_should_propagate_errors(); + }); } // 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace. if (local_name == "*") { return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [namespace_](Element const& element) { return element.namespace_() == namespace_; - }).release_value_but_fixme_should_propagate_errors(); + }); } // 5. Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose namespace is namespace and local name is localName. return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [namespace_, local_name](Element const& element) { return element.namespace_() == namespace_ && element.local_name() == local_name; - }).release_value_but_fixme_should_propagate_errors(); + }); } // https://dom.spec.whatwg.org/#dom-parentnode-prepend diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index dd0dc115d5..49c62ab92a 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -31,21 +31,21 @@ HashTable& Range::live_ranges() return ranges; } -WebIDL::ExceptionOr> Range::create(HTML::Window& window) +JS::NonnullGCPtr Range::create(HTML::Window& window) { return Range::create(window.associated_document()); } -WebIDL::ExceptionOr> Range::create(Document& document) +JS::NonnullGCPtr Range::create(Document& document) { auto& realm = document.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, document)); + return realm.heap().allocate(realm, document); } -WebIDL::ExceptionOr> Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) +JS::NonnullGCPtr Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset) { auto& realm = start_container.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset)); + return realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset); } WebIDL::ExceptionOr> Range::construct_impl(JS::Realm& realm) @@ -430,12 +430,12 @@ WebIDL::ExceptionOr Range::select_node_contents(Node& node) JS::NonnullGCPtr Range::clone_range() const { - return heap().allocate(shape().realm(), const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset).release_allocated_value_but_fixme_should_propagate_errors(); + return heap().allocate(shape().realm(), const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset); } JS::NonnullGCPtr Range::inverted() const { - return heap().allocate(shape().realm(), const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset).release_allocated_value_but_fixme_should_propagate_errors(); + return heap().allocate(shape().realm(), const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset); } JS::NonnullGCPtr Range::normalized() const @@ -589,7 +589,7 @@ WebIDL::ExceptionOr> Range::extract_contents( WebIDL::ExceptionOr> Range::extract() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = MUST_OR_THROW_OOM(heap().allocate(realm(), const_cast(start_container()->document()))); + auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); // 2. If range is collapsed, then return fragment. if (collapsed()) @@ -717,7 +717,7 @@ WebIDL::ExceptionOr> Range::extract() TRY(fragment->append_child(clone)); // 3. Let subrange be a new live range whose start is (original start node, original start offset) and whose end is (first partially contained child, first partially contained child’s length). - auto subrange = TRY(Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length())); + auto subrange = Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length()); // 4. Let subfragment be the result of extracting subrange. auto subfragment = TRY(subrange->extract()); @@ -755,7 +755,7 @@ WebIDL::ExceptionOr> Range::extract() TRY(fragment->append_child(clone)); // 3. Let subrange be a new live range whose start is (last partially contained child, 0) and whose end is (original end node, original end offset). - auto subrange = TRY(Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset)); + auto subrange = Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset); // 4. Let subfragment be the result of extracting subrange. auto subfragment = TRY(subrange->extract()); @@ -918,7 +918,7 @@ WebIDL::ExceptionOr> Range::clone_contents() WebIDL::ExceptionOr> Range::clone_the_contents() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = MUST_OR_THROW_OOM(heap().allocate(realm(), const_cast(start_container()->document()))); + auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); // 2. If range is collapsed, then return fragment. if (collapsed()) @@ -1018,7 +1018,7 @@ WebIDL::ExceptionOr> Range::clone_the_content TRY(fragment->append_child(clone)); // 3. Let subrange be a new live range whose start is (original start node, original start offset) and whose end is (first partially contained child, first partially contained child’s length). - auto subrange = TRY(Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length())); + auto subrange = Range::create(original_start_node, original_start_offset, *first_partially_contained_child, first_partially_contained_child->length()); // 4. Let subfragment be the result of cloning the contents of subrange. auto subfragment = TRY(subrange->clone_the_contents()); @@ -1057,7 +1057,7 @@ WebIDL::ExceptionOr> Range::clone_the_content TRY(fragment->append_child(clone)); // 3. Let subrange be a new live range whose start is (last partially contained child, 0) and whose end is (original end node, original end offset). - auto subrange = TRY(Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset)); + auto subrange = Range::create(*last_partially_contained_child, 0, original_end_node, original_end_offset); // 4. Let subfragment be the result of cloning the contents of subrange. auto subfragment = TRY(subrange->clone_the_contents()); diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index 1a24e922b5..97f20f852a 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -26,9 +26,9 @@ class Range final : public AbstractRange { WEB_PLATFORM_OBJECT(Range, AbstractRange); public: - static WebIDL::ExceptionOr> create(Document&); - static WebIDL::ExceptionOr> create(HTML::Window&); - static WebIDL::ExceptionOr> create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); + [[nodiscard]] static JS::NonnullGCPtr create(Document&); + [[nodiscard]] static JS::NonnullGCPtr create(HTML::Window&); + [[nodiscard]] static JS::NonnullGCPtr create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); static WebIDL::ExceptionOr> construct_impl(JS::Realm&); virtual ~Range() override; diff --git a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp index 03821977f4..591616e8c2 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp @@ -10,9 +10,9 @@ namespace Web::DOM { -WebIDL::ExceptionOr> StaticNodeList::create(JS::Realm& realm, Vector> static_nodes) +JS::NonnullGCPtr StaticNodeList::create(JS::Realm& realm, Vector> static_nodes) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(static_nodes))); + return realm.heap().allocate(realm, realm, move(static_nodes)); } StaticNodeList::StaticNodeList(JS::Realm& realm, Vector> static_nodes) diff --git a/Userland/Libraries/LibWeb/DOM/StaticNodeList.h b/Userland/Libraries/LibWeb/DOM/StaticNodeList.h index 46997e9f98..86f6c15db9 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticNodeList.h +++ b/Userland/Libraries/LibWeb/DOM/StaticNodeList.h @@ -15,7 +15,7 @@ class StaticNodeList final : public NodeList { WEB_PLATFORM_OBJECT(StaticNodeList, NodeList); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Vector>); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector>); virtual ~StaticNodeList() override; diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index 1aec3b2081..41f6722a2a 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -32,7 +32,7 @@ WebIDL::ExceptionOr> StaticRange::construct_impl(J return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."); // 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]). - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset)); + return realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset); } void StaticRange::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index ef0280352f..0a86ebe852 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -41,7 +41,7 @@ WebIDL::ExceptionOr> Text::construct_impl(JS::Realm& real { // The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s associated Document. auto& window = verify_cast(HTML::current_global_object()); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, window.associated_document(), data)); + return realm.heap().allocate(realm, window.associated_document(), data); } void Text::set_owner_input_element(Badge, HTML::HTMLInputElement& input_element) @@ -67,7 +67,7 @@ WebIDL::ExceptionOr> Text::split_text(size_t offset) auto new_data = TRY(substring_data(offset, count)); // 5. Let new node be a new Text node, with the same node document as node. Set new node’s data to new data. - auto new_node = MUST_OR_THROW_OOM(heap().allocate(realm(), document(), new_data)); + auto new_node = heap().allocate(realm(), document(), new_data); // 6. Let parent be node’s parent. JS::GCPtr parent = this->parent(); diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp index fec61ba5ff..e86a8a50b3 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -37,12 +37,12 @@ void TreeWalker::visit_edges(Cell::Visitor& visitor) } // https://dom.spec.whatwg.org/#dom-document-createtreewalker -WebIDL::ExceptionOr> TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr filter) +JS::NonnullGCPtr TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr filter) { // 1. Let walker be a new TreeWalker object. // 2. Set walker’s root and walker’s current to root. auto& realm = root.realm(); - auto walker = MUST_OR_THROW_OOM(realm.heap().allocate(realm, root)); + auto walker = realm.heap().allocate(realm, root); // 3. Set walker’s whatToShow to whatToShow. walker->m_what_to_show = what_to_show; diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.h b/Userland/Libraries/LibWeb/DOM/TreeWalker.h index 65c3e7ee0e..b6e182ff7d 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.h +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.h @@ -15,7 +15,7 @@ class TreeWalker final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(TreeWalker, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(Node& root, unsigned what_to_show, JS::GCPtr); + [[nodiscard]] static JS::NonnullGCPtr create(Node& root, unsigned what_to_show, JS::GCPtr); virtual ~TreeWalker() override; diff --git a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp index cd5d2e03e6..cefafb2d8f 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp @@ -21,7 +21,7 @@ WebIDL::ExceptionOr> parse_fragment(Depr auto& realm = context_element.realm(); auto new_children = HTML::HTMLParser::parse_html_fragment(context_element, markup); - auto fragment = MUST_OR_THROW_OOM(realm.heap().allocate(realm, context_element.document())); + auto fragment = realm.heap().allocate(realm, context_element.document()); for (auto& child : new_children) { // I don't know if this can throw here, but let's be safe. diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index e94f5235eb..820ad9aac5 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -25,7 +25,7 @@ namespace Web::DOMParsing { WebIDL::ExceptionOr> XMLSerializer::construct_impl(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } XMLSerializer::XMLSerializer(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index 6f8b29da7e..cb1a10cbe3 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -20,7 +20,7 @@ WebIDL::ExceptionOr> TextDecoder::construct_impl(J if (!decoder.has_value()) return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, TRY_OR_THROW_OOM(vm, String::formatted("Invalid encoding {}", encoding)) }; - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *decoder, move(encoding), false, false)); + return realm.heap().allocate(realm, realm, *decoder, move(encoding), false, false); } // https://encoding.spec.whatwg.org/#dom-textdecoder diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp index cb60a63ee8..f2a21b28d2 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp @@ -14,7 +14,7 @@ namespace Web::Encoding { WebIDL::ExceptionOr> TextEncoder::construct_impl(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } TextEncoder::TextEncoder(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/Fetch/Body.cpp b/Userland/Libraries/LibWeb/Fetch/Body.cpp index 7596f2a663..601f329355 100644 --- a/Userland/Libraries/LibWeb/Fetch/Body.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Body.cpp @@ -113,7 +113,7 @@ WebIDL::ExceptionOr package_data(JS::Realm& realm, ByteBuffer bytes, // Return a Blob whose contents are bytes and type attribute is mimeType. // NOTE: If extracting the mime type returns failure, other browsers set it to an empty string - not sure if that's spec'd. auto mime_type_string = mime_type.has_value() ? TRY_OR_THROW_OOM(vm, mime_type->serialized()) : String {}; - return TRY(FileAPI::Blob::create(realm, move(bytes), move(mime_type_string))); + return FileAPI::Blob::create(realm, move(bytes), move(mime_type_string)); } case PackageDataType::FormData: // If mimeType’s essence is "multipart/form-data", then: diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index b116de67f3..d136d1a50d 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -45,12 +45,12 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm, else if (auto const* blob_handle = object.get_pointer>()) { // FIXME: "set stream to the result of running object’s get stream" (void)blob_handle; - stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + stream = realm.heap().allocate(realm, realm); } // 4. Otherwise, set stream to a new ReadableStream object, and set up stream. else { // FIXME: "set up stream" - stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + stream = realm.heap().allocate(realm, realm); } // 5. Assert: stream is a ReadableStream object. diff --git a/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp index 28afe8da7d..e9657cf1c0 100644 --- a/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp +++ b/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp @@ -111,7 +111,7 @@ JS::NonnullGCPtr fetch(JS::VM& vm, RequestInfo const& input, Reques // 4. Set responseObject to the result of creating a Response object, given response, "immutable", and // relevantRealm. - auto response_object = Response::create(relevant_realm, response, Headers::Guard::Immutable).release_value_but_fixme_should_propagate_errors(); + auto response_object = Response::create(relevant_realm, response, Headers::Guard::Immutable); response_object_handle = JS::make_handle(response_object); // 5. Resolve p with responseObject. diff --git a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index 61097dd489..cd0fbcd0f9 100644 --- a/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -859,7 +859,7 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& rea // 4. If request’s service-workers mode is "all", then: if (request->service_workers_mode() == Infrastructure::Request::ServiceWorkersMode::All) { // 1. Let requestForServiceWorker be a clone of request. - auto request_for_service_worker = TRY(request->clone(realm)); + auto request_for_service_worker = request->clone(realm); // 2. If requestForServiceWorker’s body is non-null, then: if (!request_for_service_worker->body().has()) { @@ -1262,7 +1262,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fet // NOTE: Implementations are encouraged to avoid teeing request’s body’s stream when request’s body’s // source is null as only a single body is needed in that case. E.g., when request’s body’s source // is null, redirects and authentication will end up failing the fetch. - http_request = TRY(request->clone(realm)); + http_request = request->clone(realm); // 2. Set httpFetchParams to a copy of fetchParams. // 3. Set httpFetchParams’s request to httpRequest. diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index eeaf89249a..3c5a5e721d 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -17,7 +17,7 @@ WebIDL::ExceptionOr> Headers::construct_impl(JS::Realm auto& vm = realm.vm(); // The new Headers(init) constructor steps are: - auto headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::HeaderList::create(vm))); + auto headers = realm.heap().allocate(realm, realm, Infrastructure::HeaderList::create(vm)); // 1. Set this’s guard to "none". headers->m_guard = Guard::None; diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 729026042a..cdbdc28955 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto prototype = heap().allocate(realm, realm); m_prototypes.set("HeadersIterator"sv, prototype); } @@ -23,9 +23,9 @@ void Intrinsics::create_web_prototype_and_constructor( namespace Web::Fetch { -WebIDL::ExceptionOr> HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind) +JS::NonnullGCPtr HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind) { - return MUST_OR_THROW_OOM(headers.heap().allocate(headers.realm(), headers, iteration_kind)); + return headers.heap().allocate(headers.realm(), headers, iteration_kind); } HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind) diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h index 6375a40560..575abf97ea 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h @@ -16,7 +16,7 @@ class HeadersIterator final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(HeadersIterator, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(Headers const&, JS::Object::PropertyKind iteration_kind); + [[nodiscard]] static JS::NonnullGCPtr create(Headers const&, JS::Object::PropertyKind iteration_kind); virtual ~HeadersIterator() override; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index 5c7ee0c8c0..bb6aedee65 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -26,12 +26,12 @@ Body::Body(JS::Handle stream, SourceType source, Option } // https://fetch.spec.whatwg.org/#concept-body-clone -WebIDL::ExceptionOr Body::clone(JS::Realm& realm) const +Body Body::clone(JS::Realm& realm) const { // To clone a body body, run these steps: // FIXME: 1. Let « out1, out2 » be the result of teeing body’s stream. // FIXME: 2. Set body’s stream to out1. - auto out2 = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto out2 = realm.heap().allocate(realm, realm); // 3. Return a body whose stream is out2 and other members are copied from body. return Body { JS::make_handle(out2), m_source, m_length }; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h index ff40d57ebe..ddf93a08df 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.h @@ -36,7 +36,7 @@ public: [[nodiscard]] SourceType const& source() const { return m_source; } [[nodiscard]] Optional const& length() const { return m_length; } - WebIDL::ExceptionOr clone(JS::Realm&) const; + [[nodiscard]] Body clone(JS::Realm&) const; WebIDL::ExceptionOr fully_read(JS::Realm&, ProcessBodyCallback process_body, ProcessBodyErrorCallback process_body_error, TaskDestination task_destination) const; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index 0c3bc57bba..3a6a3a2d66 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -202,7 +202,7 @@ ErrorOr Request::byte_serialize_origin() const } // https://fetch.spec.whatwg.org/#concept-request-clone -WebIDL::ExceptionOr> Request::clone(JS::Realm& realm) const +JS::NonnullGCPtr Request::clone(JS::Realm& realm) const { // To clone a request request, run these steps: auto& vm = realm.vm(); @@ -250,7 +250,7 @@ WebIDL::ExceptionOr> Request::clone(JS::Realm& realm) // 2. If request’s body is non-null, set newRequest’s body to the result of cloning request’s body. if (auto const* body = m_body.get_pointer()) - new_request->set_body(TRY(body->clone(realm))); + new_request->set_body(body->clone(realm)); // 3. Return newRequest. return new_request; diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index 7f1e4feff0..30ce01bb81 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -297,7 +297,7 @@ public: [[nodiscard]] ErrorOr serialize_origin() const; [[nodiscard]] ErrorOr byte_serialize_origin() const; - [[nodiscard]] WebIDL::ExceptionOr> clone(JS::Realm&) const; + [[nodiscard]] JS::NonnullGCPtr clone(JS::Realm&) const; [[nodiscard]] ErrorOr add_range_header(u64 first, Optional const& last); [[nodiscard]] ErrorOr add_origin_header(); diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index 527b735c22..18ef9bf8a7 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -164,7 +164,7 @@ WebIDL::ExceptionOr> Response::clone(JS::Realm& realm // 3. If response’s body is non-null, then set newResponse’s body to the result of cloning response’s body. if (m_body.has_value()) - new_response->set_body(TRY(m_body->clone(realm))); + new_response->set_body(m_body->clone(realm)); // 4. Return newResponse. return new_response; diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index c1dfb3fbbf..e6fec92a4f 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -79,18 +79,18 @@ Optional Request::body_impl() } // https://fetch.spec.whatwg.org/#request-create -WebIDL::ExceptionOr> Request::create(JS::Realm& realm, JS::NonnullGCPtr request, Headers::Guard guard) +JS::NonnullGCPtr Request::create(JS::Realm& realm, JS::NonnullGCPtr request, Headers::Guard guard) { // 1. Let requestObject be a new Request object with realm. // 2. Set requestObject’s request to request. - auto request_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, request)); + auto request_object = realm.heap().allocate(realm, realm, request); // 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard. - request_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, request->header_list())); + request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); request_object->m_headers->set_guard(guard); // 4. Set requestObject’s signal to a new AbortSignal object with realm. - request_object->m_signal = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + request_object->m_signal = realm.heap().allocate(realm, realm); // 5. Return requestObject. return request_object; @@ -102,7 +102,7 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto request_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::Request::create(vm))); + auto request_object = realm.heap().allocate(realm, realm, Infrastructure::Request::create(vm)); // 1. Let request be null. JS::GCPtr input_request; @@ -387,14 +387,14 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm // 28. Set this’s signal to a new AbortSignal object with this’s relevant Realm. auto& this_relevant_realm = HTML::relevant_realm(*request_object); - request_object->m_signal = MUST_OR_THROW_OOM(realm.heap().allocate(this_relevant_realm, this_relevant_realm)); + request_object->m_signal = realm.heap().allocate(this_relevant_realm, this_relevant_realm); // 29. If signal is not null, then make this’s signal follow signal. if (input_signal != nullptr) request_object->m_signal->follow(*input_signal); // 30. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is request’s header list and guard is "request". - request_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, request->header_list())); + request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); request_object->m_headers->set_guard(Headers::Guard::Request); // 31. If this’s request’s mode is "no-cors", then: @@ -639,10 +639,10 @@ WebIDL::ExceptionOr> Request::clone() const return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Request is unusable"sv }; // 2. Let clonedRequest be the result of cloning this’s request. - auto cloned_request = TRY(m_request->clone(realm)); + auto cloned_request = m_request->clone(realm); // 3. Let clonedRequestObject be the result of creating a Request object, given clonedRequest, this’s headers’s guard, and this’s relevant Realm. - auto cloned_request_object = TRY(Request::create(HTML::relevant_realm(*this), cloned_request, m_headers->guard())); + auto cloned_request_object = Request::create(HTML::relevant_realm(*this), cloned_request, m_headers->guard()); // 4. Make clonedRequestObject’s signal follow this’s signal. cloned_request_object->m_signal->follow(*m_signal); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.h b/Userland/Libraries/LibWeb/Fetch/Request.h index f5a923c819..7b74776bbb 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.h +++ b/Userland/Libraries/LibWeb/Fetch/Request.h @@ -66,7 +66,7 @@ class Request final WEB_PLATFORM_OBJECT(Request, Bindings::PlatformObject); public: - [[nodiscard]] static WebIDL::ExceptionOr> create(JS::Realm&, JS::NonnullGCPtr, Headers::Guard); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, JS::NonnullGCPtr, Headers::Guard); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, RequestInfo const& input, RequestInit const& init = {}); virtual ~Request() override; diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 82526baa8b..e9b528cac9 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -71,14 +71,14 @@ Optional Response::body_impl() } // https://fetch.spec.whatwg.org/#response-create -WebIDL::ExceptionOr> Response::create(JS::Realm& realm, JS::NonnullGCPtr response, Headers::Guard guard) +JS::NonnullGCPtr Response::create(JS::Realm& realm, JS::NonnullGCPtr response, Headers::Guard guard) { // 1. Let responseObject be a new Response object with realm. // 2. Set responseObject’s response to response. - auto response_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, response)); + auto response_object = realm.heap().allocate(realm, realm, response); // 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard. - response_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, response->header_list())); + response_object->m_headers = realm.heap().allocate(realm, realm, response->header_list()); response_object->m_headers->set_guard(guard); // 4. Return responseObject. @@ -134,14 +134,14 @@ WebIDL::ExceptionOr> Response::construct_impl(JS::Rea auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto response_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, Infrastructure::Response::create(vm))); + auto response_object = realm.heap().allocate(realm, realm, Infrastructure::Response::create(vm)); // 1. Set this’s response to a new response. // NOTE: This is done at the beginning as the 'this' value Response object // cannot exist with a null Infrastructure::Response. // 2. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is this’s response’s header list and guard is "response". - response_object->m_headers = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, response_object->response()->header_list())); + response_object->m_headers = realm.heap().allocate(realm, realm, response_object->response()->header_list()); response_object->m_headers->set_guard(Headers::Guard::Response); // 3. Let bodyWithType be null. @@ -158,7 +158,7 @@ WebIDL::ExceptionOr> Response::construct_impl(JS::Rea } // https://fetch.spec.whatwg.org/#dom-response-error -WebIDL::ExceptionOr> Response::error(JS::VM& vm) +JS::NonnullGCPtr Response::error(JS::VM& vm) { // The static error() method steps are to return the result of creating a Response object, given a new network error, "immutable", and this’s relevant Realm. // FIXME: How can we reliably get 'this', i.e. the object the function was called on, in IDL-defined functions? @@ -184,7 +184,7 @@ WebIDL::ExceptionOr> Response::redirect(JS::VM& vm, S // 4. Let responseObject be the result of creating a Response object, given a new response, "immutable", and this’s relevant Realm. // FIXME: How can we reliably get 'this', i.e. the object the function was called on, in IDL-defined functions? - auto response_object = TRY(Response::create(realm, Infrastructure::Response::create(vm), Headers::Guard::Immutable)); + auto response_object = Response::create(realm, Infrastructure::Response::create(vm), Headers::Guard::Immutable); // 5. Set responseObject’s response’s status to status. response_object->response()->set_status(status); @@ -213,7 +213,7 @@ WebIDL::ExceptionOr> Response::json(JS::VM& vm, JS::V // 3. Let responseObject be the result of creating a Response object, given a new response, "response", and this’s relevant Realm. // FIXME: How can we reliably get 'this', i.e. the object the function was called on, in IDL-defined functions? - auto response_object = TRY(Response::create(realm, Infrastructure::Response::create(vm), Headers::Guard::Response)); + auto response_object = Response::create(realm, Infrastructure::Response::create(vm), Headers::Guard::Response); // 4. Perform initialize a response given responseObject, init, and (body, "application/json"). auto body_with_type = Infrastructure::BodyWithType { @@ -294,7 +294,7 @@ WebIDL::ExceptionOr> Response::clone() const auto cloned_response = TRY(m_response->clone(realm)); // 3. Return the result of creating a Response object, given clonedResponse, this’s headers’s guard, and this’s relevant Realm. - return TRY(Response::create(HTML::relevant_realm(*this), cloned_response, m_headers->guard())); + return Response::create(HTML::relevant_realm(*this), cloned_response, m_headers->guard()); } } diff --git a/Userland/Libraries/LibWeb/Fetch/Response.h b/Userland/Libraries/LibWeb/Fetch/Response.h index bf42ffbd4f..dc34663005 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.h +++ b/Userland/Libraries/LibWeb/Fetch/Response.h @@ -33,7 +33,7 @@ class Response final WEB_PLATFORM_OBJECT(Response, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, JS::NonnullGCPtr, Headers::Guard); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, JS::NonnullGCPtr, Headers::Guard); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional const& body = {}, ResponseInit const& init = {}); virtual ~Response() override; @@ -48,7 +48,7 @@ public: [[nodiscard]] JS::NonnullGCPtr response() const { return m_response; } // JS API functions - static WebIDL::ExceptionOr> error(JS::VM&); + [[nodiscard]] static JS::NonnullGCPtr error(JS::VM&); static WebIDL::ExceptionOr> redirect(JS::VM&, String const& url, u16 status); static WebIDL::ExceptionOr> json(JS::VM&, JS::Value data, ResponseInit const& init = {}); [[nodiscard]] Bindings::ResponseType type() const; diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index d8ba7732e0..cc8124b57b 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -22,9 +22,9 @@ namespace Web::FileAPI { -WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, String type) +JS::NonnullGCPtr Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, String type) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(byte_buffer), move(type))); + return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); } // https://w3c.github.io/FileAPI/#convert-line-endings-to-native @@ -146,18 +146,16 @@ void Blob::initialize(JS::Realm& realm) } // https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob -WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, Optional> const& blob_parts, Optional const& options) +JS::NonnullGCPtr Blob::create(JS::Realm& realm, Optional> const& blob_parts, Optional const& options) { - auto& vm = realm.vm(); - // 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 MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); ByteBuffer byte_buffer {}; // 2. Let bytes be the result of processing blob parts given blobParts and options. if (blob_parts.has_value()) { - byte_buffer = TRY_OR_THROW_OOM(realm.vm(), process_blob_parts(blob_parts.value(), options)); + byte_buffer = MUST(process_blob_parts(blob_parts.value(), options)); } auto type = String {}; @@ -173,11 +171,11 @@ WebIDL::ExceptionOr> Blob::create(JS::Realm& realm, Optio // 2. Convert every character in t to ASCII lowercase. if (!type.is_empty()) - type = TRY_OR_THROW_OOM(vm, Infra::to_ascii_lowercase(type)); + type = MUST(Infra::to_ascii_lowercase(type)); } // 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 MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(byte_buffer), move(type))); + return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); } WebIDL::ExceptionOr> Blob::construct_impl(JS::Realm& realm, Optional> const& blob_parts, Optional const& options) @@ -250,7 +248,7 @@ WebIDL::ExceptionOr> Blob::slice(Optional start, Opt // b. S.size = span. // c. S.type = relativeContentType. auto byte_buffer = TRY_OR_THROW_OOM(vm, m_byte_buffer.slice(relative_start, span)); - return MUST_OR_THROW_OOM(heap().allocate(realm(), realm(), move(byte_buffer), move(relative_content_type))); + return heap().allocate(realm(), realm(), move(byte_buffer), move(relative_content_type)); } // https://w3c.github.io/FileAPI/#dom-blob-stream @@ -266,7 +264,7 @@ WebIDL::ExceptionOr> Blob::get_stream( auto& realm = this->realm(); // 1. Let stream be a new ReadableStream created in blob’s relevant Realm. - auto stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto stream = realm.heap().allocate(realm, realm); // 2. Set up stream with byte reading support. TRY(set_up_readable_stream_controller_with_byte_reading_support(stream)); diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index 3657812022..d4bbdfcabd 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -32,8 +32,8 @@ class Blob : public Bindings::PlatformObject { public: virtual ~Blob() override; - static WebIDL::ExceptionOr> create(JS::Realm&, ByteBuffer, String type); - static WebIDL::ExceptionOr> create(JS::Realm&, Optional> const& blob_parts = {}, Optional const& options = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, ByteBuffer, String type); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Optional> const& blob_parts = {}, Optional const& options = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional> const& blob_parts = {}, Optional const& options = {}); // https://w3c.github.io/FileAPI/#dfn-size diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index 679af049fd..95a87c8ccf 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -67,7 +67,7 @@ WebIDL::ExceptionOr> 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 MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(bytes), move(name), move(type), last_modified)); + return realm.heap().allocate(realm, realm, move(bytes), move(name), move(type), last_modified); } WebIDL::ExceptionOr> File::construct_impl(JS::Realm& realm, Vector const& file_bits, String const& file_name, Optional const& options) diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp index 45fa1b075e..ec259dbda0 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp @@ -11,9 +11,9 @@ namespace Web::FileAPI { -WebIDL::ExceptionOr> FileList::create(JS::Realm& realm, Vector>&& files) +JS::NonnullGCPtr FileList::create(JS::Realm& realm, Vector>&& files) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(files))); + return realm.heap().allocate(realm, realm, move(files)); } FileList::FileList(JS::Realm& realm, Vector>&& files) diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.h b/Userland/Libraries/LibWeb/FileAPI/FileList.h index 98d90796b2..fe44e10d9b 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.h +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.h @@ -18,7 +18,7 @@ class FileList : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(FileList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Vector>&&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector>&&); virtual ~FileList() override; // https://w3c.github.io/FileAPI/#dfn-length diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp index 8c70f33f51..35c38f3bd7 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrix.cpp @@ -23,7 +23,7 @@ WebIDL::ExceptionOr> DOMMatrix::construct_impl(JS::R return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, TRY_OR_THROW_OOM(vm, String::formatted("Sequence must contain exactly 6 or 16 elements, got {} element(s)", double_sequence->size())) }; } - return realm.heap().allocate(realm, realm, init).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, init); } // https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-2d-dictionary @@ -42,12 +42,12 @@ WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matr // 2. Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, // the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } JS::NonnullGCPtr DOMMatrix::create_from_dom_matrix_read_only(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix) { - return realm.heap().allocate(realm, realm, read_only_matrix).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, read_only_matrix); } DOMMatrix::DOMMatrix(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp index a8bc877009..b96dc1edb9 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp @@ -24,7 +24,7 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::cons return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, TRY_OR_THROW_OOM(vm, String::formatted("Sequence must contain exactly 6 or 16 elements, got {} element(s)", double_sequence->size())) }; } - return realm.heap().allocate(realm, realm, init).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, init); } // https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-2d-dictionary @@ -43,7 +43,7 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::crea // 2. Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, // the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } DOMMatrixReadOnly::DOMMatrixReadOnly(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index a0de36ecef..36bc79b80d 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -13,7 +13,7 @@ namespace Web::Geometry { WebIDL::ExceptionOr> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, x, y, z, w)); + return realm.heap().allocate(realm, realm, x, y, z, w); } DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index 0ec52f7b3c..07758bfac4 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -13,7 +13,7 @@ namespace Web::Geometry { WebIDL::ExceptionOr> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, x, y, z, w)); + return realm.heap().allocate(realm, realm, x, y, z, w); } DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp index bc179cb431..f11b6f1786 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -12,19 +12,19 @@ namespace Web::Geometry { WebIDL::ExceptionOr> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, x, y, width, height)); + return create(realm, Gfx::FloatRect { x, y, width, height }); } -WebIDL::ExceptionOr> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) +JS::NonnullGCPtr DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) { - return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height()); + return realm.heap().allocate(realm, realm, rect.x(), rect.y(), rect.width(), rect.height()); } // https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary -WebIDL::ExceptionOr> DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) +JS::NonnullGCPtr DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) { auto& realm = *vm.current_realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height)); + return realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height); } DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double height) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.h b/Userland/Libraries/LibWeb/Geometry/DOMRect.h index c56708f57e..4c41c866c4 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.h @@ -16,8 +16,8 @@ class DOMRect final : public DOMRectReadOnly { public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0); - static WebIDL::ExceptionOr> create(JS::Realm&, Gfx::FloatRect const&); - static WebIDL::ExceptionOr> from_rect(JS::VM&, DOMRectInit const&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Gfx::FloatRect const&); + [[nodiscard]] static JS::NonnullGCPtr from_rect(JS::VM&, DOMRectInit const&); virtual ~DOMRect() override; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp index 28c8b997d5..408ef10036 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp @@ -12,12 +12,12 @@ namespace Web::Geometry { -WebIDL::ExceptionOr> DOMRectList::create(JS::Realm& realm, Vector> rect_handles) +JS::NonnullGCPtr DOMRectList::create(JS::Realm& realm, Vector> rect_handles) { Vector> rects; for (auto& rect : rect_handles) rects.append(*rect); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(rects))); + return realm.heap().allocate(realm, realm, move(rects)); } DOMRectList::DOMRectList(JS::Realm& realm, Vector> rects) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.h b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h index 77956b465e..7138518091 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectList.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h @@ -18,7 +18,7 @@ class DOMRectList final : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(DOMRectList, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, Vector>); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, Vector>); virtual ~DOMRectList() override; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp index f84844e561..2487f652ee 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp @@ -12,14 +12,14 @@ namespace Web::Geometry { WebIDL::ExceptionOr> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, x, y, width, height)); + return realm.heap().allocate(realm, realm, x, y, width, height); } // https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary -WebIDL::ExceptionOr> DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) +JS::NonnullGCPtr DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) { auto& realm = *vm.current_realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height)); + return realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height); } DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height) diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h index 7cc01f8548..1982ff6f06 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h @@ -26,7 +26,7 @@ class DOMRectReadOnly : public Bindings::PlatformObject { public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0); - static WebIDL::ExceptionOr> from_rect(JS::VM&, DOMRectInit const&); + [[nodiscard]] static JS::NonnullGCPtr from_rect(JS::VM&, DOMRectInit const&); virtual ~DOMRectReadOnly() override; diff --git a/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp b/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp index 63d7c534a0..6a972a89a9 100644 --- a/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp +++ b/Userland/Libraries/LibWeb/HTML/AudioTrack.cpp @@ -102,7 +102,7 @@ void AudioTrack::set_enabled(bool enabled) // is disabled, the user agent must queue a media element task given the media element to fire an event named // change at the AudioTrackList object. m_media_element->queue_a_media_element_task([this]() { - m_audio_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors()); + m_audio_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change)); }); } diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index ce091da702..3a83011df3 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -150,10 +150,10 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context auto realm_execution_context = Bindings::create_a_new_javascript_realm( Bindings::main_thread_vm(), [&](JS::Realm& realm) -> JS::Object* { - browsing_context->m_window_proxy = realm.heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + browsing_context->m_window_proxy = realm.heap().allocate(realm, realm); // - For the global object, create a new Window object. - window = HTML::Window::create(realm).release_value_but_fixme_should_propagate_errors(); + window = HTML::Window::create(realm); return window.ptr(); }, [&](JS::Realm&) -> JS::Object* { @@ -173,8 +173,7 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context move(realm_execution_context), {}, top_level_creation_url, - top_level_origin) - .release_value_but_fixme_should_propagate_errors(); + top_level_origin); // 12. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling // coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability. @@ -204,7 +203,7 @@ JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context // load timing info is loadTimingInfo, // FIXME: navigation id is null, // and which is ready for post-load tasks. - auto document = HTML::HTMLDocument::create(window->realm()).release_value_but_fixme_should_propagate_errors(); + auto document = HTML::HTMLDocument::create(window->realm()); // Non-standard document->set_window(*window); @@ -329,10 +328,10 @@ WebIDL::ExceptionOr BrowsingContext Bindings::main_thread_vm(), [&](JS::Realm& realm) -> JS::Object* { auto window_proxy = realm.heap().allocate(realm, realm); - browsing_context->set_window_proxy(window_proxy.release_allocated_value_but_fixme_should_propagate_errors()); + browsing_context->set_window_proxy(window_proxy); // - For the global object, create a new Window object. - window = Window::create(realm).release_value_but_fixme_should_propagate_errors(); + window = Window::create(realm); return window.ptr(); }, [&](JS::Realm&) -> JS::Object* { @@ -347,12 +346,12 @@ WebIDL::ExceptionOr BrowsingContext auto top_level_origin = !embedder ? origin : relevant_settings_object(*embedder).origin(); // 12. Set up a window environment settings object with about:blank, realm execution context, null, topLevelCreationURL, and topLevelOrigin. - TRY(WindowEnvironmentSettingsObject::setup( + WindowEnvironmentSettingsObject::setup( AK::URL("about:blank"), move(realm_execution_context), {}, top_level_creation_url, - top_level_origin)); + top_level_origin); // 13. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling // coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability. @@ -362,7 +361,7 @@ WebIDL::ExceptionOr BrowsingContext verify_cast(Bindings::host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes); // 14. Let document be a new Document, with: - auto document = TRY(HTML::HTMLDocument::create(window->realm())); + auto document = HTML::HTMLDocument::create(window->realm()); // Non-standard document->set_window(*window); @@ -1435,7 +1434,7 @@ WebIDL::ExceptionOr BrowsingContext::traverse_the_history(size_t entry_ind // and the newURL attribute initialized to newURL. // FIXME: Implement a proper HashChangeEvent class. - auto event = DOM::Event::create(verify_cast(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange).release_value_but_fixme_should_propagate_errors(); + auto event = DOM::Event::create(verify_cast(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange); new_document->dispatch_event(event); }); } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index 103b02e75b..a95e807981 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -22,21 +22,21 @@ WebIDL::ExceptionOr> CanvasGradient::create_rad return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"); auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *radial_gradient)); + return realm.heap().allocate(realm, realm, *radial_gradient); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient WebIDL::ExceptionOr> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1) { auto linear_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 })); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *linear_gradient)); + return realm.heap().allocate(realm, realm, *linear_gradient); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient WebIDL::ExceptionOr> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y) { auto conic_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *conic_gradient)); + return realm.heap().allocate(realm, realm, *conic_gradient); } CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradient) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp index 9c560ac104..39714b28c3 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp @@ -130,7 +130,7 @@ WebIDL::ExceptionOr> CanvasPattern::create(JS::Realm& r // FIXME: 7. If image is not origin-clean, then mark pattern as not origin-clean. // 8. Return pattern. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *pattern)); + return realm.heap().allocate(realm, realm, *pattern); } void CanvasPattern::initialize(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 07d9ba2183..92d441bc2d 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -26,9 +26,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element) +JS::NonnullGCPtr CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, element)); + return realm.heap().allocate(realm, realm, element); } CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasElement& element) @@ -394,7 +394,7 @@ JS::NonnullGCPtr CanvasRenderingContext2D::measure_text(DeprecatedS // TextMetrics object with members behaving as described in the following // list: auto prepared_text = prepare_text(text); - auto metrics = TextMetrics::create(realm()).release_value_but_fixme_should_propagate_errors(); + auto metrics = TextMetrics::create(realm()); // FIXME: Use the font that was used to create the glyphs in prepared_text. auto font = current_font(); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 933a99bbad..9a99f446e2 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -60,7 +60,7 @@ class CanvasRenderingContext2D WEB_PLATFORM_OBJECT(CanvasRenderingContext2D, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, HTMLCanvasElement&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, HTMLCanvasElement&); virtual ~CanvasRenderingContext2D() override; virtual void fill_rect(float x, float y, float width, float height) override; diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp index f941a86b0f..a839c14f54 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init) +JS::NonnullGCPtr CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> CloseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.h b/Userland/Libraries/LibWeb/HTML/CloseEvent.h index 9508786717..d73ee04561 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.h +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.h @@ -22,7 +22,7 @@ class CloseEvent : public DOM::Event { WEB_PLATFORM_OBJECT(CloseEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, CloseEventInit const& event_init); virtual ~CloseEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h index ddfd9e7a98..c12230f555 100644 --- a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h +++ b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h @@ -24,7 +24,7 @@ class CustomElementDefinition : public JS::Cell { static JS::NonnullGCPtr create(JS::Realm& realm, String const& name, String const& local_name, WebIDL::CallbackType& constructor, Vector&& observed_attributes, LifecycleCallbacksStorage&& lifecycle_callbacks, bool form_associated, bool disable_internals, bool disable_shadow) { - return realm.heap().allocate(realm, name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow); } ~CustomElementDefinition() = default; diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index 0605ac6318..9d44da20e7 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -16,7 +16,7 @@ namespace Web::HTML { WebIDL::ExceptionOr> DOMParser::construct_impl(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } DOMParser::DOMParser(JS::Realm& realm) @@ -42,7 +42,7 @@ JS::NonnullGCPtr DOMParser::parse_from_string(DeprecatedString co if (type == Bindings::DOMParserSupportedType::Text_Html) { // -> "text/html" // 1. Set document's type to "html". - document = HTML::HTMLDocument::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()).release_value_but_fixme_should_propagate_errors(); + document = HTML::HTMLDocument::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()); document->set_content_type(Bindings::idl_enum_to_deprecated_string(type)); document->set_document_type(DOM::Document::Type::HTML); @@ -56,7 +56,7 @@ JS::NonnullGCPtr DOMParser::parse_from_string(DeprecatedString co parser->run("about:blank"sv); } else { // -> Otherwise - document = DOM::Document::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()).release_value_but_fixme_should_propagate_errors(); + document = DOM::Document::create(realm(), verify_cast(relevant_global_object(*this)).associated_document().url()); document->set_content_type(Bindings::idl_enum_to_deprecated_string(type)); // 1. Create an XML parser parse, associated with document, and with XML scripting support disabled. diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index c52b909942..7b3fb7da52 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -12,10 +12,10 @@ namespace Web::HTML { -WebIDL::ExceptionOr> DOMStringMap::create(DOM::Element& element) +JS::NonnullGCPtr DOMStringMap::create(DOM::Element& element) { auto& realm = element.realm(); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, element)); + return realm.heap().allocate(realm, element); } DOMStringMap::DOMStringMap(DOM::Element& element) diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h index 77f89271f8..ecae5ade8e 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h @@ -17,7 +17,7 @@ class DOMStringMap final : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(DOM::Element&); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::Element&); virtual ~DOMStringMap() override; diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp index b716f86e1f..bc244491b7 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) +JS::NonnullGCPtr ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h index 1c61af2f17..cb4208ed60 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h @@ -25,7 +25,7 @@ class ErrorEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init); virtual ~ErrorEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/Focus.cpp b/Userland/Libraries/LibWeb/HTML/Focus.cpp index 7fef91a120..23f35e1940 100644 --- a/Userland/Libraries/LibWeb/HTML/Focus.cpp +++ b/Userland/Libraries/LibWeb/HTML/Focus.cpp @@ -65,7 +65,7 @@ static void run_focus_update_steps(Vector> old_chain, Vect // with related blur target as the related target. if (blur_event_target) { // FIXME: Implement the "fire a focus event" spec operation. - auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur).release_value_but_fixme_should_propagate_errors(); + auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur); blur_event->set_related_target(related_blur_target); blur_event_target->dispatch_event(blur_event); } @@ -108,7 +108,7 @@ static void run_focus_update_steps(Vector> old_chain, Vect // with related focus target as the related target. if (focus_event_target) { // FIXME: Implement the "fire a focus event" spec operation. - auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus).release_value_but_fixme_should_propagate_errors(); + auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus); focus_event->set_related_target(related_focus_target); focus_event_target->dispatch_event(focus_event); } diff --git a/Userland/Libraries/LibWeb/HTML/FormDataEvent.cpp b/Userland/Libraries/LibWeb/HTML/FormDataEvent.cpp index a2e243c61d..8504a4abe5 100644 --- a/Userland/Libraries/LibWeb/HTML/FormDataEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/FormDataEvent.cpp @@ -12,7 +12,7 @@ namespace Web::HTML { WebIDL::ExceptionOr> FormDataEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } FormDataEvent::FormDataEvent(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index c7bbf5e9a7..fb2e6e032e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -101,7 +101,7 @@ HTMLCanvasElement::HasOrCreatedContext HTMLCanvasElement::create_2d_context() if (!m_context.has()) return m_context.has>() ? 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 HTMLCanvasElement::to_blob(JS::NonnullGCPtr 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))); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index 38d4ecc487..126b49686e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -48,7 +48,7 @@ void HTMLDetailsElement::run_details_notification_task_steps() // 1. FIXME: If another task has been queued to run the details notification task steps for this details element, then return. // 2. Fire an event named toggle at the details element. - dispatch_event(Web::DOM::Event::create(realm(), HTML::EventNames::toggle).release_value_but_fixme_should_propagate_errors()); + dispatch_event(Web::DOM::Event::create(realm(), HTML::EventNames::toggle)); }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp index 4c862a7e83..76288d2779 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDocument.cpp @@ -20,9 +20,9 @@ WebIDL::ExceptionOr> HTMLDocument::construct_impl return HTMLDocument::create(realm); } -WebIDL::ExceptionOr> HTMLDocument::create(JS::Realm& realm, AK::URL const& url) +JS::NonnullGCPtr HTMLDocument::create(JS::Realm& realm, AK::URL const& url) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, url)); + return realm.heap().allocate(realm, realm, url); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDocument.h b/Userland/Libraries/LibWeb/HTML/HTMLDocument.h index 45bf05324e..32d65a3ab4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDocument.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDocument.h @@ -20,7 +20,7 @@ class HTMLDocument final : public DOM::Document { public: virtual ~HTMLDocument() override; - static WebIDL::ExceptionOr> create(JS::Realm&, AK::URL const& url = "about:blank"sv); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, AK::URL const& url = "about:blank"sv); WebIDL::ExceptionOr> construct_impl(JS::Realm&); private: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 6bceff7fe3..7ee54e3570 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -48,7 +48,7 @@ void HTMLElement::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLElement")); - m_dataset = MUST(DOMStringMap::create(*this)); + m_dataset = DOMStringMap::create(*this); } void HTMLElement::visit_edges(Cell::Visitor& visitor) @@ -283,7 +283,7 @@ bool HTMLElement::fire_a_synthetic_pointer_event(FlyString const& type, DOM::Ele // 1. Let event be the result of creating an event using PointerEvent. // 2. Initialize event's type attribute to e. // FIXME: Actually create a PointerEvent! - auto event = UIEvents::MouseEvent::create(realm(), type).release_value_but_fixme_should_propagate_errors(); + auto event = UIEvents::MouseEvent::create(realm(), type); // 3. Initialize event's bubbles and cancelable attributes to true. event->set_bubbles(true); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 9dbe008fb2..b72ca9446e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -101,7 +101,7 @@ WebIDL::ExceptionOr HTMLFormElement::submit_form(JS::NonnullGCPtrset_bubbles(true); submit_event->set_cancelable(true); bool should_continue = dispatch_event(*submit_event); @@ -258,7 +258,7 @@ WebIDL::ExceptionOr HTMLFormElement::submit_form(JS::NonnullGCPtrset_bubbles(true); reset_event->set_cancelable(true); @@ -411,7 +411,7 @@ JS::NonnullGCPtr HTMLFormElement::elements() const if (!m_elements) { m_elements = DOM::HTMLCollection::create(const_cast(*this), DOM::HTMLCollection::Scope::Descendants, [](Element const& element) { return is_form_control(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_elements; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 715df6d542..63a5023968 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -163,7 +163,7 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element) // FIXME: 4. Set childDocument's iframe load in progress flag. // 5. Fire an event named load at element. - element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load)); // FIXME: 6. Unset childDocument's iframe load in progress flag. } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index c1963dd89c..ab116b07e7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -391,7 +391,7 @@ ErrorOr HTMLImageElement::update_the_image_data(bool restart_animations, b // 3. If maybe omit events is not set or previousURL is not equal to urlString, then fire an event named load at the img element. if (!maybe_omit_events || previous_url != url_string) - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load)); }); // 8. Abort the update the image data algorithm. @@ -434,7 +434,7 @@ after_step_7: if ( (has_attribute(HTML::AttributeNames::src) || uses_srcset_or_picture()) && (!maybe_omit_events || m_current_request->current_url() != ""sv)) { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); } }); @@ -463,7 +463,7 @@ after_step_7: // 2. If maybe omit events is not set or previousURL is not equal to selected source, then fire an event named error at the img element. if (!maybe_omit_events || previous_url != selected_source.value().url) - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); }); // 5. Return. @@ -585,7 +585,7 @@ void HTMLImageElement::add_callbacks_to_image_request(NonnullRefPtr HTMLInputElement::files() return nullptr; if (!m_selected_files) - m_selected_files = FileAPI::FileList::create(realm(), {}).release_value_but_fixme_should_propagate_errors(); + m_selected_files = FileAPI::FileList::create(realm(), {}); return m_selected_files; } @@ -159,11 +159,11 @@ void HTMLInputElement::update_the_file_selection(JS::NonnullGCPtrset_files(files.ptr()); // 2. Fire an event named input at the input element, with the bubbles and composed attributes initialized to true. - auto input_event = DOM::Event::create(this->realm(), EventNames::input, { .bubbles = true, .composed = true }).release_value_but_fixme_should_propagate_errors(); + auto input_event = DOM::Event::create(this->realm(), EventNames::input, { .bubbles = true, .composed = true }); this->dispatch_event(input_event); // 3. Fire an event named change at the input element, with the bubbles attribute initialized to true. - auto change_event = DOM::Event::create(this->realm(), EventNames::change, { .bubbles = true }).release_value_but_fixme_should_propagate_errors(); + auto change_event = DOM::Event::create(this->realm(), EventNames::change, { .bubbles = true }); this->dispatch_event(change_event); }); } @@ -250,13 +250,13 @@ WebIDL::ExceptionOr HTMLInputElement::run_input_activation_behavior() return {}; // 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true. - auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors(); + auto input_event = DOM::Event::create(realm(), HTML::EventNames::input); input_event->set_bubbles(true); input_event->set_composed(true); dispatch_event(input_event); // 3. Fire an event named change at the element with the bubbles attribute initialized to true. - auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors(); + auto change_event = DOM::Event::create(realm(), HTML::EventNames::change); change_event->set_bubbles(true); dispatch_event(*change_event); } else if (type_state() == TypeAttributeState::SubmitButton) { @@ -274,7 +274,7 @@ WebIDL::ExceptionOr HTMLInputElement::run_input_activation_behavior() } else if (type_state() == TypeAttributeState::FileUpload) { show_the_picker_if_applicable(*this); } else { - dispatch_event(DOM::Event::create(realm(), EventNames::change).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), EventNames::change)); } return {}; @@ -291,7 +291,7 @@ void HTMLInputElement::did_edit_text_node(Badge) // NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors" // https://html.spec.whatwg.org/multipage/input.html#common-input-element-events queue_an_element_task(HTML::Task::Source::UserInteraction, [this] { - auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors(); + auto input_event = DOM::Event::create(realm(), HTML::EventNames::input); input_event->set_bubbles(true); input_event->set_composed(true); dispatch_event(*input_event); @@ -431,7 +431,7 @@ void HTMLInputElement::create_shadow_tree_if_needed() break; } - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed).release_allocated_value_but_fixme_should_propagate_errors(); + auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); auto initial_value = m_value; if (initial_value.is_null()) initial_value = DeprecatedString::empty(); @@ -445,10 +445,10 @@ void HTMLInputElement::create_shadow_tree_if_needed() padding: 1px 2px; )~~~")); - m_placeholder_element = heap().allocate(realm(), document()).release_allocated_value_but_fixme_should_propagate_errors(); + m_placeholder_element = heap().allocate(realm(), document()); MUST(m_placeholder_element->style_for_bindings()->set_property(CSS::PropertyID::Height, "1lh"sv)); - m_placeholder_text_node = heap().allocate(realm(), document(), initial_value).release_allocated_value_but_fixme_should_propagate_errors(); + m_placeholder_text_node = heap().allocate(realm(), document(), initial_value); m_placeholder_text_node->set_data(attribute(HTML::AttributeNames::placeholder)); m_placeholder_text_node->set_owner_input_element({}, *this); MUST(m_placeholder_element->append_child(*m_placeholder_text_node)); @@ -457,7 +457,7 @@ void HTMLInputElement::create_shadow_tree_if_needed() m_inner_text_element = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); MUST(m_inner_text_element->style_for_bindings()->set_property(CSS::PropertyID::Height, "1lh"sv)); - m_text_node = heap().allocate(realm(), document(), initial_value).release_allocated_value_but_fixme_should_propagate_errors(); + m_text_node = heap().allocate(realm(), document(), initial_value); m_text_node->set_always_editable(m_type != TypeAttributeState::FileUpload); m_text_node->set_owner_input_element({}, *this); @@ -485,7 +485,7 @@ void HTMLInputElement::did_lose_focus() // The change event fires when the value is committed, if that makes sense for the control, // or else when the control loses focus queue_an_element_task(HTML::Task::Source::UserInteraction, [this] { - auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors(); + auto change_event = DOM::Event::create(realm(), HTML::EventNames::change); change_event->set_bubbles(true); dispatch_event(change_event); }); @@ -842,7 +842,7 @@ void HTMLInputElement::reset_algorithm() m_checked = has_attribute(AttributeNames::checked); // empty the list of selected files, - m_selected_files = FileAPI::FileList::create(realm(), {}).release_value_but_fixme_should_propagate_errors(); + m_selected_files = FileAPI::FileList::create(realm(), {}); // and then invoke the value sanitization algorithm, if the type attribute's current state defines one. m_value = value_sanitization_algorithm(m_value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 1e4a6ee33e..e15182e072 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -133,7 +133,7 @@ void HTMLLinkElement::resource_did_fail() { dbgln_if(CSS_LOADER_DEBUG, "HTMLLinkElement: Resource did fail. URL: {}", resource()->url()); if (m_relationship & Relationship::Preload) { - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } } @@ -145,7 +145,7 @@ void HTMLLinkElement::resource_did_load() m_document_load_event_delayer.clear(); } if (m_relationship & Relationship::Preload) { - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load)); } } @@ -353,13 +353,13 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru if (!decoder.has_value()) { // If we don't support the encoding yet, let's error out instead of trying to decode it as something it's most likely not. dbgln("FIXME: Style sheet encoding '{}' is not supported yet", encoding); - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } else { auto const& encoded_string = body_bytes.get(); auto maybe_decoded_string = TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, encoded_string); if (maybe_decoded_string.is_error()) { dbgln("Style sheet {} claimed to be '{}' but decoding failed", response.url().value_or(AK::URL()), encoding); - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } else { auto const decoded_string = maybe_decoded_string.release_value(); m_loaded_style_sheet = parse_css_stylesheet(CSS::Parser::ParsingContext(document(), *response.url()), decoded_string); @@ -373,13 +373,13 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru } // 2. Fire an event named load at el. - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load)); } } } // 5. Otherwise, fire an event named error at el. else { - dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error)); } // FIXME: 6. If el contributes a script-blocking style sheet, then: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index dd381177e4..544ce46fce 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -52,9 +52,9 @@ void HTMLMediaElement::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLMediaElement")); - m_audio_tracks = MUST(realm.heap().allocate(realm, realm)); - m_video_tracks = MUST(realm.heap().allocate(realm, realm)); - m_document_observer = MUST(realm.heap().allocate(realm, realm, document())); + m_audio_tracks = realm.heap().allocate(realm, realm); + m_video_tracks = realm.heap().allocate(realm, realm); + m_document_observer = realm.heap().allocate(realm, realm, document()); // https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-82 m_document_observer->document_became_inactive = [this]() { @@ -136,7 +136,7 @@ WebIDL::ExceptionOr HTMLMediaElement::set_decoder_error(String error_messa m_fetch_controller->stop_fetch(); // 2. Set the error attribute to the result of creating a MediaError with MEDIA_ERR_DECODE. - m_error = TRY(vm.heap().allocate(realm, realm, MediaError::Code::Decode, move(error_message))); + m_error = vm.heap().allocate(realm, realm, MediaError::Code::Decode, move(error_message)); // 3. Set the element's networkState attribute to the NETWORK_IDLE value. m_network_state = NetworkState::Idle; @@ -145,7 +145,7 @@ WebIDL::ExceptionOr HTMLMediaElement::set_decoder_error(String error_messa m_delaying_the_load_event.clear(); // 5. Fire an event named error at the media element. - dispatch_event(TRY(DOM::Event::create(realm, HTML::EventNames::error))); + dispatch_event(DOM::Event::create(realm, HTML::EventNames::error)); // FIXME: 6. Abort the overall resource selection algorithm. @@ -153,7 +153,7 @@ WebIDL::ExceptionOr HTMLMediaElement::set_decoder_error(String error_messa } // https://html.spec.whatwg.org/multipage/media.html#dom-media-buffered -WebIDL::ExceptionOr> HTMLMediaElement::buffered() const +JS::NonnullGCPtr HTMLMediaElement::buffered() const { auto& realm = this->realm(); auto& vm = realm.vm(); @@ -162,7 +162,7 @@ WebIDL::ExceptionOr> HTMLMediaElement::buffered() c // media resource, if any, that the user agent has buffered, at the time the attribute is evaluated. Users agents // must accurately determine the ranges available, even for media streams where this can only be determined by // tedious inspection. - return TRY(vm.heap().allocate(realm, realm)); + return vm.heap().allocate(realm, realm); } // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype @@ -286,7 +286,7 @@ void HTMLMediaElement::set_current_playback_position(double playback_position) // NOTE: Invoking the following steps is not listed in the spec. Rather, the spec just describes the scenario in // which these steps should be invoked, which is when we've reached the end of the media playback. if (m_current_playback_position == m_duration) - reached_end_of_media_playback().release_value_but_fixme_should_propagate_errors(); + reached_end_of_media_playback(); } // https://html.spec.whatwg.org/multipage/media.html#dom-media-duration @@ -319,7 +319,7 @@ void HTMLMediaElement::set_duration(double duration) // ends up being greater than the time of the end of the media resource, then the user agent must also seek to the time of the end of the media resource. if (!isnan(duration)) { queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::durationchange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::durationchange)); }); if (m_current_playback_position > duration) @@ -422,7 +422,7 @@ void HTMLMediaElement::volume_or_muted_attribute_changed() // agent must queue a media element task given the media element to fire an event named volumechange at the media // element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::volumechange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::volumechange)); }); // FIXME: Then, if the media element is not allowed to play, the user agent must run the internal pause steps for the media element. @@ -477,7 +477,7 @@ WebIDL::ExceptionOr HTMLMediaElement::load_element() // fire an event named abort at the media element. if (m_network_state == NetworkState::Loading || m_network_state == NetworkState::Idle) { queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::abort).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::abort)); }); } @@ -485,7 +485,7 @@ WebIDL::ExceptionOr HTMLMediaElement::load_element() if (m_network_state != NetworkState::Empty) { // 1. Queue a media element task given the media element to fire an event named emptied at the media element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::emptied).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::emptied)); }); // 2. If a fetching process is in progress for the media element, the user agent should stop it. @@ -525,7 +525,7 @@ WebIDL::ExceptionOr HTMLMediaElement::load_element() // If this changed the official playback position, then queue a media element task given the media element to fire an // event named timeupdate at the media element. queue_a_media_element_task([this] { - dispatch_time_update_event().release_value_but_fixme_should_propagate_errors(); + dispatch_time_update_event(); }); } @@ -632,7 +632,7 @@ private: { // 9. Failed with elements: Queue a media element task given the media element to fire an event named error at candidate. m_media_element->queue_a_media_element_task([this]() { - m_candidate->dispatch_event(DOM::Event::create(m_candidate->realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + m_candidate->dispatch_event(DOM::Event::create(m_candidate->realm(), HTML::EventNames::error)); }); // FIXME: 10. Await a stable state. The synchronous section consists of all the remaining steps of this algorithm until @@ -788,7 +788,7 @@ WebIDL::ExceptionOr HTMLMediaElement::select_resource() // 8. ⌛ Queue a media element task given the media element to fire an event named loadstart at the media element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadstart).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadstart)); }); // 9. Run the appropriate steps from the following list: @@ -878,7 +878,7 @@ WebIDL::ExceptionOr HTMLMediaElement::select_resource() // NOTE: We do not bother with maintaining this pointer. We inspect the DOM tree on the fly, rather than dealing // with the headache of auto-updating this pointer as the DOM changes. - m_source_element_selector = TRY(vm.heap().allocate(realm, *this, *candidate)); + m_source_element_selector = vm.heap().allocate(realm, *this, *candidate); TRY(m_source_element_selector->process_candidate()); break; @@ -1081,7 +1081,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function If the media resource is found to have an audio track if (!audio_loader.is_error()) { // 1. Create an AudioTrack object to represent the audio track. - audio_track = TRY(vm.heap().allocate(realm, realm, *this, audio_loader.release_value())); + audio_track = vm.heap().allocate(realm, realm, *this, audio_loader.release_value()); // 2. Update the media element's audioTracks attribute's AudioTrackList object with the new AudioTrack object. TRY_OR_THROW_OOM(vm, m_audio_tracks->add_track({}, *audio_track)); @@ -1106,14 +1106,14 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Functiondispatch_event(event); } // -> If the media resource is found to have a video track if (!playback_manager.is_error()) { // 1. Create a VideoTrack object to represent the video track. - video_track = TRY(vm.heap().allocate(realm, realm, *this, playback_manager.release_value())); + video_track = vm.heap().allocate(realm, realm, *this, playback_manager.release_value()); // 2. Update the media element's videoTracks attribute's VideoTrackList object with the new VideoTrack object. TRY_OR_THROW_OOM(vm, m_video_tracks->add_track({}, *video_track)); @@ -1139,7 +1139,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Functiondispatch_event(event); } @@ -1170,7 +1170,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Functionpixel_height()); queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::resize)); }); } else { auto duration = audio_track ? audio_track->duration() : video_track->duration(); @@ -1208,11 +1208,11 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function Once the entire media resource has been fetched (but potentially before any of it has been decoded) if (audio_track != nullptr || video_track != nullptr) { // Fire an event named progress at the media element. - dispatch_event(TRY(DOM::Event::create(this->realm(), HTML::EventNames::progress))); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::progress)); // Set the networkState to NETWORK_IDLE and fire an event named suspend at the media element. m_network_state = NetworkState::Idle; - dispatch_event(TRY(DOM::Event::create(this->realm(), HTML::EventNames::suspend))); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::suspend)); // If the user agent ever discards any media data and then needs to resume the network activity to obtain it again, then it must queue a media // element task given the media element to set the networkState to NETWORK_LOADING. @@ -1234,7 +1234,7 @@ WebIDL::ExceptionOr HTMLMediaElement::handle_media_source_failure(Span(realm, realm, MediaError::Code::SrcNotSupported, move(error_message))); + m_error = vm.heap().allocate(realm, realm, MediaError::Code::SrcNotSupported, move(error_message)); // 2. Forget the media element's media-resource-specific tracks. forget_media_resource_specific_tracks(); @@ -1246,7 +1246,7 @@ WebIDL::ExceptionOr HTMLMediaElement::handle_media_source_failure(Span(promises, "Media is not supported"_fly_string); @@ -1286,7 +1286,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) if (m_ready_state == ReadyState::HaveNothing && ready_state == ReadyState::HaveMetadata) { // Queue a media element task given the media element to fire an event named loadedmetadata at the element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadedmetadata).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadedmetadata)); }); return; @@ -1300,7 +1300,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) m_first_data_load_event_since_load_start = false; queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadeddata).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::loadeddata)); }); } @@ -1327,7 +1327,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) if (m_ready_state <= ReadyState::HaveCurrentData && ready_state == ReadyState::HaveFutureData) { // The user agent must queue a media element task given the media element to fire an event named canplay at the element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay)); }); // If the element's paused attribute is false, the user agent must notify about playing for the element. @@ -1343,7 +1343,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) // named canplay at the element, and, if the element's paused attribute is false, notify about playing for the element. if (m_ready_state <= ReadyState::HaveCurrentData) { queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplay)); }); if (!paused()) @@ -1352,7 +1352,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) // The user agent must queue a media element task given the media element to fire an event named canplaythrough at the element. queue_a_media_element_task([this] { - dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplaythrough).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(this->realm(), HTML::EventNames::canplaythrough)); }); // If the element is not eligible for autoplay, then the user agent must abort these substeps. @@ -1372,7 +1372,7 @@ void HTMLMediaElement::set_ready_state(ReadyState ready_state) // Queue a media element task given the element to fire an event named play at the element. queue_a_media_element_task([this]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play)); }); // Notify about playing for the element. @@ -1416,14 +1416,14 @@ WebIDL::ExceptionOr HTMLMediaElement::play_element() // 3. Queue a media element task given the media element to fire an event named play at the element. queue_a_media_element_task([this]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::play)); }); // 4. If the media element's readyState attribute has the value HAVE_NOTHING, HAVE_METADATA, or HAVE_CURRENT_DATA, // queue a media element task given the media element to fire an event named waiting at the element. if (m_ready_state == ReadyState::HaveNothing || m_ready_state == ReadyState::HaveMetadata || m_ready_state == ReadyState::HaveCurrentData) { queue_a_media_element_task([this]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::waiting).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::waiting)); }); } // Otherwise, the media element's readyState attribute has the value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA: @@ -1469,10 +1469,10 @@ WebIDL::ExceptionOr HTMLMediaElement::pause_element() auto& realm = this->realm(); // 1. Fire an event named timeupdate at the element. - dispatch_time_update_event().release_value_but_fixme_should_propagate_errors(); + dispatch_time_update_event(); // 2. Fire an event named pause at the element. - dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm, HTML::EventNames::pause)); // 3. Reject pending play promises with promises and an "AbortError" DOMException. reject_pending_play_promises(promises, "Media playback was paused"_fly_string); @@ -1529,7 +1529,7 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek // 10. Queue a media element task given the media element to fire an event named seeking at the element. queue_a_media_element_task([this]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeking).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeking)); }); // 11. Set the current playback position to the new playback position. @@ -1552,12 +1552,12 @@ void HTMLMediaElement::seek_element(double playback_position, MediaSeekMode seek // 16. ⌛ Queue a media element task given the media element to fire an event named timeupdate at the element. queue_a_media_element_task([this]() { - dispatch_time_update_event().release_value_but_fixme_should_propagate_errors(); + dispatch_time_update_event(); }); // 17. ⌛ Queue a media element task given the media element to fire an event named seeked at the element. queue_a_media_element_task([this]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeked).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::seeked)); }); } @@ -1570,7 +1570,7 @@ void HTMLMediaElement::notify_about_playing() // 2. Queue a media element task given the element and the following steps: queue_a_media_element_task([this, promises = move(promises)]() { // 1. Fire an event named playing at the element. - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::playing).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::playing)); // 2. Resolve pending play promises with promises. resolve_pending_play_promises(promises); @@ -1690,7 +1690,7 @@ bool HTMLMediaElement::has_ended_playback() const } // https://html.spec.whatwg.org/multipage/media.html#reaches-the-end -WebIDL::ExceptionOr HTMLMediaElement::reached_end_of_media_playback() +void HTMLMediaElement::reached_end_of_media_playback() { // 1. If the media element has a loop attribute specified, then seek to the earliest possible position of the media resource and return. if (has_attribute(HTML::AttributeNames::loop)) { @@ -1700,8 +1700,6 @@ WebIDL::ExceptionOr HTMLMediaElement::reached_end_of_media_playback() // playing manually to actually loop. Note that we don't need to update any HTMLMediaElement state as // it hasn't left the playing state by this point. on_playing(); - - return {}; } // 2. As defined above, the ended IDL attribute starts returning true once the event loop returns to step 1. @@ -1709,7 +1707,7 @@ WebIDL::ExceptionOr HTMLMediaElement::reached_end_of_media_playback() // 3. Queue a media element task given the media element and the following steps: queue_a_media_element_task([this]() mutable { // 1. Fire an event named timeupdate at the media element. - dispatch_time_update_event().release_value_but_fixme_should_propagate_errors(); + dispatch_time_update_event(); // 2. If the media element has ended playback, the direction of playback is forwards, and paused is false, then: // FIXME: Detect playback direction. @@ -1718,7 +1716,7 @@ WebIDL::ExceptionOr HTMLMediaElement::reached_end_of_media_playback() set_paused(true); // 2. Fire an event named pause at the media element. - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::pause).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::pause)); // 3. Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException. auto promises = take_pending_play_promises(); @@ -1727,20 +1725,17 @@ WebIDL::ExceptionOr HTMLMediaElement::reached_end_of_media_playback() }); // 4. Fire an event named ended at the media element. - dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::ended))); - - return {}; + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::ended)); } -WebIDL::ExceptionOr HTMLMediaElement::dispatch_time_update_event() +void HTMLMediaElement::dispatch_time_update_event() { ScopeGuard guard { [this] { m_running_time_update_event_handler = false; } }; m_running_time_update_event_handler = true; m_last_time_update_event_time = MonotonicTime::now(); - dispatch_event(TRY(DOM::Event::create(realm(), HTML::EventNames::timeupdate))); - return {}; + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::timeupdate)); } // https://html.spec.whatwg.org/multipage/media.html#time-marches-on @@ -1775,7 +1770,7 @@ void HTMLMediaElement::time_marches_on(TimeMarchesOnReason reason) if (dispatch_event) { queue_a_media_element_task([this]() { - dispatch_time_update_event().release_value_but_fixme_should_propagate_errors(); + dispatch_time_update_event(); }); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 854238a638..21246c2e84 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -56,7 +56,7 @@ public: }; NetworkState network_state() const { return m_network_state; } - WebIDL::ExceptionOr> buffered() const; + [[nodiscard]] JS::NonnullGCPtr buffered() const; WebIDL::ExceptionOr can_play_type(DeprecatedString const& type) const; @@ -177,9 +177,9 @@ private: bool is_eligible_for_autoplay() const; bool has_ended_playback() const; - WebIDL::ExceptionOr reached_end_of_media_playback(); + void reached_end_of_media_playback(); - WebIDL::ExceptionOr dispatch_time_update_event(); + void dispatch_time_update_event(); enum class TimeMarchesOnReason { NormalPlayback, diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 7e7186a1e2..c7eecea8a5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -125,7 +125,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps() // 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback. if (!url.is_valid()) { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); return run_object_representation_fallback_steps(); } @@ -152,7 +152,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps() void HTMLObjectElement::resource_did_fail() { // 4.7. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error at the element, then jump to the step below labeled fallback. - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); run_object_representation_fallback_steps(); } @@ -290,7 +290,7 @@ void HTMLObjectElement::run_object_representation_completed_steps(Representation // 4.11. If the object element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object element to fire an event named load at the element. if (representation != Representation::NestedBrowsingContext) { queue_an_element_task(HTML::Task::Source::DOMManipulation, [&]() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load)); }); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index 4d0f4ea8cf..382d07d46d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -13,9 +13,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> HTMLOptionsCollection::create(DOM::ParentNode& root, Function filter) +JS::NonnullGCPtr HTMLOptionsCollection::create(DOM::ParentNode& root, Function filter) { - return MUST_OR_THROW_OOM(root.heap().allocate(root.realm(), root, move(filter))); + return root.heap().allocate(root.realm(), root, move(filter)); } HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function filter) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h index c631c121b4..f990acb2b0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h @@ -19,7 +19,7 @@ class HTMLOptionsCollection final : public DOM::HTMLCollection { WEB_PLATFORM_OBJECT(HTMLOptionsCollection, DOM::HTMLCollection); public: - static WebIDL::ExceptionOr> create(DOM::ParentNode& root, Function filter); + [[nodiscard]] static JS::NonnullGCPtr create(DOM::ParentNode& root, Function filter); virtual ~HTMLOptionsCollection() override; WebIDL::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 0600bc959d..3dc7328624 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -86,7 +86,7 @@ void HTMLScriptElement::execute_script() // 3. If el's result is null, then fire an event named error at el, and return. if (m_result.has()) { dbgln("HTMLScriptElement: Refusing to run script because the element's result is null."); - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); return; } @@ -137,7 +137,7 @@ void HTMLScriptElement::execute_script() // 8. If el's from an external file is true, then fire an event named load at el. if (m_from_an_external_file) - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load)); } // https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script @@ -340,7 +340,7 @@ void HTMLScriptElement::prepare_script() if (m_script_type == ScriptType::ImportMap) { // then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return. queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); }); return; } @@ -352,7 +352,7 @@ void HTMLScriptElement::prepare_script() if (src.is_empty()) { dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty."); queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); }); return; } @@ -367,7 +367,7 @@ void HTMLScriptElement::prepare_script() if (!url.is_valid()) { dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url); queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); }); return; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index b5576979bf..022c7d78d9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -42,7 +42,7 @@ JS::GCPtr const& HTMLSelectElement::options() // the select element, and all the option element children of all the optgroup element children // of the select element, in tree order. return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return m_options; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 55c8fa3aa4..0de18caa38 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -272,7 +272,7 @@ JS::NonnullGCPtr HTMLTableElement::t_bodies() if (!m_t_bodies) { m_t_bodies = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Children, [](DOM::Element const& element) { return element.local_name() == TagNames::tbody; - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_t_bodies; } @@ -329,7 +329,7 @@ JS::NonnullGCPtr HTMLTableElement::rows() } return false; - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_rows; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index cb4d133eb1..62eb74a53f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -65,7 +65,7 @@ JS::NonnullGCPtr HTMLTableRowElement::cells() const if (!m_cells) { m_cells = DOM::HTMLCollection::create(const_cast(*this), DOM::HTMLCollection::Scope::Children, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_cells; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index 5c02ff4530..d5ad0f23a0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -41,7 +41,7 @@ JS::NonnullGCPtr HTMLTableSectionElement::rows() const if (!m_rows) { m_rows = DOM::HTMLCollection::create(const_cast(*this), DOM::HTMLCollection::Scope::Children, [](Element const& element) { return is(element); - }).release_value_but_fixme_should_propagate_errors(); + }); } return *m_rows; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 7849bf74b8..9712909d70 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -22,7 +22,7 @@ void HTMLTemplateElement::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "HTMLTemplateElement")); - m_content = MUST(heap().allocate(realm, m_document->appropriate_template_contents_owner_document())); + m_content = heap().allocate(realm, m_document->appropriate_template_contents_owner_document()); m_content->set_host(this); } diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 48471d7728..e505cb39a8 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -10,9 +10,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> History::create(JS::Realm& realm, DOM::Document& document) +JS::NonnullGCPtr History::create(JS::Realm& realm, DOM::Document& document) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, document)); + return realm.heap().allocate(realm, realm, document); } History::History(JS::Realm& realm, DOM::Document& document) diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index 60dca160b0..c11aa2b5e7 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -16,7 +16,7 @@ class History final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, DOM::Document&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, DOM::Document&); virtual ~History() override; diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index 723c25e454..04ab5b549e 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -28,7 +28,7 @@ JS::GCPtr ImageData::create_with_size(JS::Realm& realm, int width, in auto bitmap_or_error = Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data()); if (bitmap_or_error.is_error()) return nullptr; - return realm.heap().allocate(realm, realm, bitmap_or_error.release_value(), move(data)).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, bitmap_or_error.release_value(), move(data)); } ImageData::ImageData(JS::Realm& realm, NonnullRefPtr bitmap, JS::NonnullGCPtr data) diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp index 56bdbd77db..97529c4dae 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp @@ -13,17 +13,17 @@ namespace Web::HTML { WebIDL::ExceptionOr> MessageChannel::construct_impl(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } MessageChannel::MessageChannel(JS::Realm& realm) : PlatformObject(realm) { // 1. Set this's port 1 to a new MessagePort in this's relevant Realm. - m_port1 = MessagePort::create(realm).release_value_but_fixme_should_propagate_errors(); + m_port1 = MessagePort::create(realm); // 2. Set this's port 2 to a new MessagePort in this's relevant Realm. - m_port2 = MessagePort::create(realm).release_value_but_fixme_should_propagate_errors(); + m_port2 = MessagePort::create(realm); // 3. Entangle this's port 1 and this's port 2. m_port1->entangle_with(*m_port2); diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 22b7bae3fe..777eea5afc 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) +JS::NonnullGCPtr MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> MessageEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h index 83c73147e4..32fbb9fc95 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h @@ -22,8 +22,8 @@ class MessageEvent : public DOM::Event { WEB_PLATFORM_OBJECT(MessageEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, MessageEventInit const& = {}); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, MessageEventInit const&); MessageEvent(JS::Realm&, FlyString const& event_name, MessageEventInit const& event_init); virtual ~MessageEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 37f2598ac2..5d65193e7b 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -14,9 +14,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> MessagePort::create(JS::Realm& realm) +JS::NonnullGCPtr MessagePort::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } MessagePort::MessagePort(JS::Realm& realm) @@ -97,7 +97,7 @@ void MessagePort::post_message(JS::Value message) MessageEventInit event_init {}; event_init.data = message; event_init.origin = ""_string; - target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init)); })); } diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.h b/Userland/Libraries/LibWeb/HTML/MessagePort.h index 82131a7297..7d5784d340 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.h +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.h @@ -27,7 +27,7 @@ class MessagePort final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(MessagePort, DOM::EventTarget); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~MessagePort() override; diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp index ff2efaa145..f24b3dfb32 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp @@ -15,9 +15,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> Navigator::create(JS::Realm& realm) +JS::NonnullGCPtr Navigator::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } Navigator::Navigator(JS::Realm& realm) @@ -59,17 +59,17 @@ void Navigator::visit_edges(Cell::Visitor& visitor) visitor.visit(m_plugin_array); } -JS::ThrowCompletionOr> Navigator::mime_types() +JS::NonnullGCPtr Navigator::mime_types() { if (!m_mime_type_array) - m_mime_type_array = TRY(heap().allocate(realm(), realm())); + m_mime_type_array = heap().allocate(realm(), realm()); return *m_mime_type_array; } -JS::ThrowCompletionOr> Navigator::plugins() +JS::NonnullGCPtr Navigator::plugins() { if (!m_plugin_array) - m_plugin_array = TRY(heap().allocate(realm(), realm())); + m_plugin_array = heap().allocate(realm(), realm()); return *m_plugin_array; } diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.h b/Userland/Libraries/LibWeb/HTML/Navigator.h index 4741e89505..640fb6b965 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.h +++ b/Userland/Libraries/LibWeb/HTML/Navigator.h @@ -24,7 +24,7 @@ class Navigator : public Bindings::PlatformObject WEB_PLATFORM_OBJECT(Navigator, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); // FIXME: Implement NavigatorContentUtilsMixin @@ -41,8 +41,8 @@ public: bool webdriver() const; - JS::ThrowCompletionOr> mime_types(); - JS::ThrowCompletionOr> plugins(); + [[nodiscard]] JS::NonnullGCPtr mime_types(); + [[nodiscard]] JS::NonnullGCPtr plugins(); virtual ~Navigator() override; diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp index b9e3353c64..c035476171 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> PageTransitionEvent::create(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init) +JS::NonnullGCPtr PageTransitionEvent::create(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> PageTransitionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h index 1227edc2ca..a8f5634c73 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h @@ -19,8 +19,8 @@ class PageTransitionEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(PageTransitionEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const&); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const&); PageTransitionEvent(JS::Realm&, FlyString const& event_name, PageTransitionEventInit const& event_init); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp index 1fedcc8dd7..74a688b68c 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp @@ -109,7 +109,7 @@ JS::GCPtr prescan_get_attribute(DOM::Document& document, ByteBuffer c } else if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ') goto spaces; else if (input[position] == '/' || input[position] == '>') - return *DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors(); + return *DOM::Attr::create(document, attribute_name.to_deprecated_string(), ""); else attribute_name.append_as_lowercase(input[position]); ++position; @@ -121,7 +121,7 @@ spaces: if (!prescan_skip_whitespace_and_slashes(input, position)) return {}; if (input[position] != '=') - return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors(); + return DOM::Attr::create(document, attribute_name.to_deprecated_string(), ""); ++position; value: @@ -134,13 +134,13 @@ value: ++position; for (; !prescan_should_abort(input, position); ++position) { if (input[position] == quote_character) - return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()).release_value_but_fixme_should_propagate_errors(); + return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()); else attribute_value.append_as_lowercase(input[position]); } return {}; } else if (input[position] == '>') - return DOM::Attr::create(document, attribute_name.to_deprecated_string(), "").release_value_but_fixme_should_propagate_errors(); + return DOM::Attr::create(document, attribute_name.to_deprecated_string(), ""); else attribute_value.append_as_lowercase(input[position]); @@ -150,7 +150,7 @@ value: for (; !prescan_should_abort(input, position); ++position) { if (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ' || input[position] == '>') - return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()).release_value_but_fixme_should_propagate_errors(); + return DOM::Attr::create(document, attribute_name.to_deprecated_string(), attribute_value.to_deprecated_string()); else attribute_value.append_as_lowercase(input[position]); } diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 6578a7c9e4..96747702a3 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -281,7 +281,7 @@ void HTMLParser::the_end() document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time(); // 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true. - auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded).release_value_but_fixme_should_propagate_errors(); + auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded); content_loaded_event->set_bubbles(true); document->dispatch_event(content_loaded_event); @@ -322,7 +322,7 @@ void HTMLParser::the_end() // 5. Fire an event named load at window, with legacy target override flag set. // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event() // We should reorganize this so that the flag appears explicitly here instead. - window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load)); // FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL. @@ -490,13 +490,13 @@ void HTMLParser::handle_initial(HTMLToken& token) } if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); + auto comment = realm().heap().allocate(realm(), document(), token.comment()); MUST(document().append_child(*comment)); return; } if (token.is_doctype()) { - auto doctype = realm().heap().allocate(realm(), document()).release_allocated_value_but_fixme_should_propagate_errors(); + auto doctype = realm().heap().allocate(realm(), document()); doctype->set_name(token.doctype_data().name); doctype->set_public_id(token.doctype_data().public_identifier); doctype->set_system_id(token.doctype_data().system_identifier); @@ -525,7 +525,7 @@ void HTMLParser::handle_before_html(HTMLToken& token) // -> A comment token if (token.is_comment()) { // Insert a comment as the last child of the Document object. - auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); + auto comment = realm().heap().allocate(realm(), document(), token.comment()); MUST(document().append_child(*comment)); return; } @@ -822,7 +822,7 @@ AnythingElse: void HTMLParser::insert_comment(HTMLToken& token) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); - adjusted_insertion_location.parent->insert_before(realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(), adjusted_insertion_location.insert_before_sibling); + adjusted_insertion_location.parent->insert_before(realm().heap().allocate(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling); } void HTMLParser::handle_in_head(HTMLToken& token) @@ -1004,7 +1004,7 @@ DOM::Text* HTMLParser::find_character_insertion_node() if (adjusted_insertion_location.insert_before_sibling) { if (adjusted_insertion_location.insert_before_sibling->previous_sibling() && adjusted_insertion_location.insert_before_sibling->previous_sibling()->is_text()) return static_cast(adjusted_insertion_location.insert_before_sibling->previous_sibling()); - auto new_text_node = realm().heap().allocate(realm(), document(), "").release_allocated_value_but_fixme_should_propagate_errors(); + auto new_text_node = realm().heap().allocate(realm(), document(), ""); adjusted_insertion_location.parent->insert_before(*new_text_node, *adjusted_insertion_location.insert_before_sibling); return new_text_node; } @@ -1012,7 +1012,7 @@ DOM::Text* HTMLParser::find_character_insertion_node() return nullptr; if (adjusted_insertion_location.parent->last_child() && adjusted_insertion_location.parent->last_child()->is_text()) return verify_cast(adjusted_insertion_location.parent->last_child()); - auto new_text_node = realm().heap().allocate(realm(), document(), "").release_allocated_value_but_fixme_should_propagate_errors(); + auto new_text_node = realm().heap().allocate(realm(), document(), ""); MUST(adjusted_insertion_location.parent->append_child(*new_text_node)); return new_text_node; } @@ -1137,7 +1137,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) if (token.is_comment()) { auto& insertion_location = m_stack_of_open_elements.first(); - MUST(insertion_location.append_child(realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors())); + MUST(insertion_location.append_child(realm().heap().allocate(realm(), document(), token.comment()))); return; } @@ -1173,7 +1173,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) void HTMLParser::handle_after_after_body(HTMLToken& token) { if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); + auto comment = realm().heap().allocate(realm(), document(), token.comment()); MUST(document().append_child(*comment)); return; } @@ -3402,7 +3402,7 @@ void HTMLParser::handle_after_frameset(HTMLToken& token) void HTMLParser::handle_after_after_frameset(HTMLToken& token) { if (token.is_comment()) { - auto comment = document().heap().allocate(document().realm(), document(), token.comment()).release_allocated_value_but_fixme_should_propagate_errors(); + auto comment = document().heap().allocate(document().realm(), document(), token.comment()); MUST(document().append_child(comment)); return; } @@ -3669,7 +3669,7 @@ DOM::Document& HTMLParser::document() Vector> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup) { // 1. Create a new Document node, and mark it as being an HTML document. - auto temp_document = DOM::Document::create(context_element.realm()).release_value_but_fixme_should_propagate_errors(); + auto temp_document = DOM::Document::create(context_element.realm()); temp_document->set_document_type(DOM::Document::Type::HTML); temp_document->set_is_temporary_document_for_fragment_parsing({}); diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.cpp b/Userland/Libraries/LibWeb/HTML/Path2D.cpp index 636d2d1ebd..9a565af378 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/Path2D.cpp @@ -16,7 +16,7 @@ namespace Web::HTML { WebIDL::ExceptionOr> Path2D::construct_impl(JS::Realm& realm, Optional, DeprecatedString>> const& path) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, path)); + return realm.heap().allocate(realm, realm, path); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index 23322f324f..bbe4f7bcd1 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) +JS::NonnullGCPtr PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h index 5e0ac122a3..2edcae286d 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h @@ -24,8 +24,8 @@ class PromiseRejectionEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(PromiseRejectionEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const& = {}); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, PromiseRejectionEventInit const&); virtual ~PromiseRejectionEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp index 9366741fd2..2bf6505054 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -259,7 +259,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge) // FIXME: This currently assumes that global is a WindowObject. auto& window = verify_cast(global); - auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init).release_value_but_fixme_should_propagate_errors(); + auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init); bool not_handled = window.dispatch_event(*promise_rejection_event); diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp index f5ea81c601..0d63536f20 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp @@ -37,7 +37,7 @@ WebIDL::ExceptionOr> JavaScriptModuleScript::c auto& realm = settings_object.realm(); // 2. Let script be a new module script that this algorithm will subsequently initialize. - auto script = MUST_OR_THROW_OOM(realm.heap().allocate(realm, move(base_url), filename, settings_object)); + auto script = realm.heap().allocate(realm, move(base_url), filename, settings_object); // 3. Set script's settings object to settings. // NOTE: This was already done when constructing. diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index 105f766d20..0fe78ec19e 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -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 WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr execution_context, Optional reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin) +void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr execution_context, Optional 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 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(*realm, window, move(execution_context))); + auto settings_object = realm->heap().allocate(*realm, window, move(execution_context)); // 4. If reservedEnvironment is non-null, then: if (reserved_environment.has_value()) { @@ -71,15 +71,13 @@ WebIDL::ExceptionOr 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(*realm, *realm)); + auto intrinsics = realm->heap().allocate(*realm, *realm); auto host_defined = make(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 diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h index 89399ee5ec..da0ae20905 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h @@ -15,7 +15,7 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject { JS_CELL(WindowEnvironmentSettingsObject, EnvironmentSettingsObject); public: - static WebIDL::ExceptionOr setup(AK::URL const& creation_url, NonnullOwnPtr, Optional, AK::URL top_level_creation_url, Origin top_level_origin); + static void setup(AK::URL const& creation_url, NonnullOwnPtr, Optional, AK::URL top_level_creation_url, Origin top_level_origin); virtual ~WindowEnvironmentSettingsObject() override; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h index 4412444e75..40b3191af8 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h @@ -27,10 +27,10 @@ public: { auto realm = execution_context->realm; VERIFY(realm); - auto settings_object = realm->heap().allocate(*realm, move(execution_context)).release_allocated_value_but_fixme_should_propagate_errors(); + auto settings_object = realm->heap().allocate(*realm, move(execution_context)); settings_object->target_browsing_context = nullptr; - auto intrinsics = realm->heap().allocate(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto intrinsics = realm->heap().allocate(*realm, *realm); auto host_defined = make(settings_object, intrinsics); realm->set_host_defined(move(host_defined)); diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index b26b143e14..f10bb8e690 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -11,9 +11,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> Storage::create(JS::Realm& realm) +JS::NonnullGCPtr Storage::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } Storage::Storage(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index d02f942f1a..86128a96aa 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -17,7 +17,7 @@ class Storage : public Bindings::LegacyPlatformObject { WEB_PLATFORM_OBJECT(Storage, Bindings::LegacyPlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); ~Storage(); size_t length() const; diff --git a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp index cfb89bf7ae..556c009b5c 100644 --- a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -235,7 +235,7 @@ public: case ValueTag::StringObject: { auto* realm = m_vm.current_realm(); auto string = TRY(deserialize_string_primitive(m_vm, m_vector, position)); - m_memory.append(TRY(JS::StringObject::create(*realm, string, realm->intrinsics().string_prototype()))); + m_memory.append(JS::StringObject::create(*realm, string, realm->intrinsics().string_prototype())); break; } case ValueTag::DateObject: { diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp index 0417f383a3..838b06624d 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -9,9 +9,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> SubmitEvent::create(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init) +JS::NonnullGCPtr SubmitEvent::create(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> SubmitEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h index f48dccd169..a37775a560 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h @@ -19,7 +19,7 @@ class SubmitEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(SubmitEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, SubmitEventInit const& event_init); virtual ~SubmitEvent() override; diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp index c37feeaa34..e520a0c01e 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp @@ -10,9 +10,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> TextMetrics::create(JS::Realm& realm) +JS::NonnullGCPtr TextMetrics::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } TextMetrics::TextMetrics(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.h b/Userland/Libraries/LibWeb/HTML/TextMetrics.h index 693ea4ad13..fe4b96d05e 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.h +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.h @@ -14,7 +14,7 @@ class TextMetrics : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(TextMetrics, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~TextMetrics() override; diff --git a/Userland/Libraries/LibWeb/HTML/TrackEvent.cpp b/Userland/Libraries/LibWeb/HTML/TrackEvent.cpp index 7a0f700c95..40e469738f 100644 --- a/Userland/Libraries/LibWeb/HTML/TrackEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/TrackEvent.cpp @@ -10,9 +10,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> TrackEvent::create(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init) +JS::NonnullGCPtr TrackEvent::create(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, move(event_init))); + return realm.heap().allocate(realm, realm, event_name, move(event_init)); } WebIDL::ExceptionOr> TrackEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init) diff --git a/Userland/Libraries/LibWeb/HTML/TrackEvent.h b/Userland/Libraries/LibWeb/HTML/TrackEvent.h index 3af9efab42..5e03d7456c 100644 --- a/Userland/Libraries/LibWeb/HTML/TrackEvent.h +++ b/Userland/Libraries/LibWeb/HTML/TrackEvent.h @@ -23,8 +23,8 @@ class TrackEvent : public DOM::Event { WEB_PLATFORM_OBJECT(TrackEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, TrackEventInit event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, TrackEventInit = {}); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, TrackEventInit); // https://html.spec.whatwg.org/multipage/media.html#dom-trackevent-track Variant, JS::Handle> track() const; diff --git a/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp b/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp index ac7758f54b..4e5f3bf05f 100644 --- a/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp +++ b/Userland/Libraries/LibWeb/HTML/VideoTrack.cpp @@ -153,7 +153,7 @@ void VideoTrack::set_selected(bool selected) if (previously_unselected_track_is_selected || selected_track_was_unselected_without_another_selection) { m_media_element->queue_a_media_element_task([this]() { - m_video_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors()); + m_video_track_list->dispatch_event(DOM::Event::create(realm(), HTML::EventNames::change)); }); } } diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 6889b18bc6..6b1fbc9e94 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -84,9 +84,9 @@ private: u32 m_handle { 0 }; }; -WebIDL::ExceptionOr> Window::create(JS::Realm& realm) +JS::NonnullGCPtr Window::create(JS::Realm& realm) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } Window::Window(JS::Realm& realm) @@ -577,7 +577,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers // with the persisted attribute initialized to persisted, PageTransitionEventInit event_init {}; event_init.persisted = persisted; - auto event = PageTransitionEvent::create(associated_document().realm(), event_name, event_init).release_value_but_fixme_should_propagate_errors(); + auto event = PageTransitionEvent::create(associated_document().realm(), event_name, event_init); // ...the cancelable attribute initialized to true, event->set_cancelable(true); @@ -593,15 +593,10 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers WebIDL::ExceptionOr> Window::local_storage() { // FIXME: Implement according to spec. - auto& vm = this->vm(); - static HashMap> local_storage_per_origin; - auto storage = TRY_OR_THROW_OOM(vm, local_storage_per_origin.try_ensure(associated_document().origin(), [this]() -> ErrorOr> { - auto storage_or_exception = Storage::create(realm()); - if (storage_or_exception.is_exception()) - return Error::from_errno(ENOMEM); - return *storage_or_exception.release_value(); - })); + auto storage = local_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle { + return Storage::create(realm()); + }); return JS::NonnullGCPtr { *storage }; } @@ -609,15 +604,10 @@ WebIDL::ExceptionOr> Window::local_storage() WebIDL::ExceptionOr> Window::session_storage() { // FIXME: Implement according to spec. - auto& vm = this->vm(); - static HashMap> session_storage_per_origin; - auto storage = TRY_OR_THROW_OOM(vm, session_storage_per_origin.try_ensure(associated_document().origin(), [this]() -> ErrorOr> { - auto storage_or_exception = Storage::create(realm()); - if (storage_or_exception.is_exception()) - return Error::from_errno(ENOMEM); - return *storage_or_exception.release_value(); - })); + auto storage = session_storage_per_origin.ensure(associated_document().origin(), [this]() -> JS::Handle { + return Storage::create(realm()); + }); return JS::NonnullGCPtr { *storage }; } @@ -680,7 +670,7 @@ void Window::invoke_idle_callbacks() // 1. Pop the top callback from window's list of runnable idle callbacks. auto callback = m_runnable_idle_callbacks.take_first(); // 2. Let deadlineArg be a new IdleDeadline whose [get deadline time algorithm] is getDeadline. - auto deadline_arg = RequestIdleCallback::IdleDeadline::create(realm()).release_value_but_fixme_should_propagate_errors(); + auto deadline_arg = RequestIdleCallback::IdleDeadline::create(realm()); // 3. Call callback with deadlineArg as its argument. If an uncaught runtime script error occurs, then report the exception. auto result = callback->invoke(deadline_arg); if (result.is_error()) @@ -730,11 +720,11 @@ Vector> Window::pdf_viewer_plugin_objects() if (m_pdf_viewer_plugin_objects.is_empty()) { // FIXME: Propagate errors. - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors()); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chrome PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors()); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chromium PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors()); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Microsoft Edge PDF Viewer"_string).release_allocated_value_but_fixme_should_propagate_errors()); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "WebKit built-in PDF"_string).release_allocated_value_but_fixme_should_propagate_errors()); + m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chrome PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chromium PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Microsoft Edge PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "WebKit built-in PDF"_string)); } return m_pdf_viewer_plugin_objects; @@ -753,8 +743,8 @@ Vector> Window::pdf_viewer_mime_type_objects() return {}; if (m_pdf_viewer_mime_type_objects.is_empty()) { - m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "application/pdf"_string).release_allocated_value_but_fixme_should_propagate_errors()); - m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "text/pdf"_string).release_allocated_value_but_fixme_should_propagate_errors()); + m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "application/pdf"_string)); + m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "text/pdf"_string)); } return m_pdf_viewer_mime_type_objects; @@ -776,7 +766,7 @@ WebIDL::ExceptionOr> Window::count_queuin auto function = JS::NativeFunction::create(realm, move(steps), 0, "size", &realm); // 3. Set globalObject’s count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object. - m_count_queuing_strategy_size_function = MUST_OR_THROW_OOM(heap().allocate(realm, *function, relevant_settings_object(*this))); + m_count_queuing_strategy_size_function = heap().allocate(realm, *function, relevant_settings_object(*this)); } return JS::NonnullGCPtr { *m_count_queuing_strategy_size_function }; @@ -800,7 +790,7 @@ WebIDL::ExceptionOr> Window::byte_length_ auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm); // 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object. - m_byte_length_queuing_strategy_size_function = MUST_OR_THROW_OOM(heap().allocate(realm, *function, relevant_settings_object(*this))); + m_byte_length_queuing_strategy_size_function = heap().allocate(realm, *function, relevant_settings_object(*this)); } return JS::NonnullGCPtr { *m_byte_length_queuing_strategy_size_function }; @@ -824,7 +814,7 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge(realm, realm)), JS::default_attributes); + define_direct_property("internals", heap().allocate(realm, realm), JS::default_attributes); return {}; } @@ -880,13 +870,13 @@ void Window::set_name(String const& name) } // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location -WebIDL::ExceptionOr> Window::location() +JS::NonnullGCPtr Window::location() { auto& realm = this->realm(); // The Window object's location getter steps are to return this's Location object. if (!m_location) - m_location = MUST_OR_THROW_OOM(heap().allocate(realm, realm)); + m_location = heap().allocate(realm, realm); return JS::NonnullGCPtr { *m_location }; } @@ -993,13 +983,13 @@ WebIDL::ExceptionOr> Window::open(Optional const& } // https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator -WebIDL::ExceptionOr> Window::navigator() +JS::NonnullGCPtr Window::navigator() { auto& realm = this->realm(); // The navigator and clientInformation getter steps are to return this's associated Navigator. if (!m_navigator) - m_navigator = MUST_OR_THROW_OOM(heap().allocate(realm, realm)); + m_navigator = heap().allocate(realm, realm); return JS::NonnullGCPtr { *m_navigator }; } @@ -1043,7 +1033,7 @@ void Window::post_message(JS::Value message, String const&) MessageEventInit event_init {}; event_init.data = message; event_init.origin = ""_string; - dispatch_event(MessageEvent::create(realm(), EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + dispatch_event(MessageEvent::create(realm(), EventNames::message, event_init)); }); } @@ -1057,11 +1047,11 @@ Variant, JS::Value> Window::event() const } // https://w3c.github.io/csswg-drafts/cssom/#dom-window-getcomputedstyle -WebIDL::ExceptionOr> Window::get_computed_style(DOM::Element& element, Optional const& pseudo_element) const +JS::NonnullGCPtr Window::get_computed_style(DOM::Element& element, Optional const& pseudo_element) const { // FIXME: Make this fully spec compliant. (void)pseudo_element; - return MUST_OR_THROW_OOM(heap().allocate(realm(), element)); + return heap().allocate(realm(), element); } // https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-matchmedia @@ -1071,21 +1061,21 @@ WebIDL::ExceptionOr> Window::match_media(S auto parsed_media_query_list = parse_media_query_list(CSS::Parser::ParsingContext(associated_document()), query); // 2. Return a new MediaQueryList object, with this's associated Document as the document, with parsed media query list as its associated media query list. - auto media_query_list = MUST_OR_THROW_OOM(heap().allocate(realm(), associated_document(), move(parsed_media_query_list))); + auto media_query_list = heap().allocate(realm(), associated_document(), move(parsed_media_query_list)); associated_document().add_media_query_list(media_query_list); return media_query_list; } // https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-screen -WebIDL::ExceptionOr> Window::screen() +JS::NonnullGCPtr Window::screen() { // The screen attribute must return the Screen object associated with the Window object. if (!m_screen) - m_screen = MUST_OR_THROW_OOM(heap().allocate(realm(), *this)); + m_screen = heap().allocate(realm(), *this); return JS::NonnullGCPtr { *m_screen }; } -WebIDL::ExceptionOr> Window::visual_viewport() +JS::GCPtr Window::visual_viewport() { // If the associated document is fully active, the visualViewport attribute must return // the VisualViewport object associated with the Window object’s associated document. @@ -1396,31 +1386,31 @@ JS::GCPtr Window::get_selection() const } // https://w3c.github.io/hr-time/#dom-windoworworkerglobalscope-performance -WebIDL::ExceptionOr> Window::performance() +JS::NonnullGCPtr Window::performance() { if (!m_performance) - m_performance = MUST_OR_THROW_OOM(heap().allocate(realm(), *this)); + m_performance = heap().allocate(realm(), *this); return JS::NonnullGCPtr { *m_performance }; } // https://w3c.github.io/webcrypto/#dom-windoworworkerglobalscope-crypto -WebIDL::ExceptionOr> Window::crypto() +JS::NonnullGCPtr Window::crypto() { auto& realm = this->realm(); if (!m_crypto) - m_crypto = MUST_OR_THROW_OOM(heap().allocate(realm, realm)); + m_crypto = heap().allocate(realm, realm); return JS::NonnullGCPtr { *m_crypto }; } // https://html.spec.whatwg.org/multipage/custom-elements.html#dom-window-customelements -WebIDL::ExceptionOr> Window::custom_elements() +JS::NonnullGCPtr Window::custom_elements() { auto& realm = this->realm(); // The customElements attribute of the Window interface must return the CustomElementRegistry object for that Window object. if (!m_custom_element_registry) - m_custom_element_registry = MUST_OR_THROW_OOM(heap().allocate(realm, realm)); + m_custom_element_registry = heap().allocate(realm, realm); return JS::NonnullGCPtr { *m_custom_element_registry }; } diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 9b0452165c..5f5f12baed 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -46,7 +46,7 @@ class Window final WEB_PLATFORM_OBJECT(Window, DOM::EventTarget); public: - static WebIDL::ExceptionOr> create(JS::Realm&); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); ~Window(); @@ -131,7 +131,7 @@ public: JS::NonnullGCPtr document() const; String name() const; void set_name(String const&); - WebIDL::ExceptionOr> location(); + [[nodiscard]] JS::NonnullGCPtr location(); JS::NonnullGCPtr history() const; void focus(); @@ -142,7 +142,7 @@ public: JS::GCPtr frame_element() const; WebIDL::ExceptionOr> open(Optional const& url, Optional const& target, Optional const& features); - WebIDL::ExceptionOr> navigator(); + [[nodiscard]] JS::NonnullGCPtr navigator(); void alert(String const& message = {}); bool confirm(Optional const& message); @@ -152,11 +152,11 @@ public: Variant, JS::Value> event() const; - WebIDL::ExceptionOr> get_computed_style(DOM::Element&, Optional const& pseudo_element) const; + [[nodiscard]] JS::NonnullGCPtr get_computed_style(DOM::Element&, Optional const& pseudo_element) const; WebIDL::ExceptionOr> match_media(String const& query); - WebIDL::ExceptionOr> screen(); - WebIDL::ExceptionOr> visual_viewport(); + [[nodiscard]] JS::NonnullGCPtr screen(); + [[nodiscard]] JS::GCPtr visual_viewport(); i32 inner_width() const; i32 inner_height() const; @@ -182,11 +182,11 @@ public: JS::GCPtr get_selection() const; - WebIDL::ExceptionOr> performance(); + [[nodiscard]] JS::NonnullGCPtr performance(); - WebIDL::ExceptionOr> crypto(); + [[nodiscard]] JS::NonnullGCPtr crypto(); - WebIDL::ExceptionOr> custom_elements(); + [[nodiscard]] JS::NonnullGCPtr custom_elements(); HighResolutionTime::DOMHighResTimeStamp get_last_activation_timestamp() const { return m_last_activation_timestamp; } void set_last_activation_timestamp(HighResolutionTime::DOMHighResTimeStamp timestamp) { m_last_activation_timestamp = timestamp; } diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 6f9f2f87a0..1662fedb5f 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -23,7 +23,7 @@ Worker::Worker(String const& script_url, WorkerOptions const options, DOM::Docum , m_document(&document) , m_custom_data() , m_worker_vm(JS::VM::create(adopt_own(m_custom_data)).release_value_but_fixme_should_propagate_errors()) - , m_implicit_port(MessagePort::create(document.realm()).release_value_but_fixme_should_propagate_errors()) + , m_implicit_port(MessagePort::create(document.realm())) { } @@ -77,10 +77,10 @@ WebIDL::ExceptionOr> Worker::create(String const& scrip // 5. Let worker URL be the resulting URL record. // 6. Let worker be a new Worker object. - auto worker = MUST_OR_THROW_OOM(document.heap().allocate(document.realm(), script_url, options, document)); + auto worker = document.heap().allocate(document.realm(), script_url, options, document); // 7. Let outside port be a new MessagePort in outside settings's Realm. - auto outside_port = TRY(MessagePort::create(outside_settings.realm())); + auto outside_port = MessagePort::create(outside_settings.realm()); // 8. Associate the outside port with worker worker->m_outside_port = outside_port; @@ -166,7 +166,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti MessageEventInit event_init {}; event_init.data = message; event_init.origin = ""_string; - dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init)); })); return JS::js_undefined(); @@ -263,7 +263,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti // FIXME: Global scope association // 16. Let inside port be a new MessagePort object in inside settings's Realm. - auto inside_port = MessagePort::create(m_inner_settings->realm()).release_value_but_fixme_should_propagate_errors(); + auto inside_port = MessagePort::create(m_inner_settings->realm()); // 17. Associate inside port with worker global scope. // FIXME: Global scope association diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp index 620b05043f..3811f34e71 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp @@ -27,7 +27,7 @@ WorkerGlobalScope::~WorkerGlobalScope() = default; void WorkerGlobalScope::initialize(JS::Realm& realm) { Base::initialize(realm); - m_navigator = MUST(WorkerNavigator::create(*this)); + m_navigator = WorkerNavigator::create(*this); } void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp index bb6add43c8..2585f260b4 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp @@ -11,9 +11,9 @@ namespace Web::HTML { -WebIDL::ExceptionOr> WorkerNavigator::create(WorkerGlobalScope& global_scope) +JS::NonnullGCPtr WorkerNavigator::create(WorkerGlobalScope& global_scope) { - return MUST_OR_THROW_OOM(global_scope.heap().allocate(global_scope.realm(), global_scope)); + return global_scope.heap().allocate(global_scope.realm(), global_scope); } WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h index efc18d79df..d5e73cb22e 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h @@ -22,7 +22,7 @@ class WorkerNavigator : public Bindings::PlatformObject WEB_PLATFORM_OBJECT(WorkerNavigator, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(WorkerGlobalScope&); + [[nodiscard]] static JS::NonnullGCPtr create(WorkerGlobalScope&); virtual ~WorkerNavigator() override; diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index e1b638fb2f..f1fad3b394 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -43,7 +43,7 @@ void Performance::visit_edges(Cell::Visitor& visitor) JS::GCPtr Performance::timing() { if (!m_timing) - m_timing = heap().allocate(realm(), *m_window).release_allocated_value_but_fixme_should_propagate_errors(); + m_timing = heap().allocate(realm(), *m_window); return m_timing; } @@ -290,7 +290,7 @@ WebIDL::ExceptionOr> Performanc // NOTE: Already the default value of `detail`. // 4. Create a new PerformanceMeasure object (entry) with this's relevant realm. - auto entry = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail)); + auto entry = realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail); // 10. Queue entry. TRY(window_or_worker->queue_performance_entry(entry)); diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index f4d7b2242b..e7031ecce0 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -39,7 +39,7 @@ WebIDL::ExceptionOr> IntersectionObserver // 2. Set this’s internal [[callback]] slot to callback. // 8. The thresholds attribute getter will return this sorted thresholds list. // 9. Return this. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, callback, options.root, move(thresholds))); + return realm.heap().allocate(realm, realm, callback, options.root, move(thresholds)); } IntersectionObserver::IntersectionObserver(JS::Realm& realm, JS::GCPtr callback, Optional, JS::Handle>> const& root, Vector&& thresholds) diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp index 645d5eb165..e24bdd6ac0 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp @@ -16,11 +16,11 @@ WebIDL::ExceptionOr> IntersectionObs JS::GCPtr root_bounds; if (options.root_bounds.has_value()) - root_bounds = TRY(Geometry::DOMRectReadOnly::from_rect(vm, options.root_bounds.value())); + root_bounds = Geometry::DOMRectReadOnly::from_rect(vm, options.root_bounds.value()); - auto bounding_client_rect = TRY(Geometry::DOMRectReadOnly::from_rect(vm, options.bounding_client_rect)); - auto intersection_rect = TRY(Geometry::DOMRectReadOnly::from_rect(vm, options.intersection_rect)); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, options.time, root_bounds, bounding_client_rect, intersection_rect, options.is_intersecting, options.intersection_ratio, *options.target)); + auto bounding_client_rect = Geometry::DOMRectReadOnly::from_rect(vm, options.bounding_client_rect); + auto intersection_rect = Geometry::DOMRectReadOnly::from_rect(vm, options.intersection_rect); + return realm.heap().allocate(realm, realm, options.time, root_bounds, bounding_client_rect, intersection_rect, options.is_intersecting, options.intersection_ratio, *options.target); } IntersectionObserverEntry::IntersectionObserverEntry(JS::Realm& realm, HighResolutionTime::DOMHighResTimeStamp time, JS::GCPtr root_bounds, JS::NonnullGCPtr bounding_client_rect, JS::NonnullGCPtr intersection_rect, bool is_intersecting, double intersection_ratio, JS::NonnullGCPtr target) diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 83ea5cea6f..46ad7633ea 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -203,7 +203,7 @@ ErrorOr TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element // FIXME: Handle images, and multiple values if (pseudo_element_content.type == CSS::ContentData::Type::String) { - auto text = document.heap().allocate(document.realm(), document, pseudo_element_content.data.to_deprecated_string()).release_allocated_value_but_fixme_should_propagate_errors(); + auto text = document.heap().allocate(document.realm(), document, pseudo_element_content.data.to_deprecated_string()); auto text_node = document.heap().allocate_without_realm(document, *text); text_node->set_generated_for(generated_for, element); diff --git a/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp b/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp index cafa20d34e..16fcac25ed 100644 --- a/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp +++ b/Userland/Libraries/LibWeb/MathML/MathMLElement.cpp @@ -22,7 +22,7 @@ void MathMLElement::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "MathMLElement")); - m_dataset = MUST(HTML::DOMStringMap::create(*this)); + m_dataset = HTML::DOMStringMap::create(*this); } Optional MathMLElement::default_role() const diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 57e25fb5be..7d712364e0 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -693,12 +693,12 @@ bool EventHandler::fire_keyboard_event(FlyString const& event_name, HTML::Browsi return fire_keyboard_event(event_name, *navigable_container.nested_browsing_context(), key, modifiers, code_point); } - auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point).release_value_but_fixme_should_propagate_errors(); + auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point); return !focused_element->dispatch_event(event); } // FIXME: De-duplicate this. This is just to prevent wasting a KeyboardEvent allocation when recursing into an (i)frame. - auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point).release_value_but_fixme_should_propagate_errors(); + auto event = UIEvents::KeyboardEvent::create_from_platform_event(document->realm(), event_name, key, modifiers, code_point); if (JS::GCPtr body = document->body()) return !body->dispatch_event(event); diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index b4641bcd4f..b0d6fb123d 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -12,9 +12,9 @@ namespace Web::RequestIdleCallback { -WebIDL::ExceptionOr> IdleDeadline::create(JS::Realm& realm, bool did_timeout) +JS::NonnullGCPtr IdleDeadline::create(JS::Realm& realm, bool did_timeout) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, did_timeout)); + return realm.heap().allocate(realm, realm, did_timeout); } IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h index 1a150ca111..3776599c6d 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h @@ -15,7 +15,7 @@ class IdleDeadline final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(IdleDeadline, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, bool did_timeout = false); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, bool did_timeout = false); virtual ~IdleDeadline() override; double time_remaining() const; diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 3655f502f3..3c8473c0bf 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -15,7 +15,7 @@ WebIDL::ExceptionOr> ResizeObserver::construct_ { // FIXME: Implement (void)callback; - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + return realm.heap().allocate(realm, realm); } ResizeObserver::ResizeObserver(JS::Realm& realm) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index 6943ed1710..124e2ed960 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -9,9 +9,9 @@ namespace Web::SVG { -WebIDL::ExceptionOr> SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) +JS::NonnullGCPtr SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(base_val), move(anim_val))); + return realm.heap().allocate(realm, realm, move(base_val), move(anim_val)); } SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h index a1255f52bf..5aab8e6c1c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -16,7 +16,7 @@ class SVGAnimatedLength final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SVGAnimatedLength, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val); virtual ~SVGAnimatedLength() override; JS::NonnullGCPtr base_val() const { return m_base_val; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp index 18ec1ab3a1..6304096fba 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp @@ -9,9 +9,9 @@ namespace Web::SVG { -WebIDL::ExceptionOr> SVGAnimatedNumber::create(JS::Realm& realm, float base_val, float anim_val) +JS::NonnullGCPtr SVGAnimatedNumber::create(JS::Realm& realm, float base_val, float anim_val) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, base_val, anim_val)); + return realm.heap().allocate(realm, realm, base_val, anim_val); } SVGAnimatedNumber::SVGAnimatedNumber(JS::Realm& realm, float base_val, float anim_val) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.h index a9e09af7e2..b08aa94331 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedNumber.h @@ -16,7 +16,7 @@ class SVGAnimatedNumber final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SVGAnimatedNumber, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, float base_val, float anim_val); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, float base_val, float anim_val); virtual ~SVGAnimatedNumber() override; float base_val() const { return m_base_val; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index 534d677edf..b578625696 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -82,9 +82,9 @@ JS::NonnullGCPtr SVGCircleElement::cx() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#CircleElementCYAttribute @@ -92,9 +92,9 @@ JS::NonnullGCPtr SVGCircleElement::cy() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute @@ -102,9 +102,9 @@ JS::NonnullGCPtr SVGCircleElement::r() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_radius.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index d35b6bb9c7..e04301bd4c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -25,7 +25,7 @@ void SVGElement::initialize(JS::Realm& realm) Base::initialize(realm); set_prototype(&Bindings::ensure_web_prototype(realm, "SVGElement")); - m_dataset = MUST(HTML::DOMStringMap::create(*this)); + m_dataset = HTML::DOMStringMap::create(*this); } void SVGElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index c519fce692..fb8c1b3b55 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -87,9 +87,9 @@ JS::NonnullGCPtr SVGEllipseElement::cx() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_center_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCYAttribute @@ -97,9 +97,9 @@ JS::NonnullGCPtr SVGEllipseElement::cy() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_center_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRXAttribute @@ -107,9 +107,9 @@ JS::NonnullGCPtr SVGEllipseElement::rx() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementRYAttribute @@ -117,9 +117,9 @@ JS::NonnullGCPtr SVGEllipseElement::ry() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index 2f259bf24e..af4de78c48 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -28,10 +28,10 @@ void SVGForeignObjectElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGForeignObjectElement")); // FIXME: These never actually get updated! - m_x = MUST(SVGAnimatedLength::create(realm, MUST(SVGLength::create(realm, 0, 0)), MUST(SVGLength::create(realm, 0, 0)))); - m_y = MUST(SVGAnimatedLength::create(realm, MUST(SVGLength::create(realm, 0, 0)), MUST(SVGLength::create(realm, 0, 0)))); - m_width = MUST(SVGAnimatedLength::create(realm, MUST(SVGLength::create(realm, 0, 0)), MUST(SVGLength::create(realm, 0, 0)))); - m_height = MUST(SVGAnimatedLength::create(realm, MUST(SVGLength::create(realm, 0, 0)), MUST(SVGLength::create(realm, 0, 0)))); + m_x = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + m_y = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + m_width = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + m_height = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); } void SVGForeignObjectElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index 1be1227120..ae53ce61e0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -9,9 +9,9 @@ namespace Web::SVG { -WebIDL::ExceptionOr> SVGLength::create(JS::Realm& realm, u8 unit_type, float value) +JS::NonnullGCPtr SVGLength::create(JS::Realm& realm, u8 unit_type, float value) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, unit_type, value)); + return realm.heap().allocate(realm, realm, unit_type, value); } SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.h b/Userland/Libraries/LibWeb/SVG/SVGLength.h index 048e21e5d7..832e19216e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.h @@ -16,7 +16,7 @@ class SVGLength : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(SVGLength, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, u8 unit_type, float value); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, u8 unit_type, float value); virtual ~SVGLength() override; u8 unit_type() const { return m_unit_type; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index 1704e1e522..0251402829 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -67,9 +67,9 @@ JS::NonnullGCPtr SVGLineElement::x1() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_x1.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementY1Attribute @@ -77,9 +77,9 @@ JS::NonnullGCPtr SVGLineElement::y1() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_y1.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementX2Attribute @@ -87,9 +87,9 @@ JS::NonnullGCPtr SVGLineElement::x2() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_x2.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#LineElementY2Attribute @@ -97,9 +97,9 @@ JS::NonnullGCPtr SVGLineElement::y2() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_y2.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index b1559ac839..baf32a2089 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -164,9 +164,9 @@ JS::NonnullGCPtr SVGRectElement::x() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute @@ -174,9 +174,9 @@ JS::NonnullGCPtr SVGRectElement::y() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementWidthAttribute @@ -184,9 +184,9 @@ JS::NonnullGCPtr SVGRectElement::width() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_width.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_width.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementHeightAttribute @@ -194,9 +194,9 @@ JS::NonnullGCPtr SVGRectElement::height() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_height.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_height.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementRXAttribute @@ -204,9 +204,9 @@ JS::NonnullGCPtr SVGRectElement::rx() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_radius_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementRYAttribute @@ -214,9 +214,9 @@ JS::NonnullGCPtr SVGRectElement::ry() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_radius_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index 9aee188ab3..947db7bb1a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -27,12 +27,12 @@ void SVGUseElement::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "SVGUseElement")); // The shadow tree is open (inspectable by script), but read-only. - auto shadow_root = MUST(heap().allocate(realm, document(), *this, Bindings::ShadowRootMode::Open)); + auto shadow_root = heap().allocate(realm, document(), *this, Bindings::ShadowRootMode::Open); // The user agent must create a use-element shadow tree whose host is the ‘use’ element itself set_shadow_root(shadow_root); - m_document_observer = MUST(realm.heap().allocate(realm, realm, document())); + m_document_observer = realm.heap().allocate(realm, realm, document()); m_document_observer->document_completely_loaded = [this]() { clone_element_tree_as_our_shadow_tree(referenced_element()); }; @@ -136,9 +136,9 @@ JS::NonnullGCPtr SVGUseElement::x() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_x.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_x.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } // https://www.w3.org/TR/SVG11/shapes.html#RectElementYAttribute @@ -146,9 +146,9 @@ JS::NonnullGCPtr SVGUseElement::y() const { // FIXME: Populate the unit type when it is parsed (0 here is "unknown"). // FIXME: Create a proper animated value when animations are supported. - auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)).release_value_but_fixme_should_propagate_errors(); - return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)).release_value_but_fixme_should_propagate_errors(); + auto base_length = SVGLength::create(realm(), 0, m_y.value_or(0)); + auto anim_length = SVGLength::create(realm(), 0, m_y.value_or(0)); + return SVGAnimatedLength::create(realm(), move(base_length), move(anim_length)); } JS::NonnullGCPtr SVGUseElement::width() const diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 546a3a5381..72aa62b0e6 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -11,9 +11,9 @@ namespace Web::Selection { -WebIDL::ExceptionOr> Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) +JS::NonnullGCPtr Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) { - return MUST_OR_THROW_OOM(realm->heap().allocate(realm, realm, document)); + return realm->heap().allocate(realm, realm, document); } Selection::Selection(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) @@ -185,7 +185,7 @@ WebIDL::ExceptionOr Selection::collapse(JS::GCPtr node, unsigne return {}; // 4. Otherwise, let newRange be a new range. - auto new_range = TRY(DOM::Range::create(*m_document)); + auto new_range = DOM::Range::create(*m_document); // 5. Set the start the start and the end of newRange to (node, offset). TRY(new_range->set_start(*node, offset)); @@ -212,7 +212,7 @@ WebIDL::ExceptionOr Selection::collapse_to_start() } // 2. Otherwise, it must create a new range - auto new_range = TRY(DOM::Range::create(*m_document)); + auto new_range = DOM::Range::create(*m_document); // 3. Set the start both its start and end to the start of this's range TRY(new_range->set_start(*anchor_node(), m_range->start_offset())); @@ -232,7 +232,7 @@ WebIDL::ExceptionOr Selection::collapse_to_end() } // 2. Otherwise, it must create a new range - auto new_range = TRY(DOM::Range::create(*m_document)); + auto new_range = DOM::Range::create(*m_document); // 3. Set the start both its start and end to the start of this's range TRY(new_range->set_start(*anchor_node(), m_range->end_offset())); @@ -264,7 +264,7 @@ WebIDL::ExceptionOr Selection::extend(JS::NonnullGCPtr node, un auto new_focus_offset = offset; // 4. Let newRange be a new range. - auto new_range = TRY(DOM::Range::create(*m_document)); + auto new_range = DOM::Range::create(*m_document); // 5. If node's root is not the same as the this's range's root, set the start newRange's start and end to newFocus. if (&node->root() != &m_range->start_container()->root()) { @@ -313,7 +313,7 @@ WebIDL::ExceptionOr Selection::set_base_and_extent(JS::NonnullGCPtr Selection::select_all_children(JS::NonnullGCPtrchild_count(); // 3. Set newRange's start to (node, 0). diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index 1a3e7214de..d6586b0258 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -15,7 +15,7 @@ class Selection final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::NonnullGCPtr, JS::NonnullGCPtr); + [[nodiscard]] static JS::NonnullGCPtr create(JS::NonnullGCPtr, JS::NonnullGCPtr); virtual ~Selection() override; diff --git a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp index 702de212be..01f1ee8348 100644 --- a/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -41,7 +41,7 @@ WebIDL::ExceptionOr> acquire_reada auto& realm = stream.realm(); // 1. Let reader be a new ReadableStreamDefaultReader. - auto reader = TRY(realm.heap().allocate(realm, realm)); + auto reader = realm.heap().allocate(realm, realm); // 2. Perform ? SetUpReadableStreamDefaultReader(reader, stream). TRY(set_up_readable_stream_default_reader(reader, stream)); @@ -56,7 +56,7 @@ WebIDL::ExceptionOr> acquire_readable auto& realm = stream.realm(); // 1. Let reader be a new ReadableStreamBYOBReader. - auto reader = TRY(realm.heap().allocate(realm, realm)); + auto reader = realm.heap().allocate(realm, realm); // 2. Perform ? SetUpReadableStreamBYOBReader(reader, stream). TRY(set_up_readable_stream_byob_reader(reader, stream)); @@ -834,7 +834,7 @@ WebIDL::ExceptionOr set_up_readable_stream_default_controller_from_underly auto& realm = stream.realm(); // 1. Let controller be a new ReadableStreamDefaultController. - auto controller = MUST_OR_THROW_OOM(stream.heap().allocate(realm, realm)); + auto controller = stream.heap().allocate(realm, realm); // 2. Let startAlgorithm be an algorithm that returns undefined. StartAlgorithm start_algorithm = [] { return JS::js_undefined(); }; @@ -1172,13 +1172,13 @@ WebIDL::ExceptionOr> create_readable_stream(JS: VERIFY(is_non_negative_number(JS::Value { *high_water_mark })); // 4. Let stream be a new ReadableStream. - auto stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto stream = realm.heap().allocate(realm, realm); // 5. Perform ! InitializeReadableStream(stream). initialize_readable_stream(*stream); // 6. Let controller be a new ReadableStreamDefaultController. - auto controller = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto controller = realm.heap().allocate(realm, realm); // 7. Perform ? SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm). TRY(set_up_readable_stream_default_controller(*stream, *controller, move(start_algorithm), move(pull_algorithm), move(cancel_algorithm), *high_water_mark, move(*size_algorithm))); @@ -1194,13 +1194,13 @@ WebIDL::ExceptionOr> create_writable_stream(JS: VERIFY(is_non_negative_number(JS::Value { high_water_mark })); // 2. Let stream be a new WritableStream. - auto stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto stream = realm.heap().allocate(realm, realm); // 3. Perform ! InitializeWritableStream(stream). initialize_writable_stream(*stream); // 4. Let controller be a new WritableStreamDefaultController. - auto controller = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto controller = realm.heap().allocate(realm, realm); // 5. Perform ? SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm). TRY(set_up_writable_stream_default_controller(*stream, *controller, move(start_algorithm), move(write_algorithm), move(close_algorithm), move(abort_algorithm), high_water_mark, move(size_algorithm))); @@ -1252,7 +1252,7 @@ WebIDL::ExceptionOr> acquire_writa auto& realm = stream.realm(); // 1. Let writer be a new WritableStreamDefaultWriter. - auto writer = MUST_OR_THROW_OOM(stream.heap().allocate(realm, realm)); + auto writer = stream.heap().allocate(realm, realm); // 2. Perform ? SetUpWritableStreamDefaultWriter(writer, stream). TRY(set_up_writable_stream_default_writer(*writer, stream)); @@ -1730,7 +1730,7 @@ WebIDL::ExceptionOr set_up_readable_stream_controller_with_byte_reading_su // 4. Perform ! InitializeReadableStream(stream). // 5. Let controller be a new ReadableByteStreamController. - auto controller = MUST_OR_THROW_OOM(stream.heap().allocate(realm, realm)); + auto controller = stream.heap().allocate(realm, realm); // 6. Perform ! SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithmWrapper, cancelAlgorithmWrapper, highWaterMark, undefined). TRY(set_up_readable_byte_stream_controller(stream, controller, move(start_algorithm), move(pull_algorithm_wrapper), move(cancel_algorithm_wrapper), high_water_mark, JS::js_undefined())); @@ -2418,7 +2418,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller(WritableStre reset_queue(controller); // 6. Set controller.[[signal]] to a new AbortSignal. - controller.set_signal(MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm))); + controller.set_signal(realm.heap().allocate(realm, realm)); // 7. Set controller.[[started]] to false. controller.set_started(false); @@ -2489,7 +2489,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller_from_underly auto& realm = stream.realm(); // 1. Let controller be a new WritableStreamDefaultController. - auto controller = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto controller = realm.heap().allocate(realm, realm); // 2. Let startAlgorithm be an algorithm that returns undefined. StartAlgorithm start_algorithm = [] { return JS::js_undefined(); }; @@ -2916,7 +2916,7 @@ WebIDL::ExceptionOr set_up_transform_stream_default_controller_from_transf auto& vm = realm.vm(); // 1. Let controller be a new TransformStreamDefaultController. - auto controller = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto controller = realm.heap().allocate(realm, realm); // 2. Let transformAlgorithm be the following steps, taking a chunk argument: TransformAlgorithm transform_algorithm = [controller, &realm, &vm](JS::Value chunk) { @@ -3308,7 +3308,7 @@ WebIDL::ExceptionOr set_up_readable_byte_stream_controller_from_underlying auto& realm = stream.realm(); // 1. Let controller be a new ReadableByteStreamController. - auto controller = MUST_OR_THROW_OOM(stream.heap().allocate(realm, realm)); + auto controller = stream.heap().allocate(realm, realm); // 2. Let startAlgorithm be an algorithm that returns undefined. StartAlgorithm start_algorithm = [] { return JS::js_undefined(); }; diff --git a/Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp b/Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp index 847afb101d..afbfadf65d 100644 --- a/Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp +++ b/Userland/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp @@ -18,7 +18,7 @@ WebIDL::ExceptionOr> ByteLengthQueui { // The new ByteLengthQueuingStrategy(init) constructor steps are: // 1. Set this.[[highWaterMark]] to init["highWaterMark"]. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, init.high_water_mark)); + return realm.heap().allocate(realm, realm, init.high_water_mark); } ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double high_water_mark) diff --git a/Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp b/Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp index 1745bb216c..8e0ccc4080 100644 --- a/Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp +++ b/Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp @@ -18,7 +18,7 @@ WebIDL::ExceptionOr> CountQueuingStrategy { // The new CountQueuingStrategy(init) constructor steps are: // 1. Set this.[[highWaterMark]] to init["highWaterMark"]. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, init.high_water_mark)); + return realm.heap().allocate(realm, realm, init.high_water_mark); } CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark) diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index b8e799ff80..b695c27faa 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -23,7 +23,7 @@ WebIDL::ExceptionOr> ReadableStream::construct_ { auto& vm = realm.vm(); - auto readable_stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto readable_stream = realm.heap().allocate(realm, realm); // 1. If underlyingSource is missing, set it to null. auto underlying_source = underlying_source_object.has_value() ? JS::Value(underlying_source_object.value().ptr()) : JS::js_null(); diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp index dc03e9bb9f..6e6bb49e60 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp @@ -33,7 +33,7 @@ void ReadLoopReadRequest::visit_edges(Visitor& visitor) // https://streams.spec.whatwg.org/#default-reader-constructor WebIDL::ExceptionOr> ReadableStreamDefaultReader::construct_impl(JS::Realm& realm, JS::NonnullGCPtr stream) { - auto reader = TRY(realm.heap().allocate(realm, realm)); + auto reader = realm.heap().allocate(realm, realm); // 1. Perform ? SetUpReadableStreamDefaultReader(this, stream); TRY(set_up_readable_stream_default_reader(reader, *stream)); diff --git a/Userland/Libraries/LibWeb/Streams/TransformStream.cpp b/Userland/Libraries/LibWeb/Streams/TransformStream.cpp index ff54019c50..c3319b99ee 100644 --- a/Userland/Libraries/LibWeb/Streams/TransformStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/TransformStream.cpp @@ -20,7 +20,7 @@ WebIDL::ExceptionOr> TransformStream::construc { auto& vm = realm.vm(); - auto stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto stream = realm.heap().allocate(realm, realm); // 1. If transformer is missing, set it to null. auto transformer = transformer_object.has_value() ? JS::Value { transformer_object.value().ptr() } : JS::js_null(); diff --git a/Userland/Libraries/LibWeb/Streams/WritableStream.cpp b/Userland/Libraries/LibWeb/Streams/WritableStream.cpp index 3428eb63d5..9b1c6ecd53 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/WritableStream.cpp @@ -21,7 +21,7 @@ WebIDL::ExceptionOr> WritableStream::construct_ { auto& vm = realm.vm(); - auto writable_stream = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto writable_stream = realm.heap().allocate(realm, realm); // 1. If underlyingSink is missing, set it to null. auto underlying_sink = underlying_sink_object.has_value() ? JS::Value(underlying_sink_object.value().ptr()) : JS::js_null(); diff --git a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp index 9996e2e998..2ca9c38236 100644 --- a/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp +++ b/Userland/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp @@ -16,7 +16,7 @@ namespace Web::Streams { WebIDL::ExceptionOr> WritableStreamDefaultWriter::construct_impl(JS::Realm& realm, JS::NonnullGCPtr stream) { - auto writer = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto writer = realm.heap().allocate(realm, realm); // 1. Perform ? SetUpWritableStreamDefaultWriter(this, stream). TRY(set_up_writable_stream_default_writer(*writer, stream)); diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp index 868d399b7c..a666b99633 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -11,7 +11,7 @@ namespace Web::UIEvents { WebIDL::ExceptionOr> FocusEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } FocusEvent::FocusEvent(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index 5fa279c9b9..5e4bbc24c3 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -503,12 +503,10 @@ static DOMKeyLocation get_event_location(KeyCode platform_key, unsigned modifier return DOMKeyLocation::Standard; } -WebIDL::ExceptionOr> KeyboardEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, KeyCode platform_key, unsigned modifiers, u32 code_point) +JS::NonnullGCPtr KeyboardEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, KeyCode platform_key, unsigned modifiers, u32 code_point) { - auto& vm = realm.vm(); - - auto event_key = TRY_OR_THROW_OOM(vm, get_event_key(platform_key, code_point)); - auto event_code = TRY_OR_THROW_OOM(vm, get_event_code(platform_key, modifiers)); + auto event_key = MUST(get_event_key(platform_key, code_point)); + auto event_code = MUST(get_event_code(platform_key, modifiers)); auto key_code = determine_key_code(platform_key, code_point); KeyboardEventInit event_init {}; @@ -542,9 +540,9 @@ bool KeyboardEvent::get_modifier_state(String const& key_arg) return false; } -WebIDL::ExceptionOr> KeyboardEvent::create(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) +JS::NonnullGCPtr KeyboardEvent::create(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> KeyboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h index 9f2ef054f8..f7aa304e51 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h @@ -36,9 +36,9 @@ class KeyboardEvent final : public UIEvent { WEB_PLATFORM_OBJECT(KeyboardEvent, UIEvent); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init = {}); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& event_init); - static WebIDL::ExceptionOr> create_from_platform_event(JS::Realm&, FlyString const& event_name, KeyCode, unsigned modifiers, u32 code_point); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, KeyboardEventInit const& = {}); + [[nodiscard]] static JS::NonnullGCPtr create_from_platform_event(JS::Realm&, FlyString const& event_name, KeyCode, unsigned modifiers, u32 code_point); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, KeyboardEventInit const&); virtual ~KeyboardEvent() override; diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 39f69d07d3..217a1fd7d9 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -54,9 +54,9 @@ static i16 determine_button(unsigned mouse_button) } } -WebIDL::ExceptionOr> MouseEvent::create(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init) +JS::NonnullGCPtr MouseEvent::create(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> MouseEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button) diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 394bf31736..f06e1f98fa 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -29,7 +29,7 @@ class MouseEvent : public UIEvent { WEB_PLATFORM_OBJECT(MouseEvent, UIEvent); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, MouseEventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, MouseEventInit const& = {}); static WebIDL::ExceptionOr> create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixelPoint offset, CSSPixelPoint client_offset, CSSPixelPoint page_offset, unsigned buttons, unsigned mouse_button = 1); virtual ~MouseEvent() override; diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp index 2c3c6e8e30..80af8ff2e1 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -9,14 +9,14 @@ namespace Web::UIEvents { -WebIDL::ExceptionOr> UIEvent::create(JS::Realm& realm, FlyString const& event_name) +JS::NonnullGCPtr UIEvent::create(JS::Realm& realm, FlyString const& event_name) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name)); + return realm.heap().allocate(realm, realm, event_name); } WebIDL::ExceptionOr> UIEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name) diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 02346315fc..3879c1b0e4 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -21,7 +21,7 @@ class UIEvent : public DOM::Event { WEB_PLATFORM_OBJECT(UIEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& type); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& type); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, UIEventInit const& event_init); virtual ~UIEvent() override; diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp index 31a11b8958..85093dcbda 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -29,9 +29,9 @@ void WheelEvent::initialize(JS::Realm& realm) set_prototype(&Bindings::ensure_web_prototype(realm, "WheelEvent")); } -WebIDL::ExceptionOr> WheelEvent::create(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init) +JS::NonnullGCPtr WheelEvent::create(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> WheelEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button) diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h index 93a1460c6f..1a735e2133 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h @@ -29,7 +29,7 @@ class WheelEvent final : public MouseEvent { WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, WheelEventInit const& event_init = {}); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, WheelEventInit const& event_init = {}); static WebIDL::ExceptionOr> create_from_platform_event(JS::Realm&, FlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button); virtual ~WheelEvent() override; diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index a1a6a94311..05f1af05c7 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -16,9 +16,9 @@ namespace Web::URL { -WebIDL::ExceptionOr> URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr query) +JS::NonnullGCPtr URL::create(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr query) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(url), move(query))); + return realm.heap().allocate(realm, realm, move(url), move(query)); } // https://url.spec.whatwg.org/#api-url-parser @@ -67,7 +67,7 @@ WebIDL::ExceptionOr> URL::construct_impl(JS::Realm& realm, auto query_object = MUST(URLSearchParams::construct_impl(realm, query)); // 6. Initialize this’s query object with query. - auto result_url = TRY(URL::create(realm, parsed_url.release_value(), move(query_object))); + auto result_url = URL::create(realm, parsed_url.release_value(), move(query_object)); // 7. Set this’s query object’s URL object to this. result_url->m_query->m_url = result_url; diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index 2da8b0fcbc..b236a85ad1 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -19,7 +19,7 @@ class URL : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(URL, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(JS::Realm&, AK::URL url, JS::NonnullGCPtr query); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, AK::URL, JS::NonnullGCPtr query); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, String const& url, Optional const& base = {}); virtual ~URL() override; diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index 10767229c9..9c4401c4ed 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -118,7 +118,7 @@ ErrorOr> url_decode(StringView input) WebIDL::ExceptionOr> URLSearchParams::create(JS::Realm& realm, Vector list) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(list))); + return realm.heap().allocate(realm, realm, move(list)); } // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp index b4937eee44..ba058645c2 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto prototype = heap().allocate(realm, realm); m_prototypes.set("URLSearchParamsIterator"sv, prototype); } @@ -25,7 +25,7 @@ namespace Web::URL { WebIDL::ExceptionOr> URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) { - return MUST_OR_THROW_OOM(url_search_params.heap().allocate(url_search_params.realm(), url_search_params, iteration_kind)); + return url_search_params.heap().allocate(url_search_params.realm(), url_search_params, iteration_kind); } URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) diff --git a/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp b/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp index d3ed05d9aa..b2c5c3727f 100644 --- a/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp +++ b/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp @@ -88,7 +88,7 @@ WebIDL::ExceptionOr> PerformanceMark::construc } // 2. Create a new PerformanceMark object (entry) with the current global object's realm. - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, name, start_time, duration, detail)); + return realm.heap().allocate(realm, realm, name, start_time, duration, detail); } FlyString const& PerformanceMark::entry_type() const diff --git a/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp b/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp index ee6f8117b3..0c88c27a24 100644 --- a/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp +++ b/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp @@ -24,9 +24,9 @@ PerformanceMeasure::PerformanceMeasure(JS::Realm& realm, String const& name, Hig PerformanceMeasure::~PerformanceMeasure() = default; -WebIDL::ExceptionOr> PerformanceMeasure::create(JS::Realm& realm, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail) +JS::NonnullGCPtr PerformanceMeasure::create(JS::Realm& realm, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail)); + return realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail); } FlyString const& PerformanceMeasure::entry_type() const diff --git a/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.h b/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.h index 7cd9aba204..9c324693ef 100644 --- a/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.h +++ b/Userland/Libraries/LibWeb/UserTiming/PerformanceMeasure.h @@ -25,7 +25,7 @@ class PerformanceMeasure final : public PerformanceTimeline::PerformanceEntry { public: virtual ~PerformanceMeasure(); - static WebIDL::ExceptionOr> create(JS::Realm&, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail); // NOTE: These three functions are answered by the registry for the given entry type. // https://w3c.github.io/timing-entrytypes-registry/#registry diff --git a/Userland/Libraries/LibWeb/WebAssembly/Instance.cpp b/Userland/Libraries/LibWeb/WebAssembly/Instance.cpp index 3ae7aef44b..9fb77abf59 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/Instance.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/Instance.cpp @@ -28,7 +28,7 @@ WebIDL::ExceptionOr> Instance::construct_impl(JS::Rea auto& vm = realm.vm(); auto index = TRY(Detail::instantiate_module(vm, module.module())); - return MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, index)); + return vm.heap().allocate(realm, realm, index); } Instance::Instance(JS::Realm& realm, size_t index) @@ -62,7 +62,7 @@ void Instance::initialize(JS::Realm& realm) [&](Wasm::MemoryAddress const& address) { Optional> object = cache.memory_instances.get(address); if (!object.has_value()) { - object = MUST(heap().allocate(realm, realm, address)); + object = heap().allocate(realm, realm, address); cache.memory_instances.set(address, *object); } @@ -71,7 +71,7 @@ void Instance::initialize(JS::Realm& realm) [&](Wasm::TableAddress const& address) { Optional> object = cache.table_instances.get(address); if (!object.has_value()) { - object = MUST(heap().allocate(realm, realm, address)); + object = heap().allocate
(realm, realm, address); cache.table_instances.set(address, *object); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp b/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp index aef12f1b16..864baf1c44 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/Memory.cpp @@ -25,7 +25,7 @@ WebIDL::ExceptionOr> Memory::construct_impl(JS::Realm& if (!address.has_value()) return vm.throw_completion("Wasm Memory allocation failed"sv); - auto memory_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, *address)); + auto memory_object = vm.heap().allocate(realm, realm, *address); Detail::s_abstract_machine.store().get(*address)->successful_grow_hook = [memory_object] { MUST(memory_object->reset_the_memory_buffer()); }; diff --git a/Userland/Libraries/LibWeb/WebAssembly/Module.cpp b/Userland/Libraries/LibWeb/WebAssembly/Module.cpp index b92db841c5..c4d45dbcbe 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/Module.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/Module.cpp @@ -19,7 +19,7 @@ WebIDL::ExceptionOr> Module::construct_impl(JS::Realm& auto& vm = realm.vm(); auto index = TRY(Detail::parse_module(vm, bytes.cell())); - return MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, index)); + return vm.heap().allocate(realm, realm, index); } Module::Module(JS::Realm& realm, size_t index) diff --git a/Userland/Libraries/LibWeb/WebAssembly/Table.cpp b/Userland/Libraries/LibWeb/WebAssembly/Table.cpp index a2e4354aee..0c192fe1c6 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/Table.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/Table.cpp @@ -52,7 +52,7 @@ WebIDL::ExceptionOr> Table::construct_impl(JS::Realm& re for (auto& element : table.elements()) element = reference; - return MUST_OR_THROW_OOM(vm.heap().allocate
(realm, realm, *address)); + return vm.heap().allocate
(realm, realm, *address); } Table::Table(JS::Realm& realm, Wasm::TableAddress address) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp index ede245a4a6..d6092354ae 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp @@ -88,7 +88,7 @@ WebIDL::ExceptionOr compile(JS::VM& vm, JS::Handle& bytes if (module.is_error()) { promise->reject(*module.release_error().value()); } else { - auto module_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, module.release_value())); + auto module_object = vm.heap().allocate(realm, realm, module.release_value()); promise->fulfill(module_object); } @@ -118,8 +118,8 @@ WebIDL::ExceptionOr instantiate(JS::VM& vm, JS::Handle& b if (result.is_error()) { promise->reject(*result.release_error().value()); } else { - auto module_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, Detail::s_compiled_modules.size() - 1)); - auto instance_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, result.release_value())); + auto module_object = vm.heap().allocate(realm, realm, Detail::s_compiled_modules.size() - 1); + auto instance_object = vm.heap().allocate(realm, realm, result.release_value()); auto object = JS::Object::create(realm, nullptr); object->define_direct_property("module", module_object, JS::default_attributes); @@ -145,7 +145,7 @@ WebIDL::ExceptionOr instantiate(JS::VM& vm, Module const& module_obje if (result.is_error()) { promise->reject(*result.release_error().value()); } else { - auto instance_object = MUST_OR_THROW_OOM(vm.heap().allocate(realm, realm, result.release_value())); + auto instance_object = vm.heap().allocate(realm, realm, result.release_value()); promise->fulfill(instance_object); } @@ -426,7 +426,7 @@ JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value) auto& realm = *vm.current_realm(); switch (wasm_value.type().kind()) { case Wasm::ValueType::I64: - return realm.heap().allocate(realm, ::Crypto::SignedBigInteger { wasm_value.to().value() }).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, ::Crypto::SignedBigInteger { wasm_value.to().value() }); case Wasm::ValueType::I32: return JS::Value(wasm_value.to().value()); case Wasm::ValueType::F64: diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp index 35882baa0e..058349e359 100644 --- a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -15,7 +15,7 @@ namespace Web::WebAudio { // https://webaudio.github.io/web-audio-api/#dom-audiocontext-audiocontext WebIDL::ExceptionOr> AudioContext::construct_impl(JS::Realm& realm, AudioContextOptions const& context_options) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, context_options)); + return realm.heap().allocate(realm, realm, context_options); } AudioContext::AudioContext(JS::Realm& realm, AudioContextOptions const& context_options) @@ -72,7 +72,7 @@ AudioContext::AudioContext(JS::Realm& realm, AudioContextOptions const& context_ BaseAudioContext::set_control_state(Bindings::AudioContextState::Running); // 5.3.2: queue a media element task to fire an event named statechange at the AudioContext. - this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange).release_value_but_fixme_should_propagate_errors()); + this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange)); }); } } @@ -174,7 +174,7 @@ WebIDL::ExceptionOr> AudioContext::resume() // 7.5.4.2: queue a media element task to fire an event named statechange at the AudioContext. queue_a_media_element_task([&realm, this]() { - this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange).release_value_but_fixme_should_propagate_errors()); + this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange)); }); } }); @@ -229,7 +229,7 @@ WebIDL::ExceptionOr> AudioContext::suspend() // 7.3.2.2: queue a media element task to fire an event named statechange at the AudioContext. queue_a_media_element_task([&realm, this]() { - this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange).release_value_but_fixme_should_propagate_errors()); + this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange)); }); } }); @@ -280,7 +280,7 @@ WebIDL::ExceptionOr> AudioContext::close() // 5.4.2.2: queue a media element task to fire an event named statechange at the AudioContext. // FIXME: Attempting to queue another task in here causes an assertion fail at Vector.h:148 - this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange).release_value_but_fixme_should_propagate_errors()); + this->dispatch_event(DOM::Event::create(realm, HTML::EventNames::statechange)); }); // 6. Return promise diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp index c9a57491e3..2049bc3383 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp @@ -9,9 +9,9 @@ namespace Web::WebGL { -WebIDL::ExceptionOr> WebGLContextEvent::create(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init) +JS::NonnullGCPtr WebGLContextEvent::create(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> WebGLContextEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h index bf2cb811eb..a4dad188e3 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h @@ -20,8 +20,8 @@ class WebGLContextEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(WebGLContextEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init); - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& type, WebGLContextEventInit const&); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& type, WebGLContextEventInit const&); virtual ~WebGLContextEvent() override; diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 6f5ecf3b1c..76e5a2a767 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -18,7 +18,7 @@ static void fire_webgl_context_event(HTML::HTMLCanvasElement& canvas_element, Fl { // To fire a WebGL context event named e means that an event using the WebGLContextEvent interface, with its type attribute [DOM4] initialized to e, its cancelable attribute initialized to true, and its isTrusted attribute [DOM4] initialized to true, is to be dispatched at the given object. // FIXME: Consider setting a status message. - auto event = WebGLContextEvent::create(canvas_element.realm(), type, WebGLContextEventInit {}).release_value_but_fixme_should_propagate_errors(); + auto event = WebGLContextEvent::create(canvas_element.realm(), type, WebGLContextEventInit {}); event->set_is_trusted(true); event->set_cancelable(true); canvas_element.dispatch_event(*event); @@ -47,7 +47,7 @@ JS::ThrowCompletionOr> WebGLRenderingContext::c fire_webgl_context_creation_error(canvas_element); return JS::GCPtr { nullptr }; } - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes)); + return realm.heap().allocate(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes); } WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters) diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp index 8304b2c3a5..baaeac3a3f 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -11,12 +11,12 @@ namespace Web::WebIDL { JS::NonnullGCPtr DOMException::create(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) { - return realm.heap().allocate(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, name, message); } JS::NonnullGCPtr DOMException::construct_impl(JS::Realm& realm, DeprecatedFlyString const& message, DeprecatedFlyString const& name) { - return realm.heap().allocate(realm, realm, name, message).release_allocated_value_but_fixme_should_propagate_errors(); + return realm.heap().allocate(realm, realm, name, message); } DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index 6699af290c..d5050e70e3 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -53,7 +53,7 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R { auto& vm = realm.vm(); - auto web_socket = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto web_socket = realm.heap().allocate(realm, realm); auto& relevant_settings_object = HTML::relevant_settings_object(*web_socket); // 1. Let baseURL be this's relevant settings object's API base URL. @@ -264,13 +264,13 @@ void WebSocket::on_open() // 1. Change the readyState attribute's value to OPEN (1). // 2. Change the extensions attribute's value to the extensions in use, if it is not the null value. [WSP] // 3. Change the protocol attribute's value to the subprotocol in use, if it is not the null value. [WSP] - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::open).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::open)); } // https://websockets.spec.whatwg.org/#feedback-from-the-protocol void WebSocket::on_error() { - dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors()); + dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error)); } // https://websockets.spec.whatwg.org/#feedback-from-the-protocol @@ -282,7 +282,7 @@ void WebSocket::on_close(u16 code, String reason, bool was_clean) event_init.was_clean = was_clean; event_init.code = code; event_init.reason = reason; - dispatch_event(HTML::CloseEvent::create(realm(), HTML::EventNames::close, event_init).release_value_but_fixme_should_propagate_errors()); + dispatch_event(HTML::CloseEvent::create(realm(), HTML::EventNames::close, event_init)); } // https://websockets.spec.whatwg.org/#feedback-from-the-protocol @@ -295,7 +295,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) HTML::MessageEventInit event_init; event_init.data = JS::PrimitiveString::create(vm(), text_message); event_init.origin = url().release_value_but_fixme_should_propagate_errors(); - dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); return; } @@ -307,7 +307,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text) HTML::MessageEventInit event_init; event_init.data = JS::ArrayBuffer::create(realm(), message); event_init.origin = url().release_value_but_fixme_should_propagate_errors(); - dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors()); + dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init)); return; } diff --git a/Userland/Libraries/LibWeb/XHR/FormData.cpp b/Userland/Libraries/LibWeb/XHR/FormData.cpp index 31523e199b..86d05ad72a 100644 --- a/Userland/Libraries/LibWeb/XHR/FormData.cpp +++ b/Userland/Libraries/LibWeb/XHR/FormData.cpp @@ -35,7 +35,7 @@ WebIDL::ExceptionOr> FormData::construct_impl(JS::Rea WebIDL::ExceptionOr> FormData::construct_impl(JS::Realm& realm, Vector entry_list) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, move(entry_list))); + return realm.heap().allocate(realm, realm, move(entry_list)); } FormData::FormData(JS::Realm& realm, Vector entry_list) diff --git a/Userland/Libraries/LibWeb/XHR/FormDataIterator.cpp b/Userland/Libraries/LibWeb/XHR/FormDataIterator.cpp index 64e6395ea7..b27856f53b 100644 --- a/Userland/Libraries/LibWeb/XHR/FormDataIterator.cpp +++ b/Userland/Libraries/LibWeb/XHR/FormDataIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm).release_allocated_value_but_fixme_should_propagate_errors(); + auto prototype = heap().allocate(realm, realm); m_prototypes.set("FormDataIterator"sv, prototype); } @@ -23,9 +23,9 @@ void Intrinsics::create_web_prototype_and_constructor namespace Web::XHR { -WebIDL::ExceptionOr> FormDataIterator::create(FormData const& form_data, JS::Object::PropertyKind iterator_kind) +JS::NonnullGCPtr FormDataIterator::create(FormData const& form_data, JS::Object::PropertyKind iterator_kind) { - return MUST_OR_THROW_OOM(form_data.heap().allocate(form_data.realm(), form_data, iterator_kind)); + return form_data.heap().allocate(form_data.realm(), form_data, iterator_kind); } FormDataIterator::FormDataIterator(Web::XHR::FormData const& form_data, JS::Object::PropertyKind iterator_kind) diff --git a/Userland/Libraries/LibWeb/XHR/FormDataIterator.h b/Userland/Libraries/LibWeb/XHR/FormDataIterator.h index e07f846c04..cc02aac6e1 100644 --- a/Userland/Libraries/LibWeb/XHR/FormDataIterator.h +++ b/Userland/Libraries/LibWeb/XHR/FormDataIterator.h @@ -15,7 +15,7 @@ class FormDataIterator : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(FormDataIterator, Bindings::PlatformObject); public: - static WebIDL::ExceptionOr> create(FormData const&, JS::Object::PropertyKind iterator_kind); + [[nodiscard]] static JS::NonnullGCPtr create(FormData const&, JS::Object::PropertyKind iterator_kind); virtual ~FormDataIterator() override; diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp index 83c7ecdf27..0fa831b13e 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -9,9 +9,9 @@ namespace Web::XHR { -WebIDL::ExceptionOr> ProgressEvent::create(JS::Realm& realm, FlyString const& event_name, ProgressEventInit const& event_init) +JS::NonnullGCPtr ProgressEvent::create(JS::Realm& realm, FlyString const& event_name, ProgressEventInit const& event_init) { - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, event_name, event_init)); + return realm.heap().allocate(realm, realm, event_name, event_init); } WebIDL::ExceptionOr> ProgressEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ProgressEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h index 285d2480c8..5f8c24de90 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h @@ -24,7 +24,7 @@ class ProgressEvent final : public DOM::Event { WEB_PLATFORM_OBJECT(ProgressEvent, DOM::Event); public: - static WebIDL::ExceptionOr> create(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init); virtual ~ProgressEvent() override; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 116d9048c4..fae5c8e383 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -51,11 +51,11 @@ namespace Web::XHR { WebIDL::ExceptionOr> XMLHttpRequest::construct_impl(JS::Realm& realm) { - auto upload_object = MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm)); + auto upload_object = realm.heap().allocate(realm, realm); auto author_request_headers = Fetch::Infrastructure::HeaderList::create(realm.vm()); auto response = Fetch::Infrastructure::Response::network_error(realm.vm(), "Not sent yet"sv); auto fetch_controller = Fetch::Infrastructure::FetchController::create(realm.vm()); - return MUST_OR_THROW_OOM(realm.heap().allocate(realm, realm, *upload_object, *author_request_headers, *response, *fetch_controller)); + return realm.heap().allocate(realm, realm, *upload_object, *author_request_headers, *response, *fetch_controller); } XMLHttpRequest::XMLHttpRequest(JS::Realm& realm, XMLHttpRequestUpload& upload_object, Fetch::Infrastructure::HeaderList& author_request_headers, Fetch::Infrastructure::Response& response, Fetch::Infrastructure::FetchController& fetch_controller) @@ -100,7 +100,7 @@ static void fire_progress_event(XMLHttpRequestEventTarget& target, FlyString con event_init.loaded = transmitted; event_init.total = length; // FIXME: If we're in an async context, this will propagate to a callback context which can't propagate it anywhere else and does not expect this to fail. - target.dispatch_event(*ProgressEvent::create(target.realm(), event_name, event_init).release_value_but_fixme_should_propagate_errors()); + target.dispatch_event(*ProgressEvent::create(target.realm(), event_name, event_init)); } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsetext @@ -179,8 +179,8 @@ WebIDL::ExceptionOr XMLHttpRequest::response() // 6. Otherwise, if this’s response type is "blob", set this’s response object to a new Blob object representing this’s received bytes with type set to the result of get a final MIME type for this. else if (m_response_type == Bindings::XMLHttpRequestResponseType::Blob) { auto mime_type_as_string = TRY_OR_THROW_OOM(vm, TRY_OR_THROW_OOM(vm, get_final_mime_type()).serialized()); - auto blob_part = TRY(FileAPI::Blob::create(realm(), m_received_bytes, move(mime_type_as_string))); - auto blob = TRY(FileAPI::Blob::create(realm(), Vector { JS::make_handle(*blob_part) })); + auto blob_part = FileAPI::Blob::create(realm(), m_received_bytes, move(mime_type_as_string)); + auto blob = FileAPI::Blob::create(realm(), Vector { JS::make_handle(*blob_part) }); m_response_object = JS::Value(blob.ptr()); } // 7. Otherwise, if this’s response type is "document", set a document response for this. @@ -434,7 +434,7 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri m_state = State::Opened; // 2. Fire an event named readystatechange at this. - dispatch_event(TRY(DOM::Event::create(realm(), EventNames::readystatechange))); + dispatch_event(DOM::Event::create(realm(), EventNames::readystatechange)); } return {}; @@ -684,7 +684,7 @@ WebIDL::ExceptionOr XMLHttpRequest::send(Optionalrealm(), EventNames::readystatechange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(this->realm(), EventNames::readystatechange)); // 6. If this’s state is not headers received, then return. if (m_state != State::HeadersReceived) @@ -1086,7 +1086,7 @@ WebIDL::ExceptionOr XMLHttpRequest::handle_response_end_of_body() // 9. Fire an event named readystatechange at xhr. // FIXME: If we're in an async context, this will propagate to a callback context which can't propagate it anywhere else and does not expect this to fail. - dispatch_event(*DOM::Event::create(realm, EventNames::readystatechange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm, EventNames::readystatechange)); // 10. Fire a progress event named load at xhr with transmitted and length. fire_progress_event(*this, EventNames::load, transmitted, length); @@ -1138,7 +1138,7 @@ JS::ThrowCompletionOr XMLHttpRequest::request_error_steps(FlyString const& // 5. Fire an event named readystatechange at xhr. // FIXME: Since we're in an async context, this will propagate to a callback context which can't propagate it anywhere else and does not expect this to fail. - dispatch_event(*DOM::Event::create(realm(), EventNames::readystatechange).release_value_but_fixme_should_propagate_errors()); + dispatch_event(*DOM::Event::create(realm(), EventNames::readystatechange)); // 6. If xhr’s upload complete flag is unset, then: if (!m_upload_complete) { diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index c80472ad2e..668e2bb2ea 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -197,7 +197,7 @@ void XMLDocumentBuilder::document_end() document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time(); // Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true. - auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded).release_value_but_fixme_should_propagate_errors(); + auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded); content_loaded_event->set_bubbles(true); document->dispatch_event(content_loaded_event); @@ -237,7 +237,7 @@ void XMLDocumentBuilder::document_end() // Fire an event named load at window, with legacy target override flag set. // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event() // We should reorganize this so that the flag appears explicitly here instead. - window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors()); + window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load)); // FIXME: Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL. diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp index 1f32d54188..da80cdd9ab 100644 --- a/Userland/Services/WebContent/WebContentConsoleClient.cpp +++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp @@ -28,7 +28,7 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm , m_client(client) { auto& window = verify_cast(realm.global_object()); - m_console_global_environment_extensions = realm.heap().allocate(realm, realm, window).release_allocated_value_but_fixme_should_propagate_errors().ptr(); + m_console_global_environment_extensions = realm.heap().allocate(realm, realm, window); } void WebContentConsoleClient::handle_input(DeprecatedString const& js_source) diff --git a/Userland/Services/WebContent/WebDriverConnection.cpp b/Userland/Services/WebContent/WebDriverConnection.cpp index d59642278a..ead63a0038 100644 --- a/Userland/Services/WebContent/WebDriverConnection.cpp +++ b/Userland/Services/WebContent/WebDriverConnection.cpp @@ -316,7 +316,7 @@ static bool fire_an_event(FlyString name, Optional target) if (!target.has_value()) return false; - auto event = T::create(target->realm(), name).release_value_but_fixme_should_propagate_errors(); + auto event = T::create(target->realm(), name); return target->dispatch_event(event); }