1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:27:44 +00:00

LibWeb: Port DOMEventListener to new FlyString

This commit is contained in:
Kenneth Myhra 2023-04-09 10:13:46 +02:00 committed by Linus Groh
parent 2091a11488
commit fdd33d818c
3 changed files with 7 additions and 7 deletions

View file

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <AK/DeprecatedFlyString.h> #include <AK/FlyString.h>
#include <LibJS/Heap/GCPtr.h> #include <LibJS/Heap/GCPtr.h>
#include <LibJS/Runtime/Object.h> #include <LibJS/Runtime/Object.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
@ -21,7 +21,7 @@ public:
~DOMEventListener(); ~DOMEventListener();
// type (a string) // type (a string)
DeprecatedFlyString type; FlyString type;
// callback (null or an EventListener object) // callback (null or an EventListener object)
JS::GCPtr<IDLEventListener> callback; JS::GCPtr<IDLEventListener> callback;

View file

@ -63,7 +63,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent
continue; continue;
// 1. If events type attribute value is not listeners type, then continue. // 1. If events type attribute value is not listeners type, then continue.
if (event.type().to_deprecated_fly_string() != listener->type) if (event.type() != listener->type)
continue; continue;
// 2. Set found to true. // 2. Set found to true.

View file

@ -129,7 +129,7 @@ void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* ca
// once is once, and signal is signal. // once is once, and signal is signal.
auto event_listener = heap().allocate_without_realm<DOMEventListener>(); auto event_listener = heap().allocate_without_realm<DOMEventListener>();
event_listener->type = type.to_deprecated_fly_string(); event_listener->type = type;
event_listener->callback = callback; event_listener->callback = callback;
event_listener->signal = move(flattened_options.signal); event_listener->signal = move(flattened_options.signal);
event_listener->capture = flattened_options.capture; event_listener->capture = flattened_options.capture;
@ -194,7 +194,7 @@ void EventTarget::remove_event_listener(FlyString const& type, IDLEventListener*
return entry.callback->callback().callback == callback->callback().callback; return entry.callback->callback().callback == callback->callback().callback;
}; };
auto it = m_event_listener_list.find_if([&](auto& entry) { auto it = m_event_listener_list.find_if([&](auto& entry) {
return entry->type == type.to_deprecated_fly_string() return entry->type == type
&& callbacks_match(*entry) && callbacks_match(*entry)
&& entry->capture == capture; && entry->capture == capture;
}); });
@ -560,7 +560,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
// 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback. // 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback.
auto listener = realm.heap().allocate_without_realm<DOMEventListener>(); auto listener = realm.heap().allocate_without_realm<DOMEventListener>();
listener->type = name.to_deprecated_fly_string(); listener->type = name;
listener->callback = IDLEventListener::create(realm, *callback).release_value_but_fixme_should_propagate_errors(); listener->callback = IDLEventListener::create(realm, *callback).release_value_but_fixme_should_propagate_errors();
// 6. Add an event listener with eventTarget and listener. // 6. Add an event listener with eventTarget and listener.
@ -738,7 +738,7 @@ bool EventTarget::dispatch_event(Event& event)
bool EventTarget::has_event_listener(FlyString const& type) const bool EventTarget::has_event_listener(FlyString const& type) const
{ {
for (auto& listener : m_event_listener_list) { for (auto& listener : m_event_listener_list) {
if (listener->type == type.to_deprecated_fly_string()) if (listener->type == type)
return true; return true;
} }
return false; return false;