mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-31 13:48:25 +00:00
LibWeb: Return a representation of an 'Agent' in 'relevant agent'
This makes it more convenient to use the 'relvant agent' concept, instead of the awkward dynamic casts we needed to do for every call site. mutation_observers is also changed to hold a GC::Root instead of raw GC::Ptr. Somehow this was not causing problems before, but trips up CI after these changes.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <LibWeb/Bindings/MutationObserverPrototype.h>
|
||||
#include <LibWeb/DOM/MutationObserver.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/HTML/Scripting/Agent.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
@@ -29,14 +30,12 @@ MutationObserver::MutationObserver(JS::Realm& realm, GC::Ptr<WebIDL::CallbackTyp
|
||||
// 1. Set this’s callback to callback.
|
||||
|
||||
// 2. Append this to this’s relevant agent’s mutation observers.
|
||||
auto* agent_custom_data = verify_cast<Bindings::WebEngineCustomData>(realm.vm().custom_data());
|
||||
agent_custom_data->mutation_observers.append(*this);
|
||||
HTML::relevant_agent(*this).mutation_observers.append(*this);
|
||||
}
|
||||
|
||||
MutationObserver::~MutationObserver()
|
||||
{
|
||||
auto* agent_custom_data = verify_cast<Bindings::WebEngineCustomData>(vm().custom_data());
|
||||
agent_custom_data->mutation_observers.remove_all_matching([this](auto& observer) {
|
||||
HTML::relevant_agent(*this).mutation_observers.remove_all_matching([this](auto& observer) {
|
||||
return observer.ptr() == this;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user