mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +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
Notes:
sideshowbarker
2024-07-18 03:08:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6f0d7245d75
|
@ -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…
Reference in a new issue