ladybird/Libraries/LibHTML/DOM/CharacterData.h
Andreas Kling b083a233d8 LibHTML: Add Comment and CharacterData nodes and improve HTML parsing
This patch adds the CharacterData subclass of Node, which is now the
parent class of Text and a new Comment class.

A Comment node is one of these in HTML: <!--hello friends-->
Since these occur somewhat frequently on the web, we need to be able
to parse them.

This patch also adds a child rejection mechanism to the DOM tree.
Nodes can now override is_child_allowed(Node) and return false if they
don't want a particular Node to become a child of theirs. This is used
to prevent Document from taking on unwanted children.
2019-10-12 23:34:05 +02:00

25 lines
480 B
C++

#pragma once
#include <AK/String.h>
#include <LibHTML/DOM/Node.h>
class CharacterData : public Node {
public:
virtual ~CharacterData() override;
const String& data() const { return m_data; }
virtual String text_content() const override { return m_data; }
protected:
explicit CharacterData(Document&, NodeType, const String&);
private:
String m_data;
};
template<>
inline bool is<CharacterData>(const Node& node)
{
return node.is_character_data();
}