ladybird/Libraries/LibWeb/DOM/DocumentLoadEventDelayer.h
Aliaksandr Kalenik 00562d53e5 LibWeb: Save weak pointer to document in DocumentLoadEventDelayer
This prevents GC leaks caused by a DocumentLoadEventDelayer that is
never destroyed (for example, when its Document becomes inactive) from
holding a strong reference to the Document and keeping it alive.
2025-12-24 10:19:28 +01:00

30 lines
585 B
C++

/*
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <LibGC/Weak.h>
#include <LibWeb/Forward.h>
namespace Web::DOM {
class DocumentLoadEventDelayer {
AK_MAKE_NONCOPYABLE(DocumentLoadEventDelayer);
public:
explicit DocumentLoadEventDelayer(Document&);
DocumentLoadEventDelayer(DocumentLoadEventDelayer&&);
DocumentLoadEventDelayer& operator=(DocumentLoadEventDelayer&&);
~DocumentLoadEventDelayer();
private:
GC::Weak<Document> m_document;
};
}