mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 13:19:47 +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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user