mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibHTML: Move is_ancestor_of() from LayoutNode to TreeNode
This way it becomes available to all the different TreeNode subclasses.
This commit is contained in:
parent
fdbad6284c
commit
159507f2a6
2 changed files with 13 additions and 11 deletions
|
@ -81,8 +81,6 @@ public:
|
||||||
|
|
||||||
void set_needs_display();
|
void set_needs_display();
|
||||||
|
|
||||||
bool is_ancestor_of(const LayoutNode&) const;
|
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_fragment_of_this(Callback);
|
void for_each_fragment_of_this(Callback);
|
||||||
|
|
||||||
|
@ -130,12 +128,3 @@ inline const LayoutNodeWithStyle* LayoutNode::parent() const
|
||||||
{
|
{
|
||||||
return static_cast<const LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent());
|
return static_cast<const LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool LayoutNode::is_ancestor_of(const LayoutNode& other) const
|
|
||||||
{
|
|
||||||
for (auto* ancestor = other.parent(); ancestor; ancestor = ancestor->parent()) {
|
|
||||||
if (ancestor == this)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
const T* first_child() const { return m_first_child; }
|
const T* first_child() const { return m_first_child; }
|
||||||
const T* last_child() const { return m_last_child; }
|
const T* last_child() const { return m_last_child; }
|
||||||
|
|
||||||
|
bool is_ancestor_of(const TreeNode&) const;
|
||||||
|
|
||||||
void prepend_child(NonnullRefPtr<T> node, bool call_inserted_into = true);
|
void prepend_child(NonnullRefPtr<T> node, bool call_inserted_into = true);
|
||||||
void append_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);
|
void donate_all_children_to(T& node);
|
||||||
|
@ -98,3 +100,14 @@ inline void TreeNode<T>::donate_all_children_to(T& node)
|
||||||
m_first_child = nullptr;
|
m_first_child = nullptr;
|
||||||
m_last_child = nullptr;
|
m_last_child = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline bool TreeNode<T>::is_ancestor_of(const TreeNode<T>& other) const
|
||||||
|
{
|
||||||
|
for (auto* ancestor = other.parent(); ancestor; ancestor = ancestor->parent()) {
|
||||||
|
if (ancestor == this)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue