mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
LibWeb: Implement more of "completely finish loading the document"
This commit is contained in:
parent
bfec16ce46
commit
5f4a723e51
3 changed files with 44 additions and 2 deletions
|
@ -42,6 +42,7 @@
|
||||||
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
#include <LibWeb/HTML/HTMLFrameSetElement.h>
|
||||||
#include <LibWeb/HTML/HTMLHeadElement.h>
|
#include <LibWeb/HTML/HTMLHeadElement.h>
|
||||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||||
|
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||||
#include <LibWeb/HTML/HTMLTitleElement.h>
|
#include <LibWeb/HTML/HTMLTitleElement.h>
|
||||||
|
@ -920,10 +921,29 @@ EventTarget* Document::get_parent(const Event& event)
|
||||||
return &window();
|
return &window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#completely-finish-loading
|
||||||
void Document::completely_finish_loading()
|
void Document::completely_finish_loading()
|
||||||
{
|
{
|
||||||
// FIXME: This needs to handle iframes.
|
// 1. Assert: document's browsing context is non-null.
|
||||||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
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)
|
String Document::cookie(Cookie::Source source)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||||
#include <LibWeb/Layout/FrameBox.h>
|
#include <LibWeb/Layout/FrameBox.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
|
@ -63,4 +64,23 @@ void HTMLIFrameElement::load_src(const String& value)
|
||||||
m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame);
|
m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-load-event-steps
|
||||||
|
void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
|
||||||
|
{
|
||||||
|
// 1. Assert: element's nested browsing context is not null.
|
||||||
|
VERIFY(element.nested_browsing_context());
|
||||||
|
|
||||||
|
// 2. Let childDocument be the active document of element's nested browsing context.
|
||||||
|
[[maybe_unused]] auto* child_document = element.nested_browsing_context()->active_document();
|
||||||
|
|
||||||
|
// FIXME: 3. If childDocument has its mute iframe load flag set, then return.
|
||||||
|
|
||||||
|
// FIXME: 4. Set childDocument's iframe load in progress flag.
|
||||||
|
|
||||||
|
// 5. Fire an event named load at element.
|
||||||
|
element.dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||||
|
|
||||||
|
// FIXME: 6. Unset childDocument's iframe load in progress flag.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,4 +26,6 @@ private:
|
||||||
void load_src(const String&);
|
void load_src(const String&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue