ParentNode.h 689 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <LibHTML/DOM/Node.h>
  3. class ParentNode : public Node {
  4. public:
  5. template<typename F> void for_each_child(F) const;
  6. template<typename F> void for_each_child(F);
  7. protected:
  8. explicit ParentNode(Document& document, NodeType type)
  9. : Node(document, type)
  10. {
  11. }
  12. };
  13. template<typename Callback>
  14. inline void ParentNode::for_each_child(Callback callback) const
  15. {
  16. for (auto* node = first_child(); node; node = node->next_sibling())
  17. callback(*node);
  18. }
  19. template<typename Callback>
  20. inline void ParentNode::for_each_child(Callback callback)
  21. {
  22. for (auto* node = first_child(); node; node = node->next_sibling())
  23. callback(*node);
  24. }