mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 02:26:11 +00:00
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:
parent
785c9d5c2b
commit
daecf741d4
11
Tests/LibWeb/Ref/reference/svg-use-defined-earlier.html
Normal file
11
Tests/LibWeb/Ref/reference/svg-use-defined-earlier.html
Normal 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>
|
12
Tests/LibWeb/Ref/svg-use-defined-later.html
Normal file
12
Tests/LibWeb/Ref/svg-use-defined-later.html
Normal 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>
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue