mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
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.
30 lines
585 B
C++
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;
|
|
};
|
|
|
|
}
|