1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

LibWeb: Tear down old layout tree when new document becomes active

When a new document becomes the active document of a browsing context,
we now notify the old document, allowing it to tear down its layout
tree. In the future, there might be more cleanups we'd like to do here.
This commit is contained in:
Andreas Kling 2022-10-16 15:53:15 +02:00
parent 94f0c34dfe
commit dbee75af19
3 changed files with 12 additions and 0 deletions

View file

@ -295,6 +295,8 @@ bool BrowsingContext::is_focused_context() const
// https://html.spec.whatwg.org/multipage/browsers.html#set-the-active-document
void BrowsingContext::set_active_document(JS::NonnullGCPtr<DOM::Document> document)
{
auto previously_active_document = active_document();
// 1. Let window be document's relevant global object.
auto& window = verify_cast<HTML::Window>(relevant_global_object(document));
@ -315,6 +317,9 @@ void BrowsingContext::set_active_document(JS::NonnullGCPtr<DOM::Document> docume
if (m_page && is_top_level())
m_page->client().page_did_change_title(document->title());
if (previously_active_document && previously_active_document != document.ptr())
previously_active_document->did_stop_being_active_document_in_browsing_context({});
}
void BrowsingContext::set_viewport_rect(Gfx::IntRect const& rect)