mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibWeb/DOM: Create NodeIterator in document's realm
This commit is contained in:
parent
80e8313880
commit
84f22cb6b3
Notes:
github-actions[bot]
2025-01-10 08:10:02 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/84f22cb6b3a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3208 Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 10 additions and 11 deletions
|
@ -3336,7 +3336,7 @@ WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_nam
|
|||
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
|
||||
GC::Ref<NodeIterator> Document::create_node_iterator(Node& root, unsigned what_to_show, GC::Ptr<NodeFilter> filter)
|
||||
{
|
||||
return NodeIterator::create(root, what_to_show, filter).release_value_but_fixme_should_propagate_errors();
|
||||
return NodeIterator::create(realm(), root, what_to_show, filter).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace Web::DOM {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(NodeIterator);
|
||||
|
||||
NodeIterator::NodeIterator(Node& root)
|
||||
: PlatformObject(root.realm())
|
||||
NodeIterator::NodeIterator(JS::Realm& realm, Node& root)
|
||||
: PlatformObject(realm)
|
||||
, m_root(root)
|
||||
, m_reference({ root })
|
||||
{
|
||||
|
@ -48,13 +48,12 @@ void NodeIterator::visit_edges(Cell::Visitor& visitor)
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createnodeiterator
|
||||
WebIDL::ExceptionOr<GC::Ref<NodeIterator>> NodeIterator::create(Node& root, unsigned what_to_show, GC::Ptr<NodeFilter> filter)
|
||||
WebIDL::ExceptionOr<GC::Ref<NodeIterator>> NodeIterator::create(JS::Realm& realm, Node& root, unsigned what_to_show, GC::Ptr<NodeFilter> filter)
|
||||
{
|
||||
// 1. Let iterator be a new NodeIterator object.
|
||||
// 2. Set iterator’s root and iterator’s reference to root.
|
||||
// 3. Set iterator’s pointer before reference to true.
|
||||
auto& realm = root.realm();
|
||||
auto iterator = realm.create<NodeIterator>(root);
|
||||
auto iterator = realm.create<NodeIterator>(realm, root);
|
||||
|
||||
// 4. Set iterator’s whatToShow to whatToShow.
|
||||
iterator->m_what_to_show = what_to_show;
|
||||
|
|
|
@ -17,7 +17,7 @@ class NodeIterator final : public Bindings::PlatformObject {
|
|||
GC_DECLARE_ALLOCATOR(NodeIterator);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<NodeIterator>> create(Node& root, unsigned what_to_show, GC::Ptr<NodeFilter>);
|
||||
static WebIDL::ExceptionOr<GC::Ref<NodeIterator>> create(JS::Realm& realm, Node& root, unsigned what_to_show, GC::Ptr<NodeFilter>);
|
||||
|
||||
virtual ~NodeIterator() override;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
void run_pre_removing_steps(Node&);
|
||||
|
||||
private:
|
||||
explicit NodeIterator(Node& root);
|
||||
explicit NodeIterator(JS::Realm&, Node& root);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 33 tests
|
||||
|
||||
28 Pass
|
||||
5 Fail
|
||||
29 Pass
|
||||
4 Fail
|
||||
Pass querySelectorAll
|
||||
Pass createElement
|
||||
Pass createElementNS
|
||||
|
@ -15,7 +15,7 @@ Pass createAttribute
|
|||
Pass createAttributeNS
|
||||
Pass createEvent
|
||||
Pass createRange
|
||||
Fail createNodeIterator
|
||||
Pass createNodeIterator
|
||||
Fail createTreeWalker
|
||||
Pass Request
|
||||
Pass Response
|
||||
|
|
Loading…
Reference in a new issue