LibWeb: Iterate safely in process_top_layer_removals()

We should not remove from a container while iterating over it, since
that may disrupt iteration.
This commit is contained in:
Andreas Kling 2025-05-28 11:22:30 +02:00 committed by Alexander Kalenik
commit 2afe208328
Notes: github-actions[bot] 2025-05-29 01:48:24 +00:00

View file

@ -6122,13 +6122,18 @@ void Document::process_top_layer_removals()
{
// 1. For each element el in docs pending top layer removals: if els computed value of overlay is none, or el is
// not rendered, remove el from docs top layer and pending top layer removals.
GC::RootVector<GC::Ref<Element>> elements_to_remove(heap());
for (auto& element : m_top_layer_pending_removals) {
// FIXME: Implement overlay property
if (true || !element->paintable()) {
m_top_layer_elements.remove(element);
m_top_layer_pending_removals.remove(element);
elements_to_remove.append(element);
}
}
for (auto& element : elements_to_remove) {
m_top_layer_elements.remove(element);
m_top_layer_pending_removals.remove(element);
}
}
// https://html.spec.whatwg.org/multipage/popover.html#topmost-auto-popover