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

LibHTML: Add Document::normalize()

This method wraps the document tree in <html> and <body> elements if needed.
This commit is contained in:
Sergey Bugaev 2019-09-25 12:26:26 +03:00 committed by Andreas Kling
parent 599edba7a3
commit c1ef63379c
3 changed files with 36 additions and 0 deletions

View file

@ -34,6 +34,7 @@ public:
const T* last_child() const { return m_last_child; }
void append_child(NonnullRefPtr<T> node);
void donate_all_children_to(T& node);
protected:
TreeNode() { }
@ -59,3 +60,21 @@ inline void TreeNode<T>::append_child(NonnullRefPtr<T> node)
if (!m_first_child)
m_first_child = m_last_child;
}
template<typename T>
inline void TreeNode<T>::donate_all_children_to(T& node)
{
for (T* child = m_first_child; child != nullptr;) {
T* next_child = child->m_next_sibling;
child->m_parent = nullptr;
child->m_next_sibling = nullptr;
child->m_previous_sibling = nullptr;
node.append_child(adopt(*child));
child = next_child;
}
m_first_child = nullptr;
m_last_child = nullptr;
}