ladybird/Userland/Libraries/LibWeb/UIEvents/EventNames.h
Timothy Flynn db2ba5f1d9 LibWeb: Initialize static web strings during main-thread VM creation
These are currently initialized in a [[gnu::constructor]], which has a
weird initialization order. These constructors are invoked before main()
and, incidentally, before any user-defined default constructors of the
static strings they are initializing.

This will become an issue when these strings are ported to FlyString,
which has a user-defined default constructor. In that scenario, when the
FlyString constructor is executed after the [[gnu::constructor]], the
strings will be "reset" to the empty string.

Instead of relying on a non-standard compiler extension here, let's just
initialize these strings explicitly during main-thread VM creation, as
this now happens in WebContent's main().
2023-03-18 19:50:45 +01:00

40 lines
1.0 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/Error.h>
namespace Web::UIEvents::EventNames {
// FIXME: This is not all of the events
#define ENUMERATE_UI_EVENTS \
__ENUMERATE_UI_EVENT(click) \
__ENUMERATE_UI_EVENT(dblclick) \
__ENUMERATE_UI_EVENT(keydown) \
__ENUMERATE_UI_EVENT(keypress) \
__ENUMERATE_UI_EVENT(keyup) \
__ENUMERATE_UI_EVENT(mousedown) \
__ENUMERATE_UI_EVENT(mouseenter) \
__ENUMERATE_UI_EVENT(mouseleave) \
__ENUMERATE_UI_EVENT(mousemove) \
__ENUMERATE_UI_EVENT(mouseout) \
__ENUMERATE_UI_EVENT(mouseover) \
__ENUMERATE_UI_EVENT(mouseup) \
__ENUMERATE_UI_EVENT(resize) \
__ENUMERATE_UI_EVENT(wheel)
#define __ENUMERATE_UI_EVENT(name) extern DeprecatedFlyString name;
ENUMERATE_UI_EVENTS
#undef __ENUMERATE_UI_EVENT
ErrorOr<void> initialize_strings();
}