mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 18:35:07 +00:00
LibHTML: Add TreeNode::for_each_in_subtree_of_type<T>()
This allows you to iterate a subtree and get a callback for every node where is<T>(node) == true. This makes for quite pleasant DOM traversal.
This commit is contained in:
parent
54bd322881
commit
1aea8f116b
5 changed files with 56 additions and 25 deletions
|
@ -74,9 +74,8 @@ RefPtr<LayoutNode> Node::create_layout_node(const StyleProperties*) const
|
|||
|
||||
void Node::invalidate_style()
|
||||
{
|
||||
for_each_in_subtree([&](auto& node) {
|
||||
if (is<Element>(node))
|
||||
node.set_needs_style_update(true);
|
||||
for_each_in_subtree_of_type<Element>([&](auto& element) {
|
||||
element.set_needs_style_update(true);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
document().schedule_style_update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue