1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:08:13 +00:00

LibWeb: Implement more of "completely finish loading the document"

This commit is contained in:
Andreas Kling 2021-09-26 02:25:02 +02:00
parent bfec16ce46
commit 5f4a723e51
3 changed files with 44 additions and 2 deletions

View file

@ -42,6 +42,7 @@
#include <LibWeb/HTML/HTMLFrameSetElement.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
#include <LibWeb/HTML/HTMLTitleElement.h>
@ -920,10 +921,29 @@ EventTarget* Document::get_parent(const Event& event)
return &window();
}
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#completely-finish-loading
void Document::completely_finish_loading()
{
// FIXME: This needs to handle iframes.
dispatch_event(DOM::Event::create(HTML::EventNames::load));
// 1. Assert: document's browsing context is non-null.
VERIFY(browsing_context());
// FIXME: 2. Set document's completely loaded time to the current time.
// 3. Let container be document's browsing context's container.
auto* container = browsing_context()->container();
// If container is an iframe element, then queue an element task on the DOM manipulation task source given container to run the iframe load event steps given container.
if (container && is<HTML::HTMLIFrameElement>(*container)) {
container->queue_an_element_task(HTML::Task::Source::DOMManipulation, [container]() mutable {
run_iframe_load_event_steps(static_cast<HTML::HTMLIFrameElement&>(*container));
});
}
// Otherwise, if container is non-null, then queue an element task on the DOM manipulation task source given container to fire an event named load at container.
else if (container) {
container->queue_an_element_task(HTML::Task::Source::DOMManipulation, [container]() mutable {
container->dispatch_event(DOM::Event::create(HTML::EventNames::load));
});
}
}
String Document::cookie(Cookie::Source source)