mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:35:09 +00:00
LibWeb: Use smart pointers between DOM and Layout tree
DOM::Node now points to its LayoutNode with a WeakPtr. LayoutNode points to its DOM::Node and DOM::Document with RefPtrs. Layout trees come and go in response to various events, so the DOM tree already has to deal with that. The DOM should always live at least as long as the layout tree, so this patch enforces that assumption by making layout nodes keep their corresponding DOM objects alive. This may not be optimal, but it removes a lot of ambiguous raw pointer action which is not worth accomodating.
This commit is contained in:
parent
a316ca0e0d
commit
385d744989
3 changed files with 12 additions and 4 deletions
|
@ -217,4 +217,12 @@ void Node::removed_last_ref()
|
|||
delete this;
|
||||
}
|
||||
|
||||
void Node::set_layout_node(Badge<LayoutNode>, LayoutNode* layout_node) const
|
||||
{
|
||||
if (layout_node)
|
||||
m_layout_node = layout_node->make_weak_ptr();
|
||||
else
|
||||
m_layout_node = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue