mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:18:13 +00:00
LibWeb: Port DOMEventListener to new FlyString
This commit is contained in:
parent
2091a11488
commit
fdd33d818c
3 changed files with 7 additions and 7 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
~DOMEventListener();
|
||||
|
||||
// type (a string)
|
||||
DeprecatedFlyString type;
|
||||
FlyString type;
|
||||
|
||||
// callback (null or an EventListener object)
|
||||
JS::GCPtr<IDLEventListener> callback;
|
||||
|
|
|
@ -63,7 +63,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent
|
|||
continue;
|
||||
|
||||
// 1. If event’s type attribute value is not listener’s type, then continue.
|
||||
if (event.type().to_deprecated_fly_string() != listener->type)
|
||||
if (event.type() != listener->type)
|
||||
continue;
|
||||
|
||||
// 2. Set found to true.
|
||||
|
|
|
@ -129,7 +129,7 @@ void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* ca
|
|||
// once is once, and signal is signal.
|
||||
|
||||
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->signal = move(flattened_options.signal);
|
||||
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;
|
||||
};
|
||||
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)
|
||||
&& 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.
|
||||
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();
|
||||
|
||||
// 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
|
||||
{
|
||||
for (auto& listener : m_event_listener_list) {
|
||||
if (listener->type == type.to_deprecated_fly_string())
|
||||
if (listener->type == type)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue