mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibWeb: Allow removing DocumentObserver hooks
Some callers (namely WebDriver) will want to stop receiving updates from the DocumentObserver.
This commit is contained in:
parent
0bbe836f8c
commit
247307a2a2
Notes:
github-actions[bot]
2024-10-26 09:27:04 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/247307a2a28 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1967
1 changed files with 12 additions and 3 deletions
|
@ -36,17 +36,26 @@ void DocumentObserver::finalize()
|
|||
|
||||
void DocumentObserver::set_document_became_inactive(Function<void()> callback)
|
||||
{
|
||||
m_document_became_inactive = JS::create_heap_function(vm().heap(), move(callback));
|
||||
if (callback)
|
||||
m_document_became_inactive = JS::create_heap_function(vm().heap(), move(callback));
|
||||
else
|
||||
m_document_became_inactive = nullptr;
|
||||
}
|
||||
|
||||
void DocumentObserver::set_document_completely_loaded(Function<void()> callback)
|
||||
{
|
||||
m_document_completely_loaded = JS::create_heap_function(vm().heap(), move(callback));
|
||||
if (callback)
|
||||
m_document_completely_loaded = JS::create_heap_function(vm().heap(), move(callback));
|
||||
else
|
||||
m_document_completely_loaded = nullptr;
|
||||
}
|
||||
|
||||
void DocumentObserver::set_document_readiness_observer(Function<void(HTML::DocumentReadyState)> callback)
|
||||
{
|
||||
m_document_readiness_observer = JS::create_heap_function(vm().heap(), move(callback));
|
||||
if (callback)
|
||||
m_document_readiness_observer = JS::create_heap_function(vm().heap(), move(callback));
|
||||
else
|
||||
m_document_readiness_observer = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue