mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Add NonDocumentTypeChildNode::next_element_in_pre_order()
This is handy for traversing only the elements in a document.
This commit is contained in:
parent
a37331e236
commit
7698feb8ce
Notes:
sideshowbarker
2024-07-19 03:38:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7698feb8ce0
1 changed files with 10 additions and 0 deletions
|
@ -53,8 +53,18 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Element* next_element_in_pre_order()
|
||||
{
|
||||
for (auto* node = static_cast<NodeType*>(this)->next_in_pre_order(); node; node = node->next_in_pre_order()) {
|
||||
if (is<Element>(*node))
|
||||
return downcast<Element>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Element* previous_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->previous_element_sibling(); }
|
||||
const Element* next_element_sibling() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_sibling(); }
|
||||
const Element* next_element_in_pre_order() const { return const_cast<NonDocumentTypeChildNode*>(this)->next_element_in_pre_order(); }
|
||||
|
||||
protected:
|
||||
NonDocumentTypeChildNode() { }
|
||||
|
|
Loading…
Add table
Reference in a new issue