summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/HTML
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2020-11-21 18:32:39 +0000
committerAndreas Kling <kling@serenityos.org>2020-11-22 18:20:56 +0100
commite8b3a6558191e97ffab28943865a9459f013969e (patch)
treed332303702f9ab31773668fac51b6b4a03dd4b47 /Libraries/LibWeb/HTML
parent819f099a8eb595689bc37933c10d2a4fdb7737b1 (diff)
downloadserenity-e8b3a6558191e97ffab28943865a9459f013969e.zip
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.
Diffstat (limited to 'Libraries/LibWeb/HTML')
-rw-r--r--Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
index 520d062fef..d4dddffc0b 100644
--- a/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
+++ b/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp
@@ -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)