mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
LibWeb: Add an interface to be notified of Document state changes
Some HTML elements, e.g. HTMLMediaElement, need to take action when the document becomes inactive.
This commit is contained in:
committed by
Andreas Kling
parent
88b8969443
commit
f78eadf00f
Notes:
sideshowbarker
2024-07-16 20:42:33 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/f78eadf00f Pull-request: https://github.com/SerenityOS/serenity/pull/18638 Reviewed-by: https://github.com/awesomekling
32
Userland/Libraries/LibWeb/DOM/DocumentObserver.cpp
Normal file
32
Userland/Libraries/LibWeb/DOM/DocumentObserver.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/DocumentObserver.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
DocumentObserver::DocumentObserver(JS::Realm& realm, DOM::Document& document)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_document(document)
|
||||
{
|
||||
m_document->register_document_observer({}, *this);
|
||||
}
|
||||
|
||||
void DocumentObserver::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_document);
|
||||
}
|
||||
|
||||
void DocumentObserver::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
m_document->unregister_document_observer({}, *this);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user