summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-04-06 07:25:18 +0200
committerLinus Groh <mail@linusgroh.de>2023-04-06 23:49:08 +0200
commit4d87072201efc4ef9086588255fbb1bb993872ab (patch)
treeeacc0403ddd251ada971e7809d0b530239feb7b3
parentd6cf9f53297a8fe2e8455b0502cd458cd42ba12d (diff)
downloadserenity-4d87072201efc4ef9086588255fbb1bb993872ab.zip
LibWeb: Port {HTML,UIEvents,XHR}::EventNames to new String
-rw-r--r--Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp4
-rw-r--r--Userland/Libraries/LibWeb/DOM/AbortSignal.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp24
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventTarget.cpp50
-rw-r--r--Userland/Libraries/LibWeb/DOM/EventTarget.h8
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/EventNames.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/EventNames.h4
-rw-r--r--Userland/Libraries/LibWeb/HTML/Focus.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLElement.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp14
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp4
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp6
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp10
-rw-r--r--Userland/Libraries/LibWeb/HTML/MessagePort.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp6
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Worker.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp18
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/EventNames.cpp4
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/EventNames.h4
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp3
-rw-r--r--Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp10
-rw-r--r--Userland/Libraries/LibWeb/XHR/EventNames.cpp4
-rw-r--r--Userland/Libraries/LibWeb/XHR/EventNames.h4
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp52
-rw-r--r--Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp6
42 files changed, 149 insertions, 142 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
index b21f308834..42ba6efe14 100644
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
@@ -167,7 +167,7 @@ ErrorOr<void> initialize_main_thread_vm()
/* .promise = */ promise,
/* .reason = */ promise.result(),
};
- auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), String::from_deprecated_string(HTML::EventNames::rejectionhandled).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors();
+ auto promise_rejection_event = HTML::PromiseRejectionEvent::create(HTML::relevant_realm(global), HTML::EventNames::rejectionhandled, event_init).release_value_but_fixme_should_propagate_errors();
window.dispatch_event(promise_rejection_event);
});
break;
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
index eaa1c51281..dc3f261517 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
@@ -79,7 +79,7 @@ void MediaQueryList::add_listener(DOM::IDLEventListener* listener)
// callback set to listener, and capture set to false, unless there already is an event listener
// in that list with the same type, callback, and capture.
// (NOTE: capture is set to false by default)
- add_event_listener_without_options(HTML::EventNames::change, *listener);
+ add_event_listener_without_options(HTML::EventNames::change.to_deprecated_fly_string(), *listener);
}
// https://www.w3.org/TR/cssom-view/#dom-mediaquerylist-removelistener
@@ -88,7 +88,7 @@ void MediaQueryList::remove_listener(DOM::IDLEventListener* listener)
// 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
// NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
// This means if an event listener removes another event listener that comes after it, the removed event listener will not be invoked.
- remove_event_listener_without_options(HTML::EventNames::change, *listener);
+ remove_event_listener_without_options(HTML::EventNames::change.to_deprecated_fly_string(), *listener);
}
void MediaQueryList::set_onchange(WebIDL::CallbackType* event_handler)
diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp
index d8a20f599a..dd1b07f255 100644
--- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp
+++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp
@@ -62,7 +62,7 @@ void AbortSignal::signal_abort(JS::Value reason)
m_abort_algorithms.clear();
// 5. Fire an event named abort at signal.
- dispatch_event(Event::create(realm(), HTML::EventNames::abort).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(Event::create(realm(), HTML::EventNames::abort.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
void AbortSignal::set_onabort(WebIDL::CallbackType* event_handler)
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index c89e93f199..eec643d26a 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -1010,7 +1010,7 @@ void Document::set_hovered_node(Node* node)
// FIXME: Check if we need to dispatch these events in a specific order.
for (auto target = old_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
// FIXME: Populate the event with mouse coordinates, etc.
- target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave).release_value_but_fixme_should_propagate_errors());
+ target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseleave.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
}
@@ -1019,7 +1019,7 @@ void Document::set_hovered_node(Node* node)
// FIXME: Check if we need to dispatch these events in a specific order.
for (auto target = m_hovered_node; target && target.ptr() != common_ancestor; target = target->parent()) {
// FIXME: Populate the event with mouse coordinates, etc.
- target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter).release_value_but_fixme_should_propagate_errors());
+ target->dispatch_event(UIEvents::MouseEvent::create(realm(), UIEvents::EventNames::mouseenter.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
}
}
@@ -1589,7 +1589,7 @@ void Document::update_readiness(HTML::DocumentReadyState readiness_value)
}
// 4. Fire an event named readystatechange at document.
- dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(Event::create(realm(), HTML::EventNames::readystatechange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
Page* Document::page()
@@ -1604,7 +1604,7 @@ Page const* Document::page() const
EventTarget* Document::get_parent(Event const& event)
{
- if (event.type() == HTML::EventNames::load)
+ if (event.type() == HTML::EventNames::load.to_deprecated_fly_string())
return nullptr;
return m_window;
@@ -1637,7 +1637,7 @@ void Document::completely_finish_loading()
// 5. Otherwise, if container is non-null, then queue an element task on the DOM manipulation task source given container to fire an event named load at container.
else if (container) {
container->queue_an_element_task(HTML::Task::Source::DOMManipulation, [container] {
- container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ container->dispatch_event(DOM::Event::create(container->realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
}
}
@@ -1767,7 +1767,7 @@ void Document::update_the_visibility_state(HTML::VisibilityState visibility_stat
// FIXME: 3. Run any page visibility change steps which may be defined in other specifications, with visibility state and document.
// 4. Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.
- auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange).release_value_but_fixme_should_propagate_errors();
+ auto event = DOM::Event::create(realm(), HTML::EventNames::visibilitychange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
event->set_bubbles(true);
dispatch_event(event);
}
@@ -1788,7 +1788,7 @@ void Document::run_the_resize_steps()
return;
m_last_viewport_size = viewport_size;
- window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize).release_value_but_fixme_should_propagate_errors());
+ window().dispatch_event(DOM::Event::create(realm(), UIEvents::EventNames::resize.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
schedule_layout_update();
}
@@ -1800,14 +1800,14 @@ void Document::run_the_scroll_steps()
for (auto& target : m_pending_scroll_event_targets) {
// 1. If target is a Document, fire an event named scroll that bubbles at target and fire an event named scroll at the VisualViewport that is associated with target.
if (is<Document>(*target)) {
- auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors();
+ auto event = DOM::Event::create(realm(), HTML::EventNames::scroll.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
event->set_bubbles(true);
target->dispatch_event(event);
// FIXME: Fire at the associated VisualViewport
}
// 2. Otherwise, fire an event named scroll at target.
else {
- auto event = DOM::Event::create(realm(), HTML::EventNames::scroll).release_value_but_fixme_should_propagate_errors();
+ auto event = DOM::Event::create(realm(), HTML::EventNames::scroll.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
target->dispatch_event(event);
}
}
@@ -1847,7 +1847,7 @@ void Document::evaluate_media_queries_and_report_changes()
CSS::MediaQueryListEventInit init;
init.media = String::from_deprecated_string(media_query_list->media()).release_value_but_fixme_should_propagate_errors();
init.matches = now_matches;
- auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change, init).release_value_but_fixme_should_propagate_errors();
+ auto event = CSS::MediaQueryListEvent::create(realm(), HTML::EventNames::change.to_deprecated_fly_string(), init).release_value_but_fixme_should_propagate_errors();
event->set_is_trusted(true);
media_query_list->dispatch_event(*event);
}
@@ -2327,7 +2327,7 @@ void Document::unload(bool recursive_flag, Optional<DocumentUnloadTimingInfo> un
m_page_showing = false;
// 2. Fire a page transition event named pagehide at document's relevant global object with document's salvageable state.
- global_object().fire_a_page_transition_event(HTML::EventNames::pagehide, m_salvageable);
+ global_object().fire_a_page_transition_event(HTML::EventNames::pagehide.to_deprecated_fly_string(), m_salvageable);
// 3. Update the visibility state of newDocument to "hidden".
update_the_visibility_state(HTML::VisibilityState::Hidden);
@@ -2347,7 +2347,7 @@ void Document::unload(bool recursive_flag, Optional<DocumentUnloadTimingInfo> un
// then fire an event named unload at document's relevant global object, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
// We should reorganize this so that the flag appears explicitly here instead.
- auto event = DOM::Event::create(realm(), HTML::EventNames::unload).release_value_but_fixme_should_propagate_errors();
+ auto event = DOM::Event::create(realm(), HTML::EventNames::unload.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
global_object().dispatch_event(event);
}
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index 7014e93a40..2a74504b0a 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -470,7 +470,7 @@ private:
Document(JS::Realm&, AK::URL const&);
// ^HTML::GlobalEventHandlers
- virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const&) final { return *this; }
+ virtual EventTarget& global_event_handlers_to_event_target(FlyString const&) final { return *this; }
void tear_down_layout_tree();
diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
index f4ad3377b1..1f887cc596 100644
--- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -235,7 +235,7 @@ bool EventDispatcher::dispatch(JS::NonnullGCPtr<EventTarget> target, Event& even
event.append_to_path(*target, target_override, related_target, touch_targets, false);
// 4. Let isActivationEvent be true, if event is a MouseEvent object and event’s type attribute is "click"; otherwise false.
- bool is_activation_event = is<UIEvents::MouseEvent>(event) && event.type() == HTML::EventNames::click;
+ bool is_activation_event = is<UIEvents::MouseEvent>(event) && FlyString::from_deprecated_fly_string(event.type()).release_value() == HTML::EventNames::click;
// 5. If isActivationEvent is true and target has activation behavior, then set activationTarget to target.
if (is_activation_event && target->activation_behavior)
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp
index 42915736db..5f9c2962c4 100644
--- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp
+++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp
@@ -241,7 +241,7 @@ WebIDL::ExceptionOr<bool> EventTarget::dispatch_event_binding(Event& event)
}
// https://html.spec.whatwg.org/multipage/webappapis.html#window-reflecting-body-element-event-handler-set
-bool is_window_reflecting_body_element_event_handler(DeprecatedFlyString const& name)
+bool is_window_reflecting_body_element_event_handler(FlyString const& name)
{
return name.is_one_of(
HTML::EventNames::blur,
@@ -253,7 +253,7 @@ bool is_window_reflecting_body_element_event_handler(DeprecatedFlyString const&
}
// https://html.spec.whatwg.org/multipage/webappapis.html#windoweventhandlers
-static bool is_window_event_handler(DeprecatedFlyString const& name)
+static bool is_window_event_handler(FlyString const& name)
{
return name.is_one_of(
HTML::EventNames::afterprint,
@@ -288,7 +288,8 @@ static EventTarget* determine_target_of_event_handler(EventTarget& event_target,
// 2. If name is not the name of an attribute member of the WindowEventHandlers interface mixin and the Window-reflecting
// body element event handler set does not contain name, then return eventTarget.
- if (!is_window_event_handler(name) && !is_window_reflecting_body_element_event_handler(name))
+ auto new_string_name = FlyString::from_deprecated_fly_string(name).release_value();
+ if (!is_window_event_handler(new_string_name) && !is_window_reflecting_body_element_event_handler(new_string_name))
return &event_target;
// 3. If eventTarget's node document is not an active document, then return null.
@@ -300,17 +301,19 @@ static EventTarget* determine_target_of_event_handler(EventTarget& event_target,
}
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-2
-WebIDL::CallbackType* EventTarget::event_handler_attribute(DeprecatedFlyString const& name)
+WebIDL::CallbackType* EventTarget::event_handler_attribute(FlyString const& name)
{
+ auto deprecated_name = name.to_deprecated_fly_string();
+
// 1. Let eventTarget be the result of determining the target of an event handler given this object and name.
- auto target = determine_target_of_event_handler(*this, name);
+ auto target = determine_target_of_event_handler(*this, deprecated_name);
// 2. If eventTarget is null, then return null.
if (!target)
return nullptr;
// 3. Return the result of getting the current value of the event handler given eventTarget and name.
- return target->get_current_value_of_event_handler(name);
+ return target->get_current_value_of_event_handler(deprecated_name);
}
// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
@@ -376,7 +379,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(Deprecated
StringBuilder builder;
// sourceText
- if (name == HTML::EventNames::error && is<HTML::Window>(this)) {
+ if (name == HTML::EventNames::error.to_deprecated_fly_string() && is<HTML::Window>(this)) {
// -> If name is onerror and eventTarget is a Window object
// The string formed by concatenating "function ", name, "(event, source, lineno, colno, error) {", U+000A LF, body, U+000A LF, and "}".
builder.appendff("function {}(event, source, lineno, colno, error) {{\n{}\n}}", name, body);
@@ -473,10 +476,11 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(Deprecated
}
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-3
-void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, WebIDL::CallbackType* value)
+void EventTarget::set_event_handler_attribute(FlyString const& name, WebIDL::CallbackType* value)
{
+ auto deprecated_name = name.to_deprecated_fly_string();
// 1. Let eventTarget be the result of determining the target of an event handler given this object and name.
- auto event_target = determine_target_of_event_handler(*this, name);
+ auto event_target = determine_target_of_event_handler(*this, deprecated_name);
// 2. If eventTarget is null, then return.
if (!event_target)
@@ -484,7 +488,7 @@ void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, W
// 3. If the given value is null, then deactivate an event handler given eventTarget and name.
if (!value) {
- event_target->deactivate_event_handler(name);
+ event_target->deactivate_event_handler(deprecated_name);
return;
}
@@ -493,7 +497,7 @@ void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, W
auto& handler_map = event_target->m_event_handler_map;
// 2. Let eventHandler be handlerMap[name].
- auto event_handler_iterator = handler_map.find(name);
+ auto event_handler_iterator = handler_map.find(deprecated_name);
// 3. Set eventHandler's value to the given value.
if (event_handler_iterator == handler_map.end()) {
@@ -504,9 +508,9 @@ void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, W
// Optimization: We pass in the event handler here instead of having activate_event_handler do another hash map lookup just to get the same object.
// This handles a new event handler while the other path handles an existing event handler. As such, both paths must have their own
// unique call to activate_event_handler.
- event_target->activate_event_handler(name, *new_event_handler);
+ event_target->activate_event_handler(deprecated_name, *new_event_handler);
- handler_map.set(name, new_event_handler);
+ handler_map.set(deprecated_name, new_event_handler);
return;
}
@@ -516,7 +520,7 @@ void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, W
// 4. Activate an event handler given eventTarget and name.
// NOTE: See the optimization comment above.
- event_target->activate_event_handler(name, *event_handler);
+ event_target->activate_event_handler(deprecated_name, *event_handler);
}
// https://html.spec.whatwg.org/multipage/webappapis.html#activate-an-event-handler
@@ -612,7 +616,7 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(Depreca
// 3. Let special error event handling be true if event is an ErrorEvent object, event's type is error, and event's currentTarget implements the WindowOrWorkerGlobalScope mixin.
// Otherwise, let special error event handling be false.
// FIXME: This doesn't check for WorkerGlobalScape as we don't currently have it.
- bool special_error_event_handling = is<HTML::ErrorEvent>(event) && event.type() == HTML::EventNames::error && is<HTML::Window>(event.current_target().ptr());
+ bool special_error_event_handling = is<HTML::ErrorEvent>(event) && event.type() == HTML::EventNames::error.to_deprecated_fly_string() && is<HTML::Window>(event.current_target().ptr());
// 4. Process the Event object event as follows:
JS::Completion return_value_or_error;
@@ -679,13 +683,15 @@ JS::ThrowCompletionOr<void> EventTarget::process_event_handler_for_event(Depreca
}
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:concept-element-attributes-change-ext
-void EventTarget::element_event_handler_attribute_changed(DeprecatedFlyString const& local_name, DeprecatedString const& value)
+void EventTarget::element_event_handler_attribute_changed(FlyString const& local_name, DeprecatedString const& value)
{
// NOTE: Step 1 of this algorithm was handled in HTMLElement::parse_attribute.
+ auto deprecated_local_name = local_name.to_deprecated_fly_string();
+
// 2. Let eventTarget be the result of determining the target of an event handler given element and localName.
// NOTE: element is `this`.
- auto* event_target = determine_target_of_event_handler(*this, local_name);
+ auto* event_target = determine_target_of_event_handler(*this, deprecated_local_name);
// 3. If eventTarget is null, then return.
if (!event_target)
@@ -693,7 +699,7 @@ void EventTarget::element_event_handler_attribute_changed(DeprecatedFlyString co
// 4. If value is null, then deactivate an event handler given eventTarget and localName.
if (value.is_null()) {
- event_target->deactivate_event_handler(local_name);
+ event_target->deactivate_event_handler(deprecated_local_name);
return;
}
@@ -704,7 +710,7 @@ void EventTarget::element_event_handler_attribute_changed(DeprecatedFlyString co
auto& handler_map = event_target->m_event_handler_map;
// 3. Let eventHandler be handlerMap[localName].
- auto event_handler_iterator = handler_map.find(local_name);
+ auto event_handler_iterator = handler_map.find(deprecated_local_name);
// FIXME: 4. Let location be the script location that triggered the execution of these steps.
@@ -717,9 +723,9 @@ void EventTarget::element_event_handler_attribute_changed(DeprecatedFlyString co
auto new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(value);
// 6. Activate an event handler given eventTarget and name.
- event_target->activate_event_handler(local_name, *new_event_handler);
+ event_target->activate_event_handler(deprecated_local_name, *new_event_handler);
- handler_map.set(local_name, new_event_handler);
+ handler_map.set(deprecated_local_name, new_event_handler);
return;
}
@@ -727,7 +733,7 @@ void EventTarget::element_event_handler_attribute_changed(DeprecatedFlyString co
// 6. Activate an event handler given eventTarget and name.
event_handler->value = value;
- event_target->activate_event_handler(local_name, *event_handler);
+ event_target->activate_event_handler(deprecated_local_name, *event_handler);
}
bool EventTarget::dispatch_event(Event& event)
diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h
index 5077c92ef7..eeb21d038a 100644
--- a/Userland/Libraries/LibWeb/DOM/EventTarget.h
+++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h
@@ -51,8 +51,8 @@ public:
virtual void legacy_cancelled_activation_behavior() { }
virtual void legacy_cancelled_activation_behavior_was_not_called() { }
- WebIDL::CallbackType* event_handler_attribute(DeprecatedFlyString const& name);
- void set_event_handler_attribute(DeprecatedFlyString const& name, WebIDL::CallbackType*);
+ WebIDL::CallbackType* event_handler_attribute(FlyString const& name);
+ void set_event_handler_attribute(FlyString const& name, WebIDL::CallbackType*);
bool has_event_listener(DeprecatedFlyString const& type) const;
bool has_event_listeners() const;
@@ -60,7 +60,7 @@ public:
protected:
explicit EventTarget(JS::Realm&);
- void element_event_handler_attribute_changed(DeprecatedFlyString const& local_name, DeprecatedString const& value);
+ void element_event_handler_attribute_changed(FlyString const& local_name, DeprecatedString const& value);
virtual void visit_edges(Cell::Visitor&) override;
@@ -77,6 +77,6 @@ private:
JS::ThrowCompletionOr<void> process_event_handler_for_event(DeprecatedFlyString const& name, Event& event);
};
-bool is_window_reflecting_body_element_event_handler(DeprecatedFlyString const& name);
+bool is_window_reflecting_body_element_event_handler(FlyString const& name);
}
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 53b3aa1f4a..08550c544e 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -1125,7 +1125,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_ind
// 4. Fire a page transition event named pageshow at newDocument's relevant global object with true.
auto& window = verify_cast<HTML::Window>(relevant_global_object(*new_document));
- window.fire_a_page_transition_event(HTML::EventNames::pageshow, true);
+ window.fire_a_page_transition_event(HTML::EventNames::pageshow.to_deprecated_fly_string(), true);
});
}
@@ -1187,7 +1187,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_ind
// and the newURL attribute initialized to newURL.
// FIXME: Implement a proper HashChangeEvent class.
- auto event = DOM::Event::create(verify_cast<HTML::Window>(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange).release_value_but_fixme_should_propagate_errors();
+ auto event = DOM::Event::create(verify_cast<HTML::Window>(relevant_global_object(*new_document)).realm(), HTML::EventNames::hashchange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
new_document->dispatch_event(event);
});
}
diff --git a/Userland/Libraries/LibWeb/HTML/EventNames.cpp b/Userland/Libraries/LibWeb/HTML/EventNames.cpp
index 2824b90778..8f819ac1b1 100644
--- a/Userland/Libraries/LibWeb/HTML/EventNames.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventNames.cpp
@@ -8,7 +8,7 @@
namespace Web::HTML::EventNames {
-#define __ENUMERATE_HTML_EVENT(name) DeprecatedFlyString name;
+#define __ENUMERATE_HTML_EVENT(name) FlyString name;
ENUMERATE_HTML_EVENTS
#undef __ENUMERATE_HTML_EVENT
@@ -18,7 +18,7 @@ ErrorOr<void> initialize_strings()
VERIFY(!s_initialized);
#define __ENUMERATE_HTML_EVENT(name) \
- name = #name;
+ name = TRY(#name##_fly_string);
ENUMERATE_HTML_EVENTS
#undef __ENUMERATE_HTML_EVENT
diff --git a/Userland/Libraries/LibWeb/HTML/EventNames.h b/Userland/Libraries/LibWeb/HTML/EventNames.h
index bc8d14b676..8af301336f 100644
--- a/Userland/Libraries/LibWeb/HTML/EventNames.h
+++ b/Userland/Libraries/LibWeb/HTML/EventNames.h
@@ -6,8 +6,8 @@
#pragma once
-#include <AK/DeprecatedFlyString.h>
#include <AK/Error.h>
+#include <AK/FlyString.h>
namespace Web::HTML::EventNames {
@@ -95,7 +95,7 @@ namespace Web::HTML::EventNames {
__ENUMERATE_HTML_EVENT(webkitanimationstart) \
__ENUMERATE_HTML_EVENT(webkittransitionend)
-#define __ENUMERATE_HTML_EVENT(name) extern DeprecatedFlyString name;
+#define __ENUMERATE_HTML_EVENT(name) extern FlyString name;
ENUMERATE_HTML_EVENTS
#undef __ENUMERATE_HTML_EVENT
diff --git a/Userland/Libraries/LibWeb/HTML/Focus.cpp b/Userland/Libraries/LibWeb/HTML/Focus.cpp
index 337b898f8c..e6010392d8 100644
--- a/Userland/Libraries/LibWeb/HTML/Focus.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Focus.cpp
@@ -65,7 +65,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// with related blur target as the related target.
if (blur_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
- auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur).release_value_but_fixme_should_propagate_errors();
+ auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
blur_event->set_related_target(related_blur_target);
blur_event_target->dispatch_event(blur_event);
}
@@ -108,7 +108,7 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
// with related focus target as the related target.
if (focus_event_target) {
// FIXME: Implement the "fire a focus event" spec operation.
- auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus).release_value_but_fixme_should_propagate_errors();
+ auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
focus_event->set_related_target(related_focus_target);
focus_event_target->dispatch_event(focus_event);
}
diff --git a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp
index 22e7e9c4cc..1f5aa3a1ef 100644
--- a/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp
+++ b/Userland/Libraries/LibWeb/HTML/FormControlInfrastructure.cpp
@@ -165,7 +165,7 @@ WebIDL::ExceptionOr<Optional<Vector<XHR::FormDataEntry>>> construct_entry_list(J
// 7. Fire an event named formdata at form using FormDataEvent, with the formData attribute initialized to form data and the bubbles attribute initialized to true.
FormDataEventInit init {};
init.form_data = form_data;
- auto form_data_event = TRY(FormDataEvent::construct_impl(realm, String::from_deprecated_string(HTML::EventNames::formdata).release_value_but_fixme_should_propagate_errors(), init));
+ auto form_data_event = TRY(FormDataEvent::construct_impl(realm, HTML::EventNames::formdata, init));
form_data_event->set_bubbles(true);
form.dispatch_event(form_data_event);
diff --git a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.h b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.h
index 3f1ad6b4ea..21a53d1f30 100644
--- a/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.h
+++ b/Userland/Libraries/LibWeb/HTML/GlobalEventHandlers.h
@@ -91,7 +91,7 @@ public:
#undef __ENUMERATE
protected:
- virtual DOM::EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) = 0;
+ virtual DOM::EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) = 0;
};
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
index 32aaf20490..6e27e575a5 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
@@ -79,7 +79,7 @@ void HTMLBodyElement::parse_attribute(DeprecatedFlyString const& name, Deprecate
#undef __ENUMERATE
}
-DOM::EventTarget& HTMLBodyElement::global_event_handlers_to_event_target(DeprecatedFlyString const& event_name)
+DOM::EventTarget& HTMLBodyElement::global_event_handlers_to_event_target(FlyString const& event_name)
{
// NOTE: This is a little weird, but IIUC document.body.onload actually refers to window.onload
// NOTE: document.body can return either a HTMLBodyElement or HTMLFrameSetElement, so both these elements must support this mapping.
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h
index e20cb07daa..e3ac1836ed 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h
@@ -35,7 +35,7 @@ private:
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
// ^HTML::GlobalEventHandlers
- virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) override;
+ virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override;
// ^HTML::WindowEventHandlers
virtual EventTarget& window_event_handlers_to_event_target() override;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
index 91f6f70777..7ff9f2eba4 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
@@ -319,7 +319,7 @@ void HTMLElement::click()
m_click_in_progress = true;
// FIXME: 4. Fire a synthetic pointer event named click at this element, with the not trusted flag set.
- fire_a_synthetic_pointer_event(HTML::EventNames::click, *this, true);
+ fire_a_synthetic_pointer_event(HTML::EventNames::click.to_deprecated_fly_string(), *this, true);
// 5. Unset this element's click in progress flag.
m_click_in_progress = false;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
index e5a81afd96..1de58ec5cc 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
@@ -74,7 +74,7 @@ private:
virtual bool is_html_element() const final { return true; }
// ^HTML::GlobalEventHandlers
- virtual DOM::EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const&) override { return *this; }
+ virtual DOM::EventTarget& global_event_handlers_to_event_target(FlyString const&) override { return *this; }
enum class ContentEditableState {
True,
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
index 1dbecef2eb..23ff44f55d 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
@@ -83,7 +83,7 @@ ErrorOr<void> HTMLFormElement::submit_form(JS::GCPtr<HTMLElement> submitter, boo
SubmitEventInit event_init {};
event_init.submitter = submitter_button;
- auto submit_event = SubmitEvent::create(realm(), String::from_deprecated_string(EventNames::submit).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors();
+ auto submit_event = SubmitEvent::create(realm(), EventNames::submit, event_init).release_value_but_fixme_should_propagate_errors();
submit_event->set_bubbles(true);
submit_event->set_cancelable(true);
bool continue_ = dispatch_event(*submit_event);
@@ -156,7 +156,7 @@ ErrorOr<void> HTMLFormElement::submit_form(JS::GCPtr<HTMLElement> submitter, boo
void HTMLFormElement::reset_form()
{
// 1. Let reset be the result of firing an event named reset at form, with the bubbles and cancelable attributes initialized to true.
- auto reset_event = DOM::Event::create(realm(), HTML::EventNames::reset).release_value_but_fixme_should_propagate_errors();
+ auto reset_event = DOM::Event::create(realm(), HTML::EventNames::reset.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
reset_event->set_bubbles(true);
reset_event->set_cancelable(true);
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp
index 7a5c11644d..6fed1f85e9 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp
@@ -38,7 +38,7 @@ void HTMLFrameSetElement::parse_attribute(DeprecatedFlyString const& name, Depre
#undef __ENUMERATE
}
-DOM::EventTarget& HTMLFrameSetElement::global_event_handlers_to_event_target(DeprecatedFlyString const& event_name)
+DOM::EventTarget& HTMLFrameSetElement::global_event_handlers_to_event_target(FlyString const& event_name)
{
// NOTE: This is a little weird, but IIUC document.body.onload actually refers to window.onload
// NOTE: document.body can return either a HTMLBodyElement or HTMLFrameSetElement, so both these elements must support this mapping.
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h
index 60dc9ae5e4..07da683826 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h
@@ -27,7 +27,7 @@ private:
virtual void parse_attribute(DeprecatedFlyString const&, DeprecatedString const&) override;
// ^HTML::GlobalEventHandlers
- virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) override;
+ virtual EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) override;
// ^HTML::WindowEventHandlers
virtual EventTarget& window_event_handlers_to_event_target() override;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
index fc76d90b42..d38f9f2a53 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
@@ -165,7 +165,7 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
// FIXME: 4. Set childDocument's iframe load in progress flag.
// 5. Fire an event named load at element.
- element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ element.dispatch_event(DOM::Event::create(element.realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// FIXME: 6. Unset childDocument's iframe load in progress flag.
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index c1ee553898..0dab222986 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -27,7 +27,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
set_needs_style_update(true);
this->document().set_needs_layout();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
- dispatch_event(DOM::Event::create(this->realm(), EventNames::load).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(this->realm(), EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
m_load_event_delayer.clear();
});
};
@@ -37,7 +37,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
set_needs_style_update(true);
this->document().set_needs_layout();
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
- dispatch_event(DOM::Event::create(this->realm(), EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(this->realm(), EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
m_load_event_delayer.clear();
});
};
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 2da21fb220..854e4f3844 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -156,11 +156,11 @@ void HTMLInputElement::update_the_file_selection(JS::NonnullGCPtr<FileAPI::FileL
this->set_files(files.ptr());
// 2. Fire an event named input at the input element, with the bubbles and composed attributes initialized to true.
- auto input_event = DOM::Event::create(this->realm(), EventNames::input, { .bubbles = true, .composed = true }).release_value_but_fixme_should_propagate_errors();
+ auto input_event = DOM::Event::create(this->realm(), EventNames::input.to_deprecated_fly_string(), { .bubbles = true, .composed = true }).release_value_but_fixme_should_propagate_errors();
this->dispatch_event(input_event);
// 3. Fire an event named change at the input element, with the bubbles attribute initialized to true.
- auto change_event = DOM::Event::create(this->realm(), EventNames::change, { .bubbles = true }).release_value_but_fixme_should_propagate_errors();
+ auto change_event = DOM::Event::create(this->realm(), EventNames::change.to_deprecated_fly_string(), { .bubbles = true }).release_value_but_fixme_should_propagate_errors();
this->dispatch_event(change_event);
});
}
@@ -247,13 +247,13 @@ ErrorOr<void> HTMLInputElement::run_input_activation_behavior()
return {};
// 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true.
- auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors();
+ auto input_event = DOM::Event::create(realm(), HTML::EventNames::input.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(input_event);
// 3. Fire an event named change at the element with the bubbles attribute initialized to true.
- auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors();
+ auto change_event = DOM::Event::create(realm(), HTML::EventNames::change.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
change_event->set_bubbles(true);
dispatch_event(*change_event);
} else if (type_state() == TypeAttributeState::SubmitButton) {
@@ -271,7 +271,7 @@ ErrorOr<void> HTMLInputElement::run_input_activation_behavior()
} else if (type_state() == TypeAttributeState::FileUpload) {
show_the_picker_if_applicable(*this);
} else {
- dispatch_event(DOM::Event::create(realm(), EventNames::change).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), EventNames::change.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
return {};
@@ -286,13 +286,13 @@ void HTMLInputElement::did_edit_text_node(Badge<BrowsingContext>)
// NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors"
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
- auto input_event = DOM::Event::create(realm(), HTML::EventNames::input).release_value_but_fixme_should_propagate_errors();
+ auto input_event = DOM::Event::create(realm(), HTML::EventNames::input.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(*input_event);
// FIXME: This should only fire when the input is "committed", whatever that means.
- auto change_event = DOM::Event::create(realm(), HTML::EventNames::change).release_value_but_fixme_should_propagate_errors();
+ auto change_event = DOM::Event::create(realm(), HTML::EventNames::change.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
change_event->set_bubbles(true);
dispatch_event(change_event);
});
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
index 58a17ab15f..0ff92b7848 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
@@ -403,11 +403,11 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
}
// 2. Fire an event named load at el.
- dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
// 5. Otherwise, fire an event named error at el.
else {
- dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
// FIXME: 6. If el contributes a script-blocking style sheet, then:
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
index 94da7a2b92..068b41326c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
@@ -124,7 +124,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
// 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback.
if (!url.is_valid()) {
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
return run_object_representation_fallback_steps();
}
@@ -151,7 +151,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
void HTMLObjectElement::resource_did_fail()
{
// 4.7. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error at the element, then jump to the step below labeled fallback.
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
run_object_representation_fallback_steps();
}
@@ -289,7 +289,7 @@ void HTMLObjectElement::run_object_representation_completed_steps(Representation
// 4.11. If the object element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object element to fire an event named load at the element.
if (representation != Representation::NestedBrowsingContext) {
queue_an_element_task(HTML::Task::Source::DOMManipulation, [&]() {
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
index 45d310c7a3..dd27739692 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
@@ -72,7 +72,7 @@ void HTMLScriptElement::execute_script()
// 3. If el's result is null, then fire an event named error at el, and return.
if (m_result.has<ResultState::Null>()) {
dbgln("HTMLScriptElement: Refusing to run script because the element's result is null.");
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
return;
}
@@ -123,7 +123,7 @@ void HTMLScriptElement::execute_script()
// 8. If el's from an external file is true, then fire an event named load at el.
if (m_from_an_external_file)
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
// https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script
@@ -294,7 +294,7 @@ void HTMLScriptElement::prepare_script()
if (m_script_type == ScriptType::ImportMap) {
// then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return.
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
return;
}
@@ -306,7 +306,7 @@ void HTMLScriptElement::prepare_script()
if (src.is_empty()) {
dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty.");
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
return;
}
@@ -321,7 +321,7 @@ void HTMLScriptElement::prepare_script()
if (!url.is_valid()) {
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
});
return;
}
diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp
index a32f9e3b11..43621dac97 100644
--- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp
+++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp
@@ -99,7 +99,7 @@ void MessagePort::post_message(JS::Value message)
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors();
- target_port->dispatch_event(MessageEvent::create(target_port->realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ target_port->dispatch_event(MessageEvent::create(target_port->realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
}));
}
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index fccbd1f256..075e94eebf 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -256,7 +256,7 @@ void HTMLParser::the_end()
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time();
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
- auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded).release_value_but_fixme_should_propagate_errors();
+ auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
content_loaded_event->set_bubbles(true);
document->dispatch_event(content_loaded_event);
@@ -297,7 +297,7 @@ void HTMLParser::the_end()
// 5. Fire an event named load at window, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
// We should reorganize this so that the flag appears explicitly here instead.
- window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
@@ -313,7 +313,7 @@ void HTMLParser::the_end()
document->set_page_showing(true);
// 11. Fire a page transition event named pageshow at window with false.
- window->fire_a_page_transition_event(HTML::EventNames::pageshow, false);
+ window->fire_a_page_transition_event(HTML::EventNames::pageshow.to_deprecated_fly_string(), false);
// 12. Completely finish loading the Document.
document->completely_finish_loading();
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
index a5a3d41bf6..c1cd73213b 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
@@ -251,7 +251,7 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
// FIXME: This currently assumes that global is a WindowObject.
auto& window = verify_cast<HTML::Window>(global);
- auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), String::from_deprecated_string(HTML::EventNames::unhandledrejection).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors();
+ auto promise_rejection_event = PromiseRejectionEvent::create(window.realm(), HTML::EventNames::unhandledrejection, event_init).release_value_but_fixme_should_propagate_errors();
bool not_handled = window.dispatch_event(*promise_rejection_event);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index e3f821056e..e33f52b076 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -968,7 +968,7 @@ void Window::post_message(JS::Value message, String const&)
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors();
- dispatch_event(MessageEvent::create(realm(), String::from_deprecated_string(EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(MessageEvent::create(realm(), EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
});
}
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 25195868d5..e421ea90ef 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -194,7 +194,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
// ^HTML::GlobalEventHandlers
- virtual DOM::EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const&) override { return *this; }
+ virtual DOM::EventTarget& global_event_handlers_to_event_target(FlyString const&) override { return *this; }
// ^HTML::WindowEventHandlers
virtual DOM::EventTarget& window_event_handlers_to_event_target() override { return *this; }
diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp
index 5a5ef7a333..877095c25e 100644
--- a/Userland/Libraries/LibWeb/HTML/Worker.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp
@@ -166,7 +166,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
MessageEventInit event_init {};
event_init.data = message;
event_init.origin = "<origin>"_string.release_value_but_fixme_should_propagate_errors();
- dispatch_event(MessageEvent::create(*m_worker_realm, String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(MessageEvent::create(*m_worker_realm, HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
}));
return JS::js_undefined();
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
index 84348d4884..de87f44175 100644
--- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
@@ -185,7 +185,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un
return false;
auto offset = compute_mouse_event_offset(position, *layout_node);
- if (node->dispatch_event(UIEvents::WheelEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::wheel, offset.x(), offset.y(), position.x(), position.y(), wheel_delta_x, wheel_delta_y, buttons, button).release_value_but_fixme_should_propagate_errors())) {
+ if (node->dispatch_event(UIEvents::WheelEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::wheel.to_deprecated_fly_string(), offset.x(), offset.y(), position.x(), position.y(), wheel_delta_x, wheel_delta_y, buttons, button).release_value_but_fixme_should_propagate_errors())) {
if (auto* page = m_browsing_context->page()) {
page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20);
}
@@ -249,12 +249,12 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, unsigned button, unsig
auto offset = compute_mouse_event_offset(position, *layout_node);
auto client_offset = compute_mouse_event_client_offset(position);
auto page_offset = compute_mouse_event_page_offset(client_offset);
- node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mouseup, offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
+ node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mouseup.to_deprecated_fly_string(), offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
handled_event = true;
bool run_activation_behavior = true;
if (node.ptr() == m_mousedown_target && button == GUI::MouseButton::Primary) {
- run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click, offset, client_offset, page_offset, button).release_value_but_fixme_should_propagate_errors());
+ run_activation_behavior = node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::click.to_deprecated_fly_string(), offset, client_offset, page_offset, button).release_value_but_fixme_should_propagate_errors());
}
if (run_activation_behavior) {
@@ -372,7 +372,7 @@ bool EventHandler::handle_mousedown(CSSPixelPoint position, unsigned button, uns
auto offset = compute_mouse_event_offset(position, *layout_node);
auto client_offset = compute_mouse_event_client_offset(position);
auto page_offset = compute_mouse_event_page_offset(client_offset);
- node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousedown, offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
+ node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousedown.to_deprecated_fly_string(), offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
}
// NOTE: Dispatching an event may have disturbed the world.
@@ -488,7 +488,7 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, unsigned buttons, un
auto offset = compute_mouse_event_offset(position, *layout_node);
auto client_offset = compute_mouse_event_client_offset(position);
auto page_offset = compute_mouse_event_page_offset(client_offset);
- node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousemove, offset, client_offset, page_offset, buttons).release_value_but_fixme_should_propagate_errors());
+ node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::mousemove.to_deprecated_fly_string(), offset, client_offset, page_offset, buttons).release_value_but_fixme_should_propagate_errors());
// NOTE: Dispatching an event may have disturbed the world.
if (!paint_root() || paint_root() != node->document().paint_box())
return true;
@@ -577,7 +577,7 @@ bool EventHandler::handle_doubleclick(CSSPixelPoint position, unsigned button, u
auto offset = compute_mouse_event_offset(position, *layout_node);
auto client_offset = compute_mouse_event_client_offset(position);
auto page_offset = compute_mouse_event_page_offset(client_offset);
- node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::dblclick, offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
+ node->dispatch_event(UIEvents::MouseEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::dblclick.to_deprecated_fly_string(), offset, client_offset, page_offset, buttons, button).release_value_but_fixme_should_propagate_errors());
// NOTE: Dispatching an event may have disturbed the world.
if (!paint_root() || paint_root() != node->document().paint_box())
@@ -783,17 +783,17 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin
return true;
}
- bool continue_ = fire_keyboard_event(UIEvents::EventNames::keydown, m_browsing_context, key, modifiers, code_point);
+ bool continue_ = fire_keyboard_event(UIEvents::EventNames::keydown.to_deprecated_fly_string(), m_browsing_context, key, modifiers, code_point);
if (!continue_)
return false;
// FIXME: Work out and implement the difference between this and keydown.
- return fire_keyboard_event(UIEvents::EventNames::keypress, m_browsing_context, key, modifiers, code_point);
+ return fire_keyboard_event(UIEvents::EventNames::keypress.to_deprecated_fly_string(), m_browsing_context, key, modifiers, code_point);
}
bool EventHandler::handle_keyup(KeyCode key, unsigned modifiers, u32 code_point)
{
- return fire_keyboard_event(UIEvents::EventNames::keyup, m_browsing_context, key, modifiers, code_point);
+ return fire_keyboard_event(UIEvents::EventNames::keyup.to_deprecated_fly_string(), m_browsing_context, key, modifiers, code_point);
}
void EventHandler::set_mouse_event_tracking_layout_node(Layout::Node* layout_node)
diff --git a/Userland/Libraries/LibWeb/UIEvents/EventNames.cpp b/Userland/Libraries/LibWeb/UIEvents/EventNames.cpp
index 2f2ed22ca5..d7ef347ef2 100644
--- a/Userland/Libraries/LibWeb/UIEvents/EventNames.cpp
+++ b/Userland/Libraries/LibWeb/UIEvents/EventNames.cpp
@@ -8,7 +8,7 @@
namespace Web::UIEvents::EventNames {
-#define __ENUMERATE_UI_EVENT(name) DeprecatedFlyString name;
+#define __ENUMERATE_UI_EVENT(name) FlyString name;
ENUMERATE_UI_EVENTS
#undef __ENUMERATE_UI_EVENT
@@ -18,7 +18,7 @@ ErrorOr<void> initialize_strings()
VERIFY(!s_initialized);
#define __ENUMERATE_UI_EVENT(name) \
- name = #name;
+ name = TRY(#name##_fly_string);
ENUMERATE_UI_EVENTS
#undef __ENUMERATE_UI_EVENT
diff --git a/Userland/Libraries/LibWeb/UIEvents/EventNames.h b/Userland/Libraries/LibWeb/UIEvents/EventNames.h
index f60b0cb4c8..e789f7956d 100644
--- a/Userland/Libraries/LibWeb/UIEvents/EventNames.h
+++ b/Userland/Libraries/LibWeb/UIEvents/EventNames.h
@@ -7,8 +7,8 @@
#pragma once
-#include <AK/DeprecatedFlyString.h>
#include <AK/Error.h>
+#include <AK/FlyString.h>
namespace Web::UIEvents::EventNames {
@@ -31,7 +31,7 @@ namespace Web::UIEvents::EventNames {
__ENUMERATE_UI_EVENT(resize) \
__ENUMERATE_UI_EVENT(wheel)
-#define __ENUMERATE_UI_EVENT(name) extern DeprecatedFlyString name;
+#define __ENUMERATE_UI_EVENT(name) extern FlyString name;
ENUMERATE_UI_EVENTS
#undef __ENUMERATE_UI_EVENT
diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp
index 37c79481a4..3220b0c6b2 100644
--- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp
+++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp
@@ -77,7 +77,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<MouseEvent>> MouseEvent::create_from_platfo
void MouseEvent::set_event_characteristics()
{
- if (type().is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click)) {
+ auto type = String::from_deprecated_string(this->type()).release_value();
+ if (type.is_one_of(EventNames::mousedown, EventNames::mousemove, EventNames::mouseout, EventNames::mouseover, EventNames::mouseup, HTML::EventNames::click)) {
set_bubbles(true);
set_cancelable(true);
set_composed(true);
diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
index 275116fae6..dab8467b3d 100644
--- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
+++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp
@@ -204,13 +204,13 @@ void WebSocket::on_open()
// 1. Change the readyState attribute's value to OPEN (1).
// 2. Change the extensions attribute's value to the extensions in use, if it is not the null value. [WSP]
// 3. Change the protocol attribute's value to the subprotocol in use, if it is not the null value. [WSP]
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::open).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::open.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
void WebSocket::on_error()
{
- dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(DOM::Event::create(realm(), HTML::EventNames::error.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
}
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@@ -222,7 +222,7 @@ void WebSocket::on_close(u16 code, DeprecatedString reason, bool was_clean)
event_init.was_clean = was_clean;
event_init.code = code;
event_init.reason = String::from_deprecated_string(reason).release_value_but_fixme_should_propagate_errors();
- dispatch_event(HTML::CloseEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::close.view()).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(HTML::CloseEvent::create(realm(), HTML::EventNames::close, event_init).release_value_but_fixme_should_propagate_errors());
}
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
@@ -235,7 +235,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
HTML::MessageEventInit event_init;
event_init.data = JS::PrimitiveString::create(vm(), text_message);
event_init.origin = String::from_deprecated_string(url()).release_value_but_fixme_should_propagate_errors();
- dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
return;
}
@@ -247,7 +247,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
HTML::MessageEventInit event_init;
event_init.data = JS::ArrayBuffer::create(realm(), message);
event_init.origin = String::from_deprecated_string(url()).release_value_but_fixme_should_propagate_errors();
- dispatch_event(HTML::MessageEvent::create(realm(), String::from_deprecated_string(HTML::EventNames::message).release_value_but_fixme_should_propagate_errors(), event_init).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init).release_value_but_fixme_should_propagate_errors());
return;
}
diff --git a/Userland/Libraries/LibWeb/XHR/EventNames.cpp b/Userland/Libraries/LibWeb/XHR/EventNames.cpp
index 90b747c34e..1309b2f6aa 100644
--- a/Userland/Libraries/LibWeb/XHR/EventNames.cpp
+++ b/Userland/Libraries/LibWeb/XHR/EventNames.cpp
@@ -8,7 +8,7 @@
namespace Web::XHR::EventNames {
-#define __ENUMERATE_XHR_EVENT(name) DeprecatedFlyString name;
+#define __ENUMERATE_XHR_EVENT(name) FlyString name;
ENUMERATE_XHR_EVENTS
#undef __ENUMERATE_XHR_EVENT
@@ -18,7 +18,7 @@ ErrorOr<void> initialize_strings()
VERIFY(!s_initialized);
#define __ENUMERATE_XHR_EVENT(name) \
- name = #name;
+ name = TRY(#name##_fly_string);
ENUMERATE_XHR_EVENTS
#undef __ENUMERATE_XHR_EVENT
diff --git a/Userland/Libraries/LibWeb/XHR/EventNames.h b/Userland/Libraries/LibWeb/XHR/EventNames.h
index a543cea26c..0c23c1fb7c 100644
--- a/Userland/Libraries/LibWeb/XHR/EventNames.h
+++ b/Userland/Libraries/LibWeb/XHR/EventNames.h
@@ -6,8 +6,8 @@
#pragma once
-#include <AK/DeprecatedFlyString.h>
#include <AK/Error.h>
+#include <AK/FlyString.h>
namespace Web::XHR::EventNames {
@@ -21,7 +21,7 @@ namespace Web::XHR::EventNames {
__ENUMERATE_XHR_EVENT(timeout) \
__ENUMERATE_XHR_EVENT(loadend)
-#define __ENUMERATE_XHR_EVENT(name) extern DeprecatedFlyString name;
+#define __ENUMERATE_XHR_EVENT(name) extern FlyString name;
ENUMERATE_XHR_EVENTS
#undef __ENUMERATE_XHR_EVENT
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index 8015d7c14d..69f697674b 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -436,7 +436,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method_string, Stri
m_state = State::Opened;
// 2. Fire an event named readystatechange at this.
- dispatch_event(TRY(DOM::Event::create(realm(), EventNames::readystatechange)));
+ dispatch_event(TRY(DOM::Event::create(realm(), EventNames::readystatechange.to_deprecated_fly_string())));
}
return {};
@@ -607,7 +607,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
// 11. If this’s synchronous flag is unset, then:
if (!m_synchronous) {
// 1. Fire a progress event named loadstart at this with 0 and 0.
- fire_progress_event(*this, EventNames::loadstart, 0, 0);
+ fire_progress_event(*this, EventNames::loadstart.to_deprecated_fly_string(), 0, 0);
// 2. Let requestBodyTransmitted be 0.
// NOTE: This is kept on the XHR object itself instead of the stack, as we cannot capture references to stack variables in an async context.
@@ -625,7 +625,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
// 5. If this’s upload complete flag is unset and this’s upload listener flag is set, then fire a progress event named loadstart at this’s upload object with requestBodyTransmitted and requestBodyLength.
if (!m_upload_complete && m_upload_listener)
- fire_progress_event(m_upload_object, EventNames::loadstart, m_request_body_transmitted, request_body_length);
+ fire_progress_event(m_upload_object, EventNames::loadstart.to_deprecated_fly_string(), m_request_body_transmitted, request_body_length);
// 6. If this’s state is not opened or this’s send() flag is unset, then return.
if (m_state != State::Opened || !m_send)
@@ -642,7 +642,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
// 3. If this’s upload listener flag is set, then fire a progress event named progress at this’s upload object with requestBodyTransmitted and requestBodyLength.
if (m_upload_listener)
- fire_progress_event(m_upload_object, EventNames::progress, m_request_body_transmitted, request_body_length);
+ fire_progress_event(m_upload_object, EventNames::progress.to_deprecated_fly_string(), m_request_body_transmitted, request_body_length);
};
// 8. Let processRequestEndOfBody be these steps:
@@ -657,13 +657,13 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
return;
// 3. Fire a progress event named progress at this’s upload object with requestBodyTransmitted and requestBodyLength.
- fire_progress_event(m_upload_object, EventNames::progress, m_request_body_transmitted, request_body_length);
+ fire_progress_event(m_upload_object, EventNames::progress.to_deprecated_fly_string(), m_request_body_transmitted, request_body_length);
// 4. Fire a progress event named load at this’s upload object with requestBodyTransmitted and requestBodyLength.
- fire_progress_event(m_upload_object, EventNames::load, m_request_body_transmitted, request_body_length);
+ fire_progress_event(m_upload_object, EventNames::load.to_deprecated_fly_string(), m_request_body_transmitted, request_body_length);
// 5. Fire a progress event named loadend at this’s upload object with requestBodyTransmitted and requestBodyLength.
- fire_progress_event(m_upload_object, EventNames::loadend, m_request_body_transmitted, request_body_length);
+ fire_progress_event(m_upload_object, EventNames::loadend.to_deprecated_fly_string(), m_request_body_transmitted, request_body_length);
};
// 9. Let processResponse, given a response, be these steps:
@@ -686,7 +686,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(Optional<DocumentOrXMLHttpRequest
// 5. Fire an event named readystatechange at this.
// FIXME: We're in an async context, so we can't propagate the error anywhere.
- dispatch_event(*DOM::Event::create(this->realm(), EventNames::readystatechange).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(*DOM::Event::create(this->realm(), EventNames::readystatechange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// 6. If this’s state is not headers received, then return.
if (m_state != State::HeadersReceived)
@@ -983,19 +983,19 @@ bool XMLHttpRequest::must_survive_garbage_collection() const
if ((m_state == State::Opened && m_send)
|| m_state == State::HeadersReceived
|| m_state == State::Loading) {
- if (has_event_listener(EventNames::readystatechange))
+ if (has_event_listener(EventNames::readystatechange.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::progress))
+ if (has_event_listener(EventNames::progress.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::abort))
+ if (has_event_listener(EventNames::abort.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::error))
+ if (has_event_listener(EventNames::error.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::load))
+ if (has_event_listener(EventNames::load.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::timeout))
+ if (has_event_listener(EventNames::timeout.to_deprecated_fly_string()))
return true;
- if (has_event_listener(EventNames::loadend))
+ if (has_event_listener(EventNames::loadend.to_deprecated_fly_string()))
return true;
}
@@ -1017,7 +1017,7 @@ void XMLHttpRequest::abort()
// NOTE: This cannot throw as we don't pass in an exception. XHR::abort cannot be reached in a synchronous context where the state matches above.
// This is because it pauses inside XHR::send until the request is done or times out and then immediately calls `handle_response_end_of_body`
// which will always set `m_state` to `Done`.
- MUST(request_error_steps(EventNames::abort));
+ MUST(request_error_steps(EventNames::abort.to_deprecated_fly_string()));
}
// 3. If this’s state is done, then set this’s state to unsent and this’s response to a network error.
@@ -1078,7 +1078,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::handle_response_end_of_body()
// 6. If xhr’s synchronous flag is unset, then fire a progress event named progress at xhr with transmitted and length.
if (!m_synchronous)
- fire_progress_event(*this, EventNames::progress, transmitted, length);
+ fire_progress_event(*this, EventNames::progress.to_deprecated_fly_string(), transmitted, length);
// 7. Set xhr’s state to done.
m_state = State::Done;
@@ -1088,13 +1088,13 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::handle_response_end_of_body()
// 9. Fire an event named readystatechange at xhr.
// FIXME: If we're in an async context, this will propagate to a callback context which can't propagate it anywhere else and does not expect this to fail.
- dispatch_event(*DOM::Event::create(realm, EventNames::readystatechange).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(*DOM::Event::create(realm, EventNames::readystatechange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// 10. Fire a progress event named load at xhr with transmitted and length.
- fire_progress_event(*this, EventNames::load, transmitted, length);
+ fire_progress_event(*this, EventNames::load.to_deprecated_fly_string(), transmitted, length);
// 11. Fire a progress event named loadend at xhr with transmitted and length.
- fire_progress_event(*this, EventNames::loadend, transmitted, length);
+ fire_progress_event(*this, EventNames::loadend.to_deprecated_fly_string(), transmitted, length);
return {};
}
@@ -1108,15 +1108,15 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::handle_errors()
// 2. If xhr’s timed out flag is set, then run the request error steps for xhr, timeout, and "TimeoutError" DOMException.
if (m_timed_out)
- return TRY(request_error_steps(EventNames::timeout, WebIDL::TimeoutError::create(realm(), "Timed out"sv)));
+ return TRY(request_error_steps(EventNames::timeout.to_deprecated_fly_string(), WebIDL::TimeoutError::create(realm(), "Timed out"sv)));
// 3. Otherwise, if xhr’s response’s aborted flag is set, run the request error steps for xhr, abort, and "AbortError" DOMException.
if (m_response->aborted())
- return TRY(request_error_steps(EventNames::abort, WebIDL::AbortError::create(realm(), "Aborted"sv)));
+ return TRY(request_error_steps(EventNames::abort.to_deprecated_fly_string(), WebIDL::AbortError::create(realm(), "Aborted"sv)));
// 4. Otherwise, if xhr’s response is a network error, then run the request error steps for xhr, error, and "NetworkError" DOMException.
if (m_response->is_network_error())
- return TRY(request_error_steps(EventNames::error, WebIDL::NetworkError::create(realm(), "Network error"sv)));
+ return TRY(request_error_steps(EventNames::error.to_deprecated_fly_string(), WebIDL::NetworkError::create(realm(), "Network error"sv)));
return {};
}
@@ -1140,7 +1140,7 @@ JS::ThrowCompletionOr<void> XMLHttpRequest::request_error_steps(DeprecatedFlyStr
// 5. Fire an event named readystatechange at xhr.
// FIXME: Since we're in an async context, this will propagate to a callback context which can't propagate it anywhere else and does not expect this to fail.
- dispatch_event(*DOM::Event::create(realm(), EventNames::readystatechange).release_value_but_fixme_should_propagate_errors());
+ dispatch_event(*DOM::Event::create(realm(), EventNames::readystatechange.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// 6. If xhr’s upload complete flag is unset, then:
if (!m_upload_complete) {
@@ -1153,7 +1153,7 @@ JS::ThrowCompletionOr<void> XMLHttpRequest::request_error_steps(DeprecatedFlyStr
fire_progress_event(m_upload_object, event_name, 0, 0);
// 2. Fire a progress event named loadend at xhr’s upload object with 0 and 0.
- fire_progress_event(m_upload_object, EventNames::loadend, 0, 0);
+ fire_progress_event(m_upload_object, EventNames::loadend.to_deprecated_fly_string(), 0, 0);
}
}
@@ -1161,7 +1161,7 @@ JS::ThrowCompletionOr<void> XMLHttpRequest::request_error_steps(DeprecatedFlyStr
fire_progress_event(*this, event_name, 0, 0);
// 8. Fire a progress event named loadend at xhr with 0 and 0.
- fire_progress_event(*this, EventNames::loadend, 0, 0);
+ fire_progress_event(*this, EventNames::loadend.to_deprecated_fly_string(), 0, 0);
return {};
}
diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
index 4d5d562010..20113eba53 100644
--- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
+++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
@@ -189,7 +189,7 @@ void XMLDocumentBuilder::document_end()
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::unsafe_shared_current_time();
// Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
- auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded).release_value_but_fixme_should_propagate_errors();
+ auto content_loaded_event = DOM::Event::create(document->realm(), HTML::EventNames::DOMContentLoaded.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors();
content_loaded_event->set_bubbles(true);
document->dispatch_event(content_loaded_event);
@@ -229,7 +229,7 @@ void XMLDocumentBuilder::document_end()
// Fire an event named load at window, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
// We should reorganize this so that the flag appears explicitly here instead.
- window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load).release_value_but_fixme_should_propagate_errors());
+ window->dispatch_event(DOM::Event::create(document->realm(), HTML::EventNames::load.to_deprecated_fly_string()).release_value_but_fixme_should_propagate_errors());
// FIXME: Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
@@ -245,7 +245,7 @@ void XMLDocumentBuilder::document_end()
document->set_page_showing(true);
// Fire a page transition event named pageshow at window with false.
- window->fire_a_page_transition_event(HTML::EventNames::pageshow, false);
+ window->fire_a_page_transition_event(HTML::EventNames::pageshow.to_deprecated_fly_string(), false);
// Completely finish loading the Document.
document->completely_finish_loading();