LibWeb: Don't visit DocumentShadowRootList from Document

`ShadowRoot` register itself in Document` from constructor and
unregister itself from `finalize()`. The problem is that `finalize()`
won't be invoked for as long as `ShadowRoot` is visited by
`Document`, leading to GC leaks.
This commit is contained in:
Aliaksandr Kalenik 2025-07-29 23:41:39 +02:00 committed by Andreas Kling
parent 52b4f2a40a
commit 40fd2643cc
2 changed files with 2 additions and 3 deletions

View File

@ -605,9 +605,6 @@ void Document::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_adopted_style_sheets);
visitor.visit(m_script_blocking_style_sheet_set);
for (auto& shadow_root : m_shadow_roots)
visitor.visit(shadow_root);
visitor.visit(m_top_layer_elements);
visitor.visit(m_top_layer_pending_removals);
visitor.visit(m_showing_auto_popover_list);

View File

@ -1200,6 +1200,8 @@ private:
mutable GC::Ptr<WebIDL::ObservableArray> m_adopted_style_sheets;
// Document should not visit ShadowRoot list to avoid leaks.
// It's responsibility of object that allocated ShadowRoot to keep it alive.
ShadowRoot::DocumentShadowRootList m_shadow_roots;
Optional<AK::UnixDateTime> m_last_modified;