diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-18 13:45:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-18 13:45:28 +0200 |
commit | 24162127ba373ed4d32fc83efa1f48c1a73f8332 (patch) | |
tree | bc889f35942d2c33571964d7892d1791bbc931e7 /Libraries | |
parent | b71c1851b781754f96ac77a2012af19ad5e5467b (diff) | |
download | serenity-24162127ba373ed4d32fc83efa1f48c1a73f8332.zip |
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.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibWeb/DOM/Document.h | 2 | ||||
-rw-r--r-- | Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 277e678b3c..0784e99ec5 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -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; diff --git a/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp index 2f204692b6..7de6600c8d 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp @@ -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(); |