From 98cf845d8a0b445b5b587096e6484f98a6a12715 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Mar 2024 11:17:16 +0100 Subject: [PATCH] LibWeb: Use HTML::EventNames::animation* instead of string literals --- Userland/Libraries/LibWeb/DOM/Document.cpp | 22 ++++++++++----------- Userland/Libraries/LibWeb/HTML/EventNames.h | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 9efb9b7fb17..6bb5342d1f8 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1941,7 +1941,7 @@ void Document::dispatch_events_for_animation_if_necessary(JS::NonnullGCPtrrealm(), @@ -1969,15 +1969,15 @@ void Document::dispatch_events_for_animation_if_necessary(JS::NonnullGCPtrprevious_current_iteration(); if (previous_current_iteration != current_iteration) { @@ -1994,25 +1994,25 @@ void Document::dispatch_events_for_animation_if_necessary(JS::NonnullGCPtr() ? 0.0 : iteration_duration_variant.get(); auto elapsed_time = (iteration_boundary - effect->iteration_start()) * iteration_duration; - dispatch_event("animationiteration"_fly_string, elapsed_time); + dispatch_event(HTML::EventNames::animationiteration, elapsed_time); } } else if (current_phase == Animations::AnimationEffect::Phase::After) { - dispatch_event("animationend"_fly_string, interval_end); + dispatch_event(HTML::EventNames::animationend, interval_end); } break; case Animations::AnimationEffect::Phase::After: if (current_phase == Animations::AnimationEffect::Phase::Active) { - dispatch_event("animationstart"_fly_string, interval_end); + dispatch_event(HTML::EventNames::animationstart, interval_end); } else if (current_phase == Animations::AnimationEffect::Phase::Before) { - dispatch_event("animationstart"_fly_string, interval_end); - dispatch_event("animationend"_fly_string, interval_start); + dispatch_event(HTML::EventNames::animationstart, interval_end); + dispatch_event(HTML::EventNames::animationend, interval_start); } break; } if (current_phase == Animations::AnimationEffect::Phase::Idle && previous_phase != Animations::AnimationEffect::Phase::Idle && previous_phase != Animations::AnimationEffect::Phase::After) { // FIXME: Use the active time "at the moment it was cancelled" - dispatch_event("animationcancel"_fly_string, effect->active_time_using_fill(Bindings::FillMode::Both).value()); + dispatch_event(HTML::EventNames::animationcancel, effect->active_time_using_fill(Bindings::FillMode::Both).value()); } } } diff --git a/Userland/Libraries/LibWeb/HTML/EventNames.h b/Userland/Libraries/LibWeb/HTML/EventNames.h index 731d22470f4..d209fa6d3d9 100644 --- a/Userland/Libraries/LibWeb/HTML/EventNames.h +++ b/Userland/Libraries/LibWeb/HTML/EventNames.h @@ -17,6 +17,7 @@ namespace Web::HTML::EventNames { #define ENUMERATE_HTML_EVENTS \ __ENUMERATE_HTML_EVENT(abort) \ __ENUMERATE_HTML_EVENT(addtrack) \ + __ENUMERATE_HTML_EVENT(animationcancel) \ __ENUMERATE_HTML_EVENT(animationend) \ __ENUMERATE_HTML_EVENT(animationiteration) \ __ENUMERATE_HTML_EVENT(animationstart) \