LibHTML+Browser: Add a simple DOM inspector popup window

LibHTML now provides a DOMTreeModel which can be used to view a given
Document's DOM tree. :^)
This commit is contained in:
Andreas Kling 2019-11-09 11:31:03 +01:00
parent 0f76366b34
commit e3d975e943
Notes: sideshowbarker 2024-07-19 11:18:57 +09:00
5 changed files with 188 additions and 0 deletions

View file

@ -45,6 +45,30 @@ public:
const T* first_child() const { return m_first_child; }
const T* last_child() const { return m_last_child; }
int child_count() const
{
int count = 0;
for (auto* child = first_child(); child; child = child->next_sibling())
++count;
return count;
}
T* child_at_index(int index)
{
int count = 0;
for (auto* child = first_child(); child; child = child->next_sibling()) {
if (count == index)
return child;
++count;
}
return nullptr;
}
const T* child_at_index(int index) const
{
return const_cast<TreeNode*>(this)->child_at_index(index);
}
bool is_ancestor_of(const TreeNode&) const;
void prepend_child(NonnullRefPtr<T> node, bool call_inserted_into = true);