LibWeb: Make factory method of DOM::TreeWalker fallible

This commit is contained in:
Kenneth Myhra 2023-02-14 21:41:47 +01:00 committed by Linus Groh
parent 251c063897
commit 552663a2ba
Notes: sideshowbarker 2024-07-17 11:33:34 +09:00
3 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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 walkers root and walkers 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 walkers whatToShow to whatToShow.
walker->m_what_to_show = what_to_show;

View File

@ -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;