summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-02-14 21:41:47 +0100
committerLinus Groh <mail@linusgroh.de>2023-02-18 00:52:47 +0100
commit552663a2ba934424ce1279cd4959d225a1f287cf (patch)
tree02b5f7d97a20cc8fe6d4f2b860d2c0740935ac20 /Userland/Libraries/LibWeb
parent251c063897d661e13eaf224dab766b43997a9e03 (diff)
downloadserenity-552663a2ba934424ce1279cd4959d225a1f287cf.zip
LibWeb: Make factory method of DOM::TreeWalker fallible
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/TreeWalker.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/TreeWalker.h2
3 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index a76f45e723..e7e5a75afe 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -1953,7 +1953,7 @@ JS::NonnullGCPtr<NodeIterator> Document::create_node_iterator(Node& root, unsign
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
JS::NonnullGCPtr<TreeWalker> Document::create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
{
- return TreeWalker::create(root, what_to_show, filter);
+ return TreeWalker::create(root, what_to_show, filter).release_value_but_fixme_should_propagate_errors();
}
void Document::register_node_iterator(Badge<NodeIterator>, NodeIterator& node_iterator)
diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp
index bd4ba764cf..a163bac8c0 100644
--- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp
+++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp
@@ -39,12 +39,12 @@ void TreeWalker::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
-JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
+WebIDL::ExceptionOr<JS::NonnullGCPtr<TreeWalker>> TreeWalker::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> 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 = realm.heap().allocate<TreeWalker>(realm, root).release_allocated_value_but_fixme_should_propagate_errors();
+ auto walker = MUST_OR_THROW_OOM(realm.heap().allocate<TreeWalker>(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 96b84cae68..b2dbff68d1 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 JS::NonnullGCPtr<TreeWalker> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
+ static WebIDL::ExceptionOr<JS::NonnullGCPtr<TreeWalker>> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
virtual ~TreeWalker() override;