LibWeb: Ensure DocumentObserver document_completely_loaded() is called

This stopped being called for anything without a navigable container
after 76a97d8, due to the early return. This broke SVG <use> elements
that reference elements defined later in the document.
This commit is contained in:
MacDue 2023-12-26 19:51:15 +00:00 committed by Andreas Kling
parent 785c9d5c2b
commit daecf741d4
3 changed files with 31 additions and 6 deletions

View file

@ -0,0 +1,11 @@
<!doctype html>
<svg style="display: none">
<symbol id="earlier-reference">
<rect x="0" y="0" width="64" height="64" fill="green" />
</symbol>
</svg>
<div>
<svg width="100" height="100">
<use xlink:href="#earlier-reference"></use>
</svg>
</div>

View file

@ -0,0 +1,12 @@
<!doctype html>
<link rel="match" href="reference/svg-use-defined-earlier.html" />
<div>
<svg width="100" height="100">
<use xlink:href="#later-reference"></use>
</svg>
</div>
<svg style="display: none">
<symbol id="later-reference">
<rect x="0" y="0" width="64" height="64" fill="green" />
</symbol>
</svg>

View file

@ -1974,6 +1974,14 @@ void Document::completely_finish_loading()
if (!navigable())
return;
ScopeGuard notify_observers = [this] {
auto observers_to_notify = m_document_observers.values();
for (auto& document_observer : observers_to_notify) {
if (document_observer->document_completely_loaded())
document_observer->document_completely_loaded()->function()();
}
};
// 1. Assert: document's browsing context is non-null.
VERIFY(browsing_context());
@ -2002,12 +2010,6 @@ void Document::completely_finish_loading()
container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load));
});
}
auto observers_to_notify = m_document_observers.values();
for (auto& document_observer : observers_to_notify) {
if (document_observer->document_completely_loaded())
document_observer->document_completely_loaded()->function()();
}
}
String Document::cookie(Cookie::Source source)