mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 17:02:56 +00:00
LibWeb: Do not use JS::Handle for mutation observers
Using JS::Handle in WebEngineCustomData means that mutation observers will live as long as VM while actually they should be deallocated as soon as they are no longer used in a script that created them.
This commit is contained in:
parent
e7a3040c9f
commit
15629e8925
Notes:
sideshowbarker
2024-07-17 10:16:43 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 15629e8925
Pull-request: https://github.com/SerenityOS/serenity/pull/21242
2 changed files with 8 additions and 2 deletions
|
@ -29,7 +29,13 @@ MutationObserver::MutationObserver(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackT
|
|||
agent_custom_data->mutation_observers.append(*this);
|
||||
}
|
||||
|
||||
MutationObserver::~MutationObserver() = default;
|
||||
MutationObserver::~MutationObserver()
|
||||
{
|
||||
auto* agent_custom_data = verify_cast<Bindings::WebEngineCustomData>(vm().custom_data());
|
||||
agent_custom_data->mutation_observers.remove_all_matching([this](auto& observer) {
|
||||
return observer.ptr() == this;
|
||||
});
|
||||
}
|
||||
|
||||
void MutationObserver::initialize(JS::Realm& realm)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue