diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 42ba6efe14..25c7394b34 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,7 @@ ErrorOr initialize_main_thread_vm() TRY(SVG::AttributeNames::initialize_strings()); TRY(SVG::TagNames::initialize_strings()); TRY(UIEvents::EventNames::initialize_strings()); + TRY(WebGL::EventNames::initialize_strings()); TRY(XHR::EventNames::initialize_strings()); static_cast(s_main_thread_vm->custom_data())->event_loop.set_vm(*s_main_thread_vm); diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index e3c526cdad..a8909938a4 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -518,6 +518,7 @@ set(SOURCES WebDriver/Response.cpp WebDriver/Screenshot.cpp WebDriver/TimeoutsConfiguration.cpp + WebGL/EventNames.cpp WebGL/WebGLContextAttributes.cpp WebGL/WebGLContextEvent.cpp WebGL/WebGLRenderingContext.cpp diff --git a/Userland/Libraries/LibWeb/WebGL/EventNames.cpp b/Userland/Libraries/LibWeb/WebGL/EventNames.cpp new file mode 100644 index 0000000000..497863e98f --- /dev/null +++ b/Userland/Libraries/LibWeb/WebGL/EventNames.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023, Kenneth Myhra + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Web::WebGL::EventNames { + +#define __ENUMERATE_GL_EVENT(name) FlyString name; +ENUMERATE_GL_EVENTS +#undef __ENUMERATE_GL_EVENT + +ErrorOr initialize_strings() +{ + static bool s_initialized = false; + VERIFY(!s_initialized); + +#define __ENUMERATE_GL_EVENT(name) \ + name = TRY(#name##_fly_string); + ENUMERATE_GL_EVENTS +#undef __ENUMERATE_GL_EVENT + + s_initialized = true; + return {}; +} + +} diff --git a/Userland/Libraries/LibWeb/WebGL/EventNames.h b/Userland/Libraries/LibWeb/WebGL/EventNames.h new file mode 100644 index 0000000000..4d757317c5 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebGL/EventNames.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023, Kenneth Myhra + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::WebGL::EventNames { + +#define ENUMERATE_GL_EVENTS \ + __ENUMERATE_GL_EVENT(webglcontextcreationerror) \ + __ENUMERATE_GL_EVENT(webglcontextlost) \ + __ENUMERATE_GL_EVENT(webglcontextrestored) + +#define __ENUMERATE_GL_EVENT(name) extern FlyString name; +ENUMERATE_GL_EVENTS +#undef __ENUMERATE_GL_EVENT + +ErrorOr initialize_strings(); + +}