1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-17 11:47:37 +00:00

LibWeb: Make factory method of DOM::NodeIterator fallible

This commit is contained in:
Kenneth Myhra 2023-02-15 07:30:10 +01:00 committed by Linus Groh
parent 0791195843
commit d94b59263e
3 changed files with 4 additions and 4 deletions

View file

@ -1947,7 +1947,7 @@ WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_nam
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
JS::NonnullGCPtr<NodeIterator> Document::create_node_iterator(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
{
return NodeIterator::create(root, what_to_show, filter);
return NodeIterator::create(root, what_to_show, filter).release_value_but_fixme_should_propagate_errors();
}
// https://dom.spec.whatwg.org/#dom-document-createtreewalker

View file

@ -47,13 +47,13 @@ void NodeIterator::visit_edges(Cell::Visitor& visitor)
}
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeIterator>> NodeIterator::create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter> filter)
{
// 1. Let iterator be a new NodeIterator object.
// 2. Set iterators root and iterators reference to root.
// 3. Set iterators pointer before reference to true.
auto& realm = root.realm();
auto iterator = realm.heap().allocate<NodeIterator>(realm, root).release_allocated_value_but_fixme_should_propagate_errors();
auto iterator = MUST_OR_THROW_OOM(realm.heap().allocate<NodeIterator>(realm, root));
// 4. Set iterators whatToShow to whatToShow.
iterator->m_what_to_show = what_to_show;

View file

@ -16,7 +16,7 @@ class NodeIterator final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(NodeIterator, Bindings::PlatformObject);
public:
static JS::NonnullGCPtr<NodeIterator> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeIterator>> create(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
virtual ~NodeIterator() override;