summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-02-19 16:22:24 +0100
committerAndreas Kling <kling@serenityos.org>2023-02-22 09:55:33 +0100
commitff92324fa563a89513c387e65b76495b7eec16fa (patch)
tree61dabc6e9baa7801d44a852c0606e812968577f7
parenta2381a672db518e4af9087eb382ed417e66a1a52 (diff)
downloadserenity-ff92324fa563a89513c387e65b76495b7eec16fa.zip
LibWeb: Make factory method of DOM::ElementFactory fallible
-rw-r--r--Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp3
-rw-r--r--Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp3
-rw-r--r--Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp8
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/ElementFactory.cpp170
-rw-r--r--Userland/Libraries/LibWeb/DOM/ElementFactory.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/DOMParser.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp12
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp8
-rw-r--r--Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp2
-rw-r--r--Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp2
15 files changed, 115 insertions, 111 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
index 96d8ca6340..eed8d57db3 100644
--- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp
@@ -5,6 +5,7 @@
*/
#include <LibWeb/Bindings/AudioConstructor.h>
+#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HTMLAudioElementPrototype.h>
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/HTML/Scripting/Environments.h>
@@ -44,7 +45,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> AudioConstructor::construct(
auto& document = window.associated_document();
// 2. Let audio be the result of creating an element given document, audio, and the HTML namespace.
- auto audio = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML);
+ auto audio = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML); }));
// 3. Set an attribute value for audio using "preload" and "auto".
MUST(audio->set_attribute(HTML::AttributeNames::preload, "auto"sv));
diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
index 424b64e0cc..6b8a057ea5 100644
--- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HTMLImageElementPrototype.h>
#include <LibWeb/Bindings/ImageConstructor.h>
#include <LibWeb/DOM/ElementFactory.h>
@@ -44,7 +45,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> ImageConstructor::construct(
auto& document = window.associated_document();
// 2. Let img be the result of creating an element given document, img, and the HTML namespace.
- auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML);
+ auto image_element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::img, Namespace::HTML); }));
// 3. If width is given, then set an attribute value for img using "width" and width.
if (vm.argument_count() > 0) {
diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
index 9e24cd8e6f..315fb93d81 100644
--- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HTMLOptionElementPrototype.h>
#include <LibWeb/Bindings/OptionConstructor.h>
#include <LibWeb/DOM/ElementFactory.h>
@@ -47,7 +48,8 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
auto& document = window.associated_document();
// 2. Let option be the result of creating an element given document, option, and the HTML namespace.
- JS::NonnullGCPtr<HTML::HTMLOptionElement> option_element = verify_cast<HTML::HTMLOptionElement>(*DOM::create_element(document, HTML::TagNames::option, Namespace::HTML));
+ auto element = TRY(Bindings::throw_dom_exception_if_needed(vm, [&]() { return DOM::create_element(document, HTML::TagNames::option, Namespace::HTML); }));
+ JS::NonnullGCPtr<HTML::HTMLOptionElement> option_element = verify_cast<HTML::HTMLOptionElement>(*element);
// 3. If text is not the empty string, then append to option a new Text node whose data is text.
if (vm.argument_count() > 0) {
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
index 5b7ba64eab..9c911174d2 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
+++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
@@ -88,21 +88,21 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
doctype->set_name("html");
MUST(html_document->append_child(*doctype));
- auto html_element = create_element(html_document, HTML::TagNames::html, Namespace::HTML);
+ auto html_element = create_element(html_document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_document->append_child(html_element));
- auto head_element = create_element(html_document, HTML::TagNames::head, Namespace::HTML);
+ auto head_element = create_element(html_document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(head_element));
if (!title.is_null()) {
- auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML);
+ 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<Text>(realm(), html_document, title).release_allocated_value_but_fixme_should_propagate_errors();
MUST(title_element->append_child(*text_node));
}
- auto body_element = create_element(html_document, HTML::TagNames::body, Namespace::HTML);
+ auto body_element = create_element(html_document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(html_element->append_child(body_element));
html_document->set_origin(document().origin());
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index e2514c352f..be7869289d 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -1214,7 +1214,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(Deprecat
namespace_ = Namespace::HTML;
// 6. Return the result of creating an element given this, localName, namespace, null, is, and with the synchronous custom elements flag set.
- return DOM::create_element(*this, local_name, namespace_);
+ return TRY(DOM::create_element(*this, local_name, namespace_));
}
// https://dom.spec.whatwg.org/#dom-document-createelementns
@@ -1229,7 +1229,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(Depre
// FIXME: 3. If options is a dictionary and options["is"] exists, then set is to it.
// 4. Return the result of creating an element given document, localName, namespace, prefix, is, and with the synchronous custom elements flag set.
- return DOM::create_element(*this, extracted_qualified_name.local_name(), extracted_qualified_name.namespace_(), extracted_qualified_name.prefix());
+ return TRY(DOM::create_element(*this, extracted_qualified_name.local_name(), extracted_qualified_name.namespace_(), extracted_qualified_name.prefix()));
}
JS::NonnullGCPtr<DocumentFragment> Document::create_document_fragment()
diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
index 09a521b568..94065af8eb 100644
--- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
+++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp
@@ -95,7 +95,7 @@
namespace Web::DOM {
// https://dom.spec.whatwg.org/#concept-create-element
-JS::NonnullGCPtr<Element> create_element(Document& document, DeprecatedFlyString local_name, DeprecatedFlyString namespace_, DeprecatedFlyString prefix)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document, DeprecatedFlyString local_name, DeprecatedFlyString namespace_, DeprecatedFlyString prefix)
{
// 1. If prefix was not given, let prefix be null.
// NOTE: This is already taken care of by `prefix` having a default value.
@@ -120,180 +120,180 @@ JS::NonnullGCPtr<Element> create_element(Document& document, DeprecatedFlyString
auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
if (lowercase_tag_name == HTML::TagNames::a)
- return realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::area)
- return realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::audio)
- return realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::base)
- return realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::blink)
- return realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::body)
- return realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::br)
- return realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::button)
- return realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::canvas)
- return realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::data)
- return realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::datalist)
- return realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::details)
- return realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dialog)
- return realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dir)
- return realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::div)
- return realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::dl)
- return realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::embed)
- return realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::fieldset)
- return realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::font)
- return realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::form)
- return realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::frame)
- return realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::frameset)
- return realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::head)
- return realm.heap().allocate<HTML::HTMLHeadElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHeadElement>(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 realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::hr)
- return realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::html)
- return realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::iframe)
- return realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::img)
- return realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::input)
- return realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::label)
- return realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::legend)
- return realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::li)
- return realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::link)
- return realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::map)
- return realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::marquee)
- return realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::menu)
- return realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::meta)
- return realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::meter)
- return realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del))
- return realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::object)
- return realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::ol)
- return realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::optgroup)
- return realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::option)
- return realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::output)
- return realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::p)
- return realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::param)
- return realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::picture)
- return realm.heap().allocate<HTML::HTMLPictureElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLPictureElement>(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 realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::progress)
- return realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q))
- return realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::script)
- return realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::select)
- return realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::slot)
- return realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::source)
- return realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::span)
- return realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::style)
- return realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::caption)
- return realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th))
- return realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col))
- return realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::table)
- return realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::tr)
- return realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot))
- return realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::template_)
- return realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::textarea)
- return realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::time)
- return realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::title)
- return realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::track)
- return realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::ul)
- return realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == HTML::TagNames::video)
- return realm.heap().allocate<HTML::HTMLVideoElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLVideoElement>(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::summary, 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 realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::svg)
- return realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name)));
// FIXME: Support SVG's mixedCase tag names properly.
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::clipPath))
- return realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::circle)
- return realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::defs))
- return realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::ellipse)
- return realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::foreignObject))
- return realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::line)
- return realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::path)
- return realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::polygon)
- return realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::polyline)
- return realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::rect)
- return realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::g)
- return realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name)));
if (lowercase_tag_name == SVG::TagNames::text)
- return realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name)));
// FIXME: If name is a valid custom element name, then return HTMLElement.
- return realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name)).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name)));
}
}
diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.h b/Userland/Libraries/LibWeb/DOM/ElementFactory.h
index ff2d46334a..cccdc9c886 100644
--- a/Userland/Libraries/LibWeb/DOM/ElementFactory.h
+++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.h
@@ -10,6 +10,6 @@
namespace Web::DOM {
-JS::NonnullGCPtr<Element> create_element(Document&, DeprecatedFlyString local_name, DeprecatedFlyString namespace_, DeprecatedFlyString prefix = {});
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document&, DeprecatedFlyString local_name, DeprecatedFlyString namespace_, DeprecatedFlyString prefix = {});
}
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp
index 2844df3b5d..094905f195 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Node.cpp
@@ -727,7 +727,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
if (is<Element>(this)) {
// 1. Let copy be the result of creating an element, given document, node’s local name, node’s namespace, node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset.
auto& element = *verify_cast<Element>(this);
- auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_() /* FIXME: node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset */);
+ auto element_copy = DOM::create_element(*document, element.local_name(), element.namespace_() /* FIXME: node’s namespace prefix, and node’s is value, with the synchronous custom elements flag unset */).release_value_but_fixme_should_propagate_errors();
// 2. For each attribute in node’s attribute list:
element.for_each_attribute([&](auto& name, auto& value) {
diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp
index 081550de37..9f4c655038 100644
--- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp
@@ -68,7 +68,7 @@ JS::NonnullGCPtr<DOM::Document> DOMParser::parse_from_string(DeprecatedString co
// 1. Assert: document has no child nodes.
document->remove_all_children(true);
// 2. Let root be the result of creating an element given document, "parsererror", and "http://www.mozilla.org/newlayout/xml/parsererror.xml".
- auto root = DOM::create_element(*document, "parsererror", "http://www.mozilla.org/newlayout/xml/parsererror.xml");
+ auto root = DOM::create_element(*document, "parsererror", "http://www.mozilla.org/newlayout/xml/parsererror.xml").release_value_but_fixme_should_propagate_errors();
// FIXME: 3. Optionally, add attributes or children to root to describe the nature of the parsing error.
// 4. Append root to document.
MUST(document->append_child(*root));
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
index 322c5cff4e..880c7e0701 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
@@ -88,7 +88,7 @@ JS::NonnullGCPtr<HTMLTableCaptionElement> HTMLTableElement::create_caption()
return *maybe_caption;
}
- auto caption = DOM::create_element(document(), TagNames::caption, Namespace::HTML);
+ auto caption = DOM::create_element(document(), TagNames::caption, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(pre_insert(caption, first_child()));
return static_cast<HTMLTableCaptionElement&>(*caption);
}
@@ -166,7 +166,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_head()
if (maybe_thead)
return *maybe_thead;
- auto thead = DOM::create_element(document(), TagNames::thead, Namespace::HTML);
+ auto thead = DOM::create_element(document(), TagNames::thead, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
// We insert the new thead after any <caption> or <colgroup> elements
DOM::Node* child_to_insert_before = nullptr;
@@ -242,7 +242,7 @@ JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_foot()
if (maybe_tfoot)
return *maybe_tfoot;
- auto tfoot = DOM::create_element(document(), TagNames::tfoot, Namespace::HTML);
+ auto tfoot = DOM::create_element(document(), TagNames::tfoot, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
MUST(append_child(tfoot));
return static_cast<HTMLTableSectionElement&>(*tfoot);
}
@@ -272,7 +272,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::t_bodies()
// https://html.spec.whatwg.org/multipage/tables.html#dom-table-createtbody
JS::NonnullGCPtr<HTMLTableSectionElement> HTMLTableElement::create_t_body()
{
- auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML);
+ auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
// We insert the new tbody after the last <tbody> element
DOM::Node* child_to_insert_before = nullptr;
@@ -335,9 +335,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::ins
if (index < -1 || index > (long)rows_length) {
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows");
}
- auto& tr = static_cast<HTMLTableRowElement&>(*DOM::create_element(document(), TagNames::tr, Namespace::HTML));
+ auto& tr = static_cast<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
if (rows_length == 0 && !has_child_of_type<HTMLTableRowElement>()) {
- auto tbody = DOM::create_element(document(), TagNames::tbody, Namespace::HTML);
+ auto tbody = TRY(DOM::create_element(document(), TagNames::tbody, Namespace::HTML));
TRY(tbody->append_child(tr));
TRY(append_child(tbody));
} else if (rows_length == 0) {
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp
index a72941ee6b..efe5044f2c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp
@@ -112,7 +112,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableCellElement>> HTMLTableRowElement:
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells");
// 2. Let table cell be the result of creating an element given this tr element's node document, td, and the HTML namespace.
- auto& table_cell = static_cast<HTMLTableCellElement&>(*DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML));
+ auto& table_cell = static_cast<HTMLTableCellElement&>(*TRY(DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML)));
// 3. If index is equal to −1 or equal to the number of items in cells collection, then append table cell to this tr element.
if (index == -1 || index == cells_collection_size)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
index 1f4b976526..1a3c00ccfe 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
@@ -60,7 +60,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableSectionEleme
return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows");
// 2. Let table row be the result of creating an element given this element's node document, tr, and the HTML namespace.
- auto& table_row = static_cast<HTMLTableRowElement&>(*DOM::create_element(document(), TagNames::tr, Namespace::HTML));
+ auto& table_row = static_cast<HTMLTableRowElement&>(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML)));
// 3. If index is −1 or equal to the number of items in the rows collection, then append table row to this element.
if (index == -1 || index == rows_collection_size)
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index b8148c3fee..cb480c1baf 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -536,8 +536,8 @@ void HTMLParser::handle_before_html(HTMLToken& token)
// -> Anything else
AnythingElse:
// Create an html element whose node document is the Document object. Append it to the Document object. Put this element in the stack of open elements.
- auto element = create_element(document(), HTML::TagNames::html, Namespace::HTML);
- MUST(document().append_child(*element));
+ auto element = create_element(document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
+ MUST(document().append_child(element));
m_stack_of_open_elements.push(element);
// Switch the insertion mode to "before head", then reprocess the token.
@@ -638,7 +638,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& t
// 9. Let element be the result of creating an element given document, localName, given namespace, null, and is.
// FIXME: If will execute script is true, set the synchronous custom elements flag; otherwise, leave it unset.
// FIXME: Pass in `null` and `is`.
- auto element = create_element(*document, local_name, namespace_);
+ auto element = create_element(*document, local_name, namespace_).release_value_but_fixme_should_propagate_errors();
// 10. Append each attribute in the given token to element.
// FIXME: This isn't the exact `append` the spec is talking about.
@@ -3499,7 +3499,7 @@ Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& cont
}
// 5. Let root be a new html element with no attributes.
- auto root = create_element(context_element.document(), HTML::TagNames::html, Namespace::HTML);
+ auto root = create_element(context_element.document(), HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
// 6. Append the element root to the Document node created above.
MUST(temp_document->append_child(root));
diff --git a/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp b/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp
index 249074f432..3d79916cf3 100644
--- a/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp
+++ b/Userland/Libraries/LibWeb/WebDriver/Screenshot.cpp
@@ -57,7 +57,7 @@ Response capture_element_screenshot(Painter const& painter, Page& page, DOM::Ele
auto viewport_rect = page.top_level_browsing_context().viewport_rect();
rect.intersect(page.enclosing_device_rect(viewport_rect).to_type<int>());
- auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, Namespace::HTML);
+ auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
auto& canvas = verify_cast<HTML::HTMLCanvasElement>(*canvas_element);
if (!canvas.create_bitmap(rect.width(), rect.height())) {
diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
index 25d830d266..c1468b2bc7 100644
--- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
+++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
@@ -64,7 +64,7 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
}
}
- auto node = DOM::create_element(m_document, name, {});
+ auto node = DOM::create_element(m_document, name, {}).release_value_but_fixme_should_propagate_errors();
// When an XML parser with XML scripting support enabled creates a script element,
// it must have its parser document set and its "force async" flag must be unset.
// FIXME: If the parser was created as part of the XML fragment parsing algorithm, then the element must be marked as "already started" also.