mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Make factory method of DOM::TreeWalker fallible
This commit is contained in:
parent
251c063897
commit
552663a2ba
Notes:
sideshowbarker
2024-07-17 11:33:34 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/552663a2ba Pull-request: https://github.com/SerenityOS/serenity/pull/17491 Reviewed-by: https://github.com/linusg ✅
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user