mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +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
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/HTMLTemplateElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/XML/XMLDocumentBuilder.h>
|
||||
|
@ -160,22 +161,22 @@ void XMLDocumentBuilder::document_end()
|
|||
// Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing has its "ready to be parser-executed" flag set
|
||||
// and the parser's Document has no style sheet that is blocking scripts.
|
||||
HTML::main_thread_event_loop().spin_until([&] {
|
||||
return m_document.scripts_to_execute_when_parsing_has_finished().first().is_ready_to_be_parser_executed()
|
||||
return m_document.scripts_to_execute_when_parsing_has_finished().first()->is_ready_to_be_parser_executed()
|
||||
&& !m_document.has_a_style_sheet_that_is_blocking_scripts();
|
||||
});
|
||||
|
||||
// Execute the first script in the list of scripts that will execute when the document has finished parsing.
|
||||
m_document.scripts_to_execute_when_parsing_has_finished().first().execute_script();
|
||||
m_document.scripts_to_execute_when_parsing_has_finished().first()->execute_script();
|
||||
|
||||
// Remove the first script element from the list of scripts that will execute when the document has finished parsing (i.e. shift out the first entry in the list).
|
||||
(void)m_document.scripts_to_execute_when_parsing_has_finished().take_first();
|
||||
}
|
||||
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = NonnullRefPtr(m_document)]() mutable {
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = JS::make_handle(m_document)]() mutable {
|
||||
// FIXME: Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||
|
||||
// Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
||||
auto content_loaded_event = DOM::Event::create(document->preferred_window_object(), HTML::EventNames::DOMContentLoaded);
|
||||
auto content_loaded_event = DOM::Event::create(document->window(), HTML::EventNames::DOMContentLoaded);
|
||||
content_loaded_event->set_bubbles(true);
|
||||
document->dispatch_event(*content_loaded_event);
|
||||
|
||||
|
@ -197,7 +198,7 @@ void XMLDocumentBuilder::document_end()
|
|||
});
|
||||
|
||||
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = NonnullRefPtr(m_document)]() mutable {
|
||||
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = JS::make_handle(m_document)]() mutable {
|
||||
// Update the current document readiness to "complete".
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
|
||||
|
@ -206,14 +207,14 @@ void XMLDocumentBuilder::document_end()
|
|||
return;
|
||||
|
||||
// Let window be the Document's relevant global object.
|
||||
NonnullRefPtr<HTML::Window> window = document->window();
|
||||
JS::NonnullGCPtr<HTML::Window> window = document->window();
|
||||
|
||||
// FIXME: Set the Document's load timing info's load event start time to the current high resolution time given window.
|
||||
|
||||
// Fire an event named load at window, with legacy target override flag set.
|
||||
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
||||
// We should reorganize this so that the flag appears explicitly here instead.
|
||||
window->dispatch_event(*DOM::Event::create(document->preferred_window_object(), HTML::EventNames::load));
|
||||
window->dispatch_event(*DOM::Event::create(document->window(), HTML::EventNames::load));
|
||||
|
||||
// FIXME: Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue