Skip to content

Commit a20951f

Browse files
AtkinsSJkalenikaliaksandr
authored andcommitted
LibWeb: Support making a document active after it has completely loaded
So far, we always call make_active() before update_readiness (Complete), but this will soon not be the case once we implement the spec document-loading algorithms. Co-authored-by: Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
1 parent ad8ccd4 commit a20951f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Userland/Libraries/LibWeb/DOM/Document.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,9 +1934,13 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value)
19341934
// 4. Fire an event named readystatechange at document.
19351935
dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange));
19361936

1937-
if (readiness_value == HTML::DocumentReadyState::Complete && is_active() && navigable()->is_traversable()) {
1938-
HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors();
1939-
navigable()->traversable_navigable()->page().client().page_did_finish_loading(url());
1937+
if (readiness_value == HTML::DocumentReadyState::Complete) {
1938+
if (navigable() && navigable()->is_traversable()) {
1939+
HTML::HTMLLinkElement::load_fallback_favicon_if_needed(*this).release_value_but_fixme_should_propagate_errors();
1940+
navigable()->traversable_navigable()->page().client().page_did_finish_loading(url());
1941+
} else {
1942+
m_needs_to_call_page_did_load = true;
1943+
}
19401944
}
19411945
}
19421946

@@ -3093,6 +3097,11 @@ void Document::make_active()
30933097

30943098
// 4. Set window's relevant settings object's execution ready flag.
30953099
HTML::relevant_settings_object(window).execution_ready = true;
3100+
3101+
if (m_needs_to_call_page_did_load) {
3102+
navigable()->traversable_navigable()->page().client().page_did_finish_loading(url());
3103+
m_needs_to_call_page_did_load = false;
3104+
}
30963105
}
30973106

30983107
HTML::ListOfAvailableImages& Document::list_of_available_images()

Userland/Libraries/LibWeb/DOM/Document.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ class Document
767767

768768
// https://www.w3.org/TR/web-animations-1/#pending-animation-event-queue
769769
Vector<PendingAnimationEvent> m_pending_animation_event_queue;
770+
771+
bool m_needs_to_call_page_did_load { false };
770772
};
771773

772774
template<>

0 commit comments

Comments
 (0)