Node.h 739 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <AK/Badge.h>
  3. #include <AK/RefPtr.h>
  4. #include <AK/Vector.h>
  5. #include <LibHTML/TreeNode.h>
  6. enum class NodeType : unsigned {
  7. INVALID = 0,
  8. ELEMENT_NODE = 1,
  9. TEXT_NODE = 3,
  10. DOCUMENT_NODE = 9,
  11. };
  12. class ParentNode;
  13. class Node : public TreeNode<Node> {
  14. public:
  15. virtual ~Node();
  16. NodeType type() const { return m_type; }
  17. bool is_element() const { return type() == NodeType::ELEMENT_NODE; }
  18. bool is_text() const { return type() == NodeType::TEXT_NODE; }
  19. bool is_document() const { return type() == NodeType::DOCUMENT_NODE; }
  20. bool is_parent_node() const { return is_element() || is_document(); }
  21. protected:
  22. explicit Node(NodeType);
  23. NodeType m_type { NodeType::INVALID };
  24. };