1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibHTML: Create some subdirectories.

This commit is contained in:
Andreas Kling 2019-06-15 23:41:15 +02:00
parent 0522a8f71c
commit 1f51c2b7da
25 changed files with 49 additions and 50 deletions

40
LibHTML/DOM/ParentNode.h Normal file
View file

@ -0,0 +1,40 @@
#pragma once
#include <LibHTML/DOM/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; }
const Node* first_child() const { return m_first_child; }
const Node* last_child() const { return m_last_child; }
template<typename F> void for_each_child(F) const;
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 Callback>
inline void ParentNode::for_each_child(Callback callback) const
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}
template<typename Callback>
inline void ParentNode::for_each_child(Callback callback)
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}