1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:27:35 +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:
Andreas Kling 2020-10-11 21:52:59 +02:00
parent 99acbbe86b
commit f68ed6d25b
5 changed files with 45 additions and 11 deletions

View file

@ -77,6 +77,16 @@ Document::~Document()
{
}
void Document::removed_last_ref()
{
ASSERT(!ref_count());
if (m_referencing_node_count)
return;
delete this;
}
Origin Document::origin() const
{
if (!m_url.is_valid())