LibWeb: Remove uses of obsolete PlatformObject::global_object()

This API is a relic from the time when it was important for objects to
have easy access to the Window, and to know it was the global object.

We now have more spec-related concepts like relevant_global_object and
current_global_object to pull the Window out of thin air.
This commit is contained in:
Andrew Kaster 2024-09-04 19:22:48 -06:00 committed by Andreas Kling
commit 02a56f6480
Notes: github-actions[bot] 2024-09-07 09:40:02 +00:00
10 changed files with 36 additions and 28 deletions

View file

@ -3406,8 +3406,6 @@ void Document::set_browsing_context(HTML::BrowsingContext* browsing_context)
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#unload-a-document
void Document::unload(JS::GCPtr<Document>)
{
auto& vm = this->vm();
// FIXME: 1. Assert: this is running as part of a task queued on oldDocument's event loop.
// FIXME: 2. Let unloadTimingInfo be a new document unload timing info.
@ -3421,7 +3419,7 @@ void Document::unload(JS::GCPtr<Document>)
auto intend_to_store_in_bfcache = false;
// 6. Let eventLoop be oldDocument's relevant agent's event loop.
auto& event_loop = *verify_cast<Bindings::WebEngineCustomData>(*vm.custom_data()).event_loop;
auto& event_loop = *verify_cast<Bindings::WebEngineCustomData>(*HTML::relevant_agent(*this).custom_data()).event_loop;
// 7. Increase eventLoop's termination nesting level by 1.
event_loop.increment_termination_nesting_level();
@ -3455,7 +3453,7 @@ void Document::unload(JS::GCPtr<Document>)
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
// We should reorganize this so that the flag appears explicitly here instead.
auto event = DOM::Event::create(realm(), HTML::EventNames::unload);
global_object().dispatch_event(event);
verify_cast<HTML::Window>(relevant_global_object(*this)).dispatch_event(event);
}
// FIXME: 13. If unloadTimingInfo is not null, then set unloadTimingInfo's unload event end time to the current high resolution time given newDocument's relevant global object, coarsened