mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 01:25:09 +00:00
LibWeb: Make DOM Nodes keep their Document alive
In addition to being reference-counted, all nodes that are part of a document must also keep the document alive. This is achieved by adding a second ref-count to the Document object and incrementing/decrementing it whenever a node is created/destroyed in that document. This brings us much closer to a proper DOM lifetime model, although the JS bindings still need more work.
This commit is contained in:
parent
99acbbe86b
commit
f68ed6d25b
5 changed files with 45 additions and 11 deletions
|
@ -206,4 +206,13 @@ Bindings::EventTargetWrapper* Node::create_wrapper(JS::GlobalObject& global_obje
|
|||
return wrap(global_object, *this);
|
||||
}
|
||||
|
||||
void Node::removed_last_ref()
|
||||
{
|
||||
if (is<Document>(*this)) {
|
||||
downcast<Document>(*this).removed_last_ref();
|
||||
return;
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue