1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibWeb: Add support for DOM's TreeWalker

This patch adds TreeWalker (created via Document.createTreeWalker())
which allows you to traverse a filtered view of the DOM in all
directions.
This commit is contained in:
Andreas Kling 2022-03-09 14:37:48 +01:00
parent fabcee016f
commit acbdb95b0a
9 changed files with 487 additions and 0 deletions

View file

@ -35,6 +35,7 @@
#include <LibWeb/DOM/Range.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/DOM/TreeWalker.h>
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/BrowsingContext.h>
@ -1467,4 +1468,10 @@ NonnullRefPtr<NodeIterator> Document::create_node_iterator(Node& root, unsigned
return NodeIterator::create(root, what_to_show, move(filter));
}
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
NonnullRefPtr<TreeWalker> Document::create_tree_walker(Node& root, unsigned what_to_show, RefPtr<NodeFilter> filter)
{
return TreeWalker::create(root, what_to_show, move(filter));
}
}