summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp13
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h6
2 files changed, 16 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 5630e0657c..64fbe989af 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -1454,24 +1454,31 @@ EventTarget* Document::get_parent(Event const& event)
return &window();
}
+// https://html.spec.whatwg.org/#completely-loaded
+bool Document::is_completely_loaded() const
+{
+ return m_completely_loaded_time.has_value();
+}
+
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#completely-finish-loading
void Document::completely_finish_loading()
{
// 1. Assert: document's browsing context is non-null.
VERIFY(browsing_context());
- // FIXME: 2. Set document's completely loaded time to the current time.
+ // 2. Set document's completely loaded time to the current time.
+ m_completely_loaded_time = AK::Time::now_realtime();
// 3. Let container be document's browsing context's container.
auto container = JS::make_handle(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.
+ // 4. 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.
+ // 5. 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(container->window(), HTML::EventNames::load));
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index d7ae532478..b75c00a624 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -365,6 +365,9 @@ public:
auto& pending_scroll_event_targets() { return m_pending_scroll_event_targets; }
auto& pending_scrollend_event_targets() { return m_pending_scrollend_event_targets; }
+ // https://html.spec.whatwg.org/#completely-loaded
+ bool is_completely_loaded() const;
+
protected:
virtual void visit_edges(Cell::Visitor&) override;
@@ -496,6 +499,9 @@ private:
JS::GCPtr<HTMLCollection> m_forms;
JS::GCPtr<HTMLCollection> m_scripts;
JS::GCPtr<HTMLCollection> m_all;
+
+ // https://html.spec.whatwg.org/#completely-loaded-time
+ Optional<AK::Time> m_completely_loaded_time;
};
}