1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibHTML: Add basic <!DOCTYPE> parsing and a DocumentType class

Plus, Document::fixup() will now make sure that the document always
starts with a doctype node, followed by an <html> element.
This commit is contained in:
Andreas Kling 2019-10-09 20:17:01 +02:00
parent 850955053f
commit fc53867937
9 changed files with 84 additions and 6 deletions

View file

@ -33,6 +33,7 @@ public:
const T* first_child() const { return m_first_child; }
const T* last_child() const { return m_last_child; }
void prepend_child(NonnullRefPtr<T> node, bool call_inserted_into = true);
void append_child(NonnullRefPtr<T> node, bool call_inserted_into = true);
void donate_all_children_to(T& node);
@ -64,6 +65,22 @@ inline void TreeNode<T>::append_child(NonnullRefPtr<T> node, bool call_inserted_
(void)node.leak_ref();
}
template<typename T>
inline void TreeNode<T>::prepend_child(NonnullRefPtr<T> node, bool call_inserted_into)
{
ASSERT(!node->m_parent);
if (m_first_child)
m_first_child->m_previous_sibling = node.ptr();
node->m_next_sibling = m_first_child;
node->m_parent = static_cast<T*>(this);
m_first_child = node.ptr();
if (!m_last_child)
m_last_child = m_first_child;
if (call_inserted_into)
node->inserted_into(static_cast<T&>(*this));
(void)node.leak_ref();
}
template<typename T>
inline void TreeNode<T>::donate_all_children_to(T& node)
{