summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp12
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h6
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp2
4 files changed, 12 insertions, 12 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
index d327fd4a8a..5b7ba64eab 100644
--- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
+++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp
@@ -49,7 +49,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(DeprecatedString const& namespace_, DeprecatedString const& qualified_name, JS::GCPtr<DocumentType> doctype) const
{
// FIXME: This should specifically be an XML document.
- auto xml_document = Document::create(realm());
+ auto xml_document = TRY(Document::create(realm()));
xml_document->set_ready_for_post_load_tasks(true);
@@ -79,7 +79,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_docume
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedString const& title) const
{
- auto html_document = Document::create(realm());
+ auto html_document = Document::create(realm()).release_value_but_fixme_should_propagate_errors();
html_document->set_content_type("text/html");
html_document->set_ready_for_post_load_tasks(true);
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index e7e5a75afe..abb4634664 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -126,7 +126,7 @@ static JS::NonnullGCPtr<HTML::BrowsingContext> obtain_a_browsing_context_to_use_
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#initialise-the-document-object
-JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, DeprecatedString content_type, HTML::NavigationParams navigation_params)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(Type type, DeprecatedString content_type, HTML::NavigationParams navigation_params)
{
// 1. Let browsingContext be the result of the obtaining a browsing context to use for a navigation response
// given navigationParams's browsing context, navigationParams's final sandboxing flag set,
@@ -230,7 +230,7 @@ JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, Deprecated
// 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 = Document::create(window->realm());
+ auto document = TRY(Document::create(window->realm()));
document->m_type = type;
document->m_content_type = move(content_type);
document->set_origin(navigation_params.origin);
@@ -283,14 +283,14 @@ JS::NonnullGCPtr<Document> Document::create_and_initialize(Type type, Deprecated
return document;
}
-JS::NonnullGCPtr<Document> Document::construct_impl(JS::Realm& realm)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::construct_impl(JS::Realm& realm)
{
return Document::create(realm);
}
-JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, AK::URL const& url)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create(JS::Realm& realm, AK::URL const& url)
{
- return realm.heap().allocate<Document>(realm, realm, url).release_allocated_value_but_fixme_should_propagate_errors();
+ return MUST_OR_THROW_OOM(realm.heap().allocate<Document>(realm, realm, url));
}
Document::Document(JS::Realm& realm, const AK::URL& url)
@@ -2330,7 +2330,7 @@ JS::NonnullGCPtr<DOM::Document> 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 = DOM::Document::create(realm());
+ auto new_document = DOM::Document::create(realm()).release_value_but_fixme_should_propagate_errors();
new_document->m_created_for_appropriate_template_contents = true;
// 2. If doc is an HTML document, mark new doc as an HTML document also.
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index bb45b04d1d..c741e62a4f 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -82,10 +82,10 @@ public:
HTML
};
- static JS::NonnullGCPtr<Document> create_and_initialize(Type, DeprecatedString content_type, HTML::NavigationParams);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_and_initialize(Type, DeprecatedString content_type, HTML::NavigationParams);
- static JS::NonnullGCPtr<Document> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
- static JS::NonnullGCPtr<Document> construct_impl(JS::Realm&);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create(JS::Realm&, AK::URL const& url = "about:blank"sv);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> construct_impl(JS::Realm&);
virtual ~Document() override;
// https://w3c.github.io/selection-api/#dom-document-getselection
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp
index 9ee0a1f330..4ca8818b88 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Node.cpp
@@ -730,7 +730,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
else if (is<Document>(this)) {
// Document
auto document_ = verify_cast<Document>(this);
- auto document_copy = Document::create(this->realm(), document_->url());
+ auto document_copy = Document::create(this->realm(), document_->url()).release_value_but_fixme_should_propagate_errors();
// Set copy’s encoding, content type, URL, origin, type, and mode to those of node.
document_copy->set_encoding(document_->encoding());