LibWeb: Make event dispatching spec-compliant

Specification: https://dom.spec.whatwg.org/#concept-event-dispatch

This also introduces shadow roots due to it being a requirement of
the event dispatcher.

However, it does not introduce the full shadow DOM, that can be
left for future work.

This changes some event dispatches which require certain attributes
to be initialised to a value.
This commit is contained in:
Luke 2020-11-21 18:32:39 +00:00 committed by Andreas Kling
parent 819f099a8e
commit e8b3a65581
Notes: sideshowbarker 2024-07-19 01:18:46 +09:00
32 changed files with 858 additions and 54 deletions

View file

@ -180,18 +180,22 @@ void HTMLDocumentParser::run(const URL& url)
script.execute_script();
}
m_document->dispatch_event(DOM::Event::create("DOMContentLoaded"));
// FIXME: These are not in the right place, they should only fire once subresources are ready.
m_document->dispatch_event(DOM::Event::create("load"));
m_document->window().dispatch_event(DOM::Event::create("load"));
auto content_loaded_event = DOM::Event::create("DOMContentLoaded");
content_loaded_event->set_bubbles(true);
m_document->dispatch_event(content_loaded_event);
auto scripts_to_execute_as_soon_as_possible = m_document->take_scripts_to_execute_as_soon_as_possible({});
for (auto& script : scripts_to_execute_as_soon_as_possible) {
script.execute_script();
}
// FIXME: Spin the event loop until there is nothing that delays the load event in the Document.
m_document->set_ready_state("complete");
m_document->window().dispatch_event(DOM::Event::create("load"));
m_document->set_ready_for_post_load_tasks(true);
m_document->completely_finish_loading();
}
void HTMLDocumentParser::process_using_the_rules_for(InsertionMode mode, HTMLToken& token)