LibWeb: Add GC finalizer for DOM::Node

Now that the layout tree is also GC-allocated, we can't be messing with
it from the DOM::Node destructor. Move everything to a GC finalizer
so we know it runs before the GC sweep phase.
This commit is contained in:
Andreas Kling 2022-10-20 19:30:29 +02:00
parent 07a36c8f80
commit c877eb47a2
2 changed files with 4 additions and 1 deletions

View file

@ -73,7 +73,9 @@ Node::Node(Document& document, NodeType type)
{
}
Node::~Node()
Node::~Node() = default;
void Node::finalize()
{
if (layout_node() && layout_node()->parent())
layout_node()->parent()->remove_child(*layout_node());

View file

@ -622,6 +622,7 @@ protected:
Node(Document&, NodeType);
virtual void visit_edges(Cell::Visitor&) override;
virtual void finalize() override;
JS::GCPtr<Document> m_document;
JS::GCPtr<Layout::Node> m_layout_node;