mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibWeb: Move tree iteration helpers from Node/LayoutNode to TreeNode
Since these are generally useful in our trees, let's just keep them in TreeNode instead of duplicating the helpers in subclasses.
This commit is contained in:
@@ -106,12 +106,6 @@ public:
|
||||
Element* parent_element();
|
||||
const Element* parent_element() const;
|
||||
|
||||
template<typename T>
|
||||
const T* first_child_of_type() const;
|
||||
|
||||
template<typename T>
|
||||
const T* first_ancestor_of_type() const;
|
||||
|
||||
virtual void inserted_into(Node&) { }
|
||||
virtual void removed_from(Node&) { }
|
||||
virtual void children_changed() { }
|
||||
@@ -144,24 +138,4 @@ protected:
|
||||
bool m_needs_style_update { true };
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline const T* Node::first_child_of_type() const
|
||||
{
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<T>(*child))
|
||||
return downcast<T>(child);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline const T* Node::first_ancestor_of_type() const
|
||||
{
|
||||
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
if (is<T>(*ancestor))
|
||||
return downcast<T>(ancestor);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user