mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
LibWeb: Make factory method of DOM::NodeIterator fallible
This commit is contained in:
parent
0791195843
commit
d94b59263e
3 changed files with 4 additions and 4 deletions
|
@ -1947,7 +1947,7 @@ WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_nam
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
|
// 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)
|
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
|
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||||
|
|
|
@ -47,13 +47,13 @@ void NodeIterator::visit_edges(Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
|
// 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.
|
// 1. Let iterator be a new NodeIterator object.
|
||||||
// 2. Set iterator’s root and iterator’s reference to root.
|
// 2. Set iterator’s root and iterator’s reference to root.
|
||||||
// 3. Set iterator’s pointer before reference to true.
|
// 3. Set iterator’s pointer before reference to true.
|
||||||
auto& realm = root.realm();
|
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 iterator’s whatToShow to whatToShow.
|
// 4. Set iterator’s whatToShow to whatToShow.
|
||||||
iterator->m_what_to_show = what_to_show;
|
iterator->m_what_to_show = what_to_show;
|
||||||
|
|
|
@ -16,7 +16,7 @@ class NodeIterator final : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(NodeIterator, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(NodeIterator, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
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;
|
virtual ~NodeIterator() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue