LibWeb: Ignore HTML tasks enqueued in document used for fragment parsing

The inert temporary documents used for fragment parsing will never
become "fully active" and so any tasks associated with them will never
run. To avoid memory leaks, we now simply ignore any attempts to enqueue
tasks associated with such documents.
This commit is contained in:
Andreas Kling
2025-12-26 12:29:52 +01:00
committed by Andreas Kling
parent f12f72f139
commit 7bc07662be
Notes: github-actions[bot] 2025-12-27 15:42:23 +00:00

View File

@@ -1,10 +1,11 @@
/*
* Copyright (c) 2021-2024, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021-2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGC/RootVector.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/EventLoop/TaskQueue.h>
@@ -28,6 +29,11 @@ void TaskQueue::visit_edges(Visitor& visitor)
void TaskQueue::add(GC::Ref<Task> task)
{
// AD-HOC: Don't enqueue tasks for temporary (inert) documents used for fragment parsing.
// FIXME: There's ongoing spec work to remove such documents: https://github.com/whatwg/html/pull/11970
if (task->document() && task->document()->is_temporary_document_for_fragment_parsing())
return;
m_tasks.append(task);
m_event_loop->schedule();
}