LibWeb: Add Node.insertBefore(Node node, Node? child)

This commit is contained in:
Andreas Kling 2020-06-21 16:45:21 +02:00
commit 213e2793bd
Notes: sideshowbarker 2024-07-19 05:28:34 +09:00
4 changed files with 43 additions and 0 deletions

View file

@ -200,4 +200,16 @@ RefPtr<Node> Node::append_child(NonnullRefPtr<Node> node, bool notify)
return node;
}
RefPtr<Node> Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool notify)
{
if (!child)
return append_child(move(node), notify);
if (child->parent_node() != this) {
dbg() << "FIXME: Trying to insert_before() a bogus child";
return nullptr;
}
TreeNode<Node>::insert_before(node, child, notify);
return node;
}
}