Files
ladybird/LibHTML/ParentNode.h
Andreas Kling a67e823838 LibHTML: Start working on a simple HTML library.
I'd like to have rich text, and we might as well use HTML for that. :^)
2019-06-15 18:55:47 +02:00

33 lines
615 B
C++

#pragma once
#include <LibHTML/Node.h>
class ParentNode : public Node {
public:
void append_child(Retained<Node>);
Node* first_child() { return m_first_child; }
Node* last_child() { return m_last_child; }
template<typename F> void for_each_child(F);
protected:
explicit ParentNode(NodeType type)
: Node(type)
{
}
private:
Node* m_first_child { nullptr };
Node* m_last_child { nullptr };
};
template<typename F>
inline void ParentNode::for_each_child(F func)
{
for (auto* node = first_child(); node; node = node->next_sibling()) {
func(*node);
}
}