mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 13:18:19 +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: 247307a2a2
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)
|
void DocumentObserver::set_document_became_inactive(Function<void()> callback)
|
||||||
{
|
{
|
||||||
|
if (callback)
|
||||||
m_document_became_inactive = JS::create_heap_function(vm().heap(), move(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)
|
void DocumentObserver::set_document_completely_loaded(Function<void()> callback)
|
||||||
{
|
{
|
||||||
|
if (callback)
|
||||||
m_document_completely_loaded = JS::create_heap_function(vm().heap(), move(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)
|
void DocumentObserver::set_document_readiness_observer(Function<void(HTML::DocumentReadyState)> callback)
|
||||||
{
|
{
|
||||||
|
if (callback)
|
||||||
m_document_readiness_observer = JS::create_heap_function(vm().heap(), move(callback));
|
m_document_readiness_observer = JS::create_heap_function(vm().heap(), move(callback));
|
||||||
|
else
|
||||||
|
m_document_readiness_observer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue