mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb/DOM: Support changing document to observe in DocumentObserver
This commit is contained in:
parent
0e74736a53
commit
3383a781f6
Notes:
github-actions[bot]
2025-06-24 07:57:45 +00:00
Author: https://github.com/shannonbooth
Commit: 3383a781f6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5153
Reviewed-by: https://github.com/gmta ✅
2 changed files with 14 additions and 3 deletions
|
@ -12,7 +12,7 @@ namespace Web::DOM {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(DocumentObserver);
|
||||
|
||||
DocumentObserver::DocumentObserver(JS::Realm& realm, DOM::Document& document)
|
||||
DocumentObserver::DocumentObserver(JS::Realm& realm, Document& document)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_document(document)
|
||||
{
|
||||
|
@ -37,6 +37,14 @@ void DocumentObserver::finalize()
|
|||
m_document->unregister_document_observer({}, *this);
|
||||
}
|
||||
|
||||
void DocumentObserver::set_document(GC::Ref<Document> document)
|
||||
{
|
||||
VERIFY(document != m_document);
|
||||
m_document->unregister_document_observer({}, *this);
|
||||
m_document = document;
|
||||
document->register_document_observer({}, *this);
|
||||
}
|
||||
|
||||
void DocumentObserver::set_document_became_active(Function<void()> callback)
|
||||
{
|
||||
if (callback)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue