1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

LibWeb: Null layout and paintable pointers of removed DOM::Node

When a node is removed from the DOM tree, its paintable needs to be
removed to ensure that it is not used to obtain sizes that are no
longer valid.

This change enables the ResizeObserver to send a notification if a node
is removed, as it should, because a removed node now has a size of zero

It should be okay to nullify pointers without concerning
parent/sibling/child relationships because the layout and paintable
trees will be rebuilt following any DOM mutation anyway.
This commit is contained in:
Aliaksandr Kalenik 2024-02-19 02:22:15 +01:00 committed by Andreas Kling
parent 2b7e7cc1ad
commit 036cd9b2dd
6 changed files with 103 additions and 1 deletions

View file

@ -974,6 +974,12 @@ void Node::inserted()
set_needs_style_update(true);
}
void Node::removed_from(Node*)
{
m_layout_node = nullptr;
m_paintable = nullptr;
}
ParentNode* Node::parent_or_shadow_host()
{
if (is<ShadowRoot>(*this))