diff --git a/Libraries/LibHTML/TreeNode.h b/Libraries/LibHTML/TreeNode.h index 3adf8695f7e..229b07c4e2e 100644 --- a/Libraries/LibHTML/TreeNode.h +++ b/Libraries/LibHTML/TreeNode.h @@ -53,6 +53,15 @@ public: bool is_child_allowed(const T&) const { return true; } + template + void for_each_in_subtree(Callback callback) + { + callback(static_cast(*this)); + for (auto* child = first_child(); child; child = child->next_sibling()) { + child->for_each_in_subtree(callback); + } + } + protected: TreeNode() {}