mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibWeb: Allow Document::ref() when ref-count is zero
DOM::Document has some special lifetime rules to support the DOM lifetime semantics expected on the web. Any DOM node will keep its document alive as well, even after the document's ref-count has reached zero. This is achieved by the Document::m_referencing_node_count counter. Because of this mechanism, we can't VERIFY(m_ref_count) in TreeNode where T may be a DOM::Document.
This commit is contained in:
parent
bbfde63f79
commit
6f0d7245d7
1 changed files with 4 additions and 1 deletions
|
@ -20,7 +20,10 @@ public:
|
|||
void ref()
|
||||
{
|
||||
VERIFY(!m_in_removed_last_ref);
|
||||
VERIFY(m_ref_count);
|
||||
if constexpr (!IsBaseOf<DOM::Node, T>) {
|
||||
// NOTE: DOM::Document is allowed to survive with 0 ref count, if one of its descendant nodes are alive.
|
||||
VERIFY(m_ref_count);
|
||||
}
|
||||
++m_ref_count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue