mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Let HTML::EventLoop keep track of live DOM::Document objects
This will be used by the event loop processing model.
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 03:08:50 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ae71e5f99b5
@@ -8,6 +8,7 @@
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
@@ -242,4 +243,25 @@ void EventLoop::perform_a_microtask_checkpoint()
|
||||
m_performing_a_microtask_checkpoint = false;
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<DOM::Document> EventLoop::documents_in_this_event_loop() const
|
||||
{
|
||||
NonnullRefPtrVector<DOM::Document> documents;
|
||||
for (auto& document : m_documents) {
|
||||
VERIFY(document);
|
||||
documents.append(*document);
|
||||
}
|
||||
return documents;
|
||||
}
|
||||
|
||||
void EventLoop::register_document(Badge<DOM::Document>, DOM::Document& document)
|
||||
{
|
||||
m_documents.append(&document);
|
||||
}
|
||||
|
||||
void EventLoop::unregister_document(Badge<DOM::Document>, DOM::Document& document)
|
||||
{
|
||||
bool did_remove = m_documents.remove_first_matching([&](auto& entry) { return entry.ptr() == &document; });
|
||||
VERIFY(did_remove);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user