LibWeb: Dispatch "load" on document and window

These happen right after "DOMContentLoaded" for now, which is incorrect
since they should really wait until subresources have loaded.
However, this makes a bunch of things work already so let's do it.
This commit is contained in:
Andreas Kling 2020-10-18 13:45:28 +02:00
parent b71c1851b7
commit 24162127ba
Notes: sideshowbarker 2024-07-19 01:51:49 +09:00
2 changed files with 7 additions and 0 deletions

View file

@ -193,6 +193,8 @@ public:
void removed_last_ref();
Window& window() { return *m_window; }
private:
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;

View file

@ -33,6 +33,7 @@
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/DOM/Window.h>
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
@ -165,6 +166,10 @@ void HTMLDocumentParser::run(const URL& url)
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 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();