mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
LibWeb: Expose ParentNode.{first,last}ElementChild
I needed these to write the event dispatcher test.
This commit is contained in:
parent
e8b3a65581
commit
c5e15d9282
6 changed files with 41 additions and 1 deletions
|
@ -255,6 +255,12 @@ public:
|
|||
return const_cast<TreeNode*>(this)->template first_child_of_type<U>();
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
const U* last_child_of_type() const
|
||||
{
|
||||
return const_cast<TreeNode*>(this)->template last_child_of_type<U>();
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
U* first_child_of_type()
|
||||
{
|
||||
|
@ -265,6 +271,16 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
U* last_child_of_type()
|
||||
{
|
||||
for (auto* child = last_child(); child; child = child->previous_sibling()) {
|
||||
if (is<U>(*child))
|
||||
return &downcast<U>(*child);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
const U* first_ancestor_of_type() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue