mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:15:06 +00:00
LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
This commit is contained in:
parent
bb547ce1c4
commit
6f433c8656
445 changed files with 4797 additions and 4268 deletions
|
@ -141,12 +141,12 @@ void EventLoop::process()
|
|||
// - Any Document B whose browsing context's container document is A must be listed after A in the list.
|
||||
// - If there are two documents A and B whose browsing contexts are both child browsing contexts whose container documents are another Document C, then the order of A and B in the list must match the shadow-including tree order of their respective browsing context containers in C's node tree.
|
||||
// FIXME: NOTE: The sort order specified above is missing here!
|
||||
NonnullRefPtrVector<DOM::Document> docs = documents_in_this_event_loop();
|
||||
Vector<JS::Handle<DOM::Document>> docs = documents_in_this_event_loop();
|
||||
|
||||
auto for_each_fully_active_document_in_docs = [&](auto&& callback) {
|
||||
for (auto& document : docs) {
|
||||
if (document.is_fully_active())
|
||||
callback(document);
|
||||
if (document->is_fully_active())
|
||||
callback(*document);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -215,7 +215,7 @@ void EventLoop::process()
|
|||
// 3. For each win of the same-loop windows for this event loop,
|
||||
// perform the start an idle period algorithm for win with computeDeadline. [REQUESTIDLECALLBACK]
|
||||
for (auto& win : same_loop_windows())
|
||||
win.start_an_idle_period();
|
||||
win->start_an_idle_period();
|
||||
}
|
||||
|
||||
// FIXME: 14. If this is a worker event loop, then:
|
||||
|
@ -248,8 +248,8 @@ void queue_global_task(HTML::Task::Source source, JS::Object& global_object, Fun
|
|||
|
||||
// 2. Let document be global's associated Document, if global is a Window object; otherwise null.
|
||||
DOM::Document* document { nullptr };
|
||||
if (is<Bindings::WindowObject>(global_object)) {
|
||||
auto& window_object = verify_cast<Bindings::WindowObject>(global_object);
|
||||
if (is<HTML::Window>(global_object)) {
|
||||
auto& window_object = verify_cast<HTML::Window>(global_object);
|
||||
document = &window_object.impl().associated_document();
|
||||
}
|
||||
|
||||
|
@ -320,12 +320,12 @@ void EventLoop::perform_a_microtask_checkpoint()
|
|||
m_performing_a_microtask_checkpoint = false;
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<DOM::Document> EventLoop::documents_in_this_event_loop() const
|
||||
Vector<JS::Handle<DOM::Document>> EventLoop::documents_in_this_event_loop() const
|
||||
{
|
||||
NonnullRefPtrVector<DOM::Document> documents;
|
||||
Vector<JS::Handle<DOM::Document>> documents;
|
||||
for (auto& document : m_documents) {
|
||||
VERIFY(document);
|
||||
documents.append(*document);
|
||||
documents.append(JS::make_handle(*document.ptr()));
|
||||
}
|
||||
return documents;
|
||||
}
|
||||
|
@ -368,11 +368,11 @@ void EventLoop::unregister_environment_settings_object(Badge<EnvironmentSettings
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#same-loop-windows
|
||||
NonnullRefPtrVector<Window> EventLoop::same_loop_windows() const
|
||||
Vector<JS::Handle<HTML::Window>> EventLoop::same_loop_windows() const
|
||||
{
|
||||
NonnullRefPtrVector<Window> windows;
|
||||
Vector<JS::Handle<HTML::Window>> windows;
|
||||
for (auto& document : documents_in_this_event_loop())
|
||||
windows.append(document.window());
|
||||
windows.append(JS::make_handle(document->window()));
|
||||
return windows;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ double EventLoop::compute_deadline() const
|
|||
// 1. If windowInSameLoop's map of animation frame callbacks is not empty,
|
||||
// or if the user agent believes that the windowInSameLoop might have pending rendering updates,
|
||||
// set hasPendingRenders to true.
|
||||
if (window.has_animation_frame_callbacks())
|
||||
if (window->has_animation_frame_callbacks())
|
||||
has_pending_renders = true;
|
||||
// FIXME: 2. Let timerCallbackEstimates be the result of getting the values of windowInSameLoop's map of active timers.
|
||||
// FIXME: 3. For each timeoutDeadline of timerCallbackEstimates, if timeoutDeadline is less than deadline, set deadline to timeoutDeadline.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue