Serenity Operating System
at master 47 lines 1.7 kB view raw
1/* 2 * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Forward.h> 10#include <LibWeb/Forward.h> 11 12#define ENUMERATE_WINDOW_EVENT_HANDLERS(E) \ 13 E(onafterprint, HTML::EventNames::afterprint) \ 14 E(onbeforeprint, HTML::EventNames::beforeprint) \ 15 E(onbeforeunload, HTML::EventNames::beforeunload) \ 16 E(onhashchange, HTML::EventNames::hashchange) \ 17 E(onlanguagechange, HTML::EventNames::languagechange) \ 18 E(onmessage, HTML::EventNames::message) \ 19 E(onmessageerror, HTML::EventNames::messageerror) \ 20 E(onoffline, HTML::EventNames::offline) \ 21 E(ononline, HTML::EventNames::online) \ 22 E(onpagehide, HTML::EventNames::pagehide) \ 23 E(onpageshow, HTML::EventNames::pageshow) \ 24 E(onpopstate, HTML::EventNames::popstate) \ 25 E(onrejectionhandled, HTML::EventNames::rejectionhandled) \ 26 E(onstorage, HTML::EventNames::storage) \ 27 E(onunhandledrejection, HTML::EventNames::unhandledrejection) \ 28 E(onunload, HTML::EventNames::unload) 29 30namespace Web::HTML { 31 32class WindowEventHandlers { 33public: 34 virtual ~WindowEventHandlers(); 35 36#undef __ENUMERATE 37#define __ENUMERATE(attribute_name, event_name) \ 38 void set_##attribute_name(WebIDL::CallbackType*); \ 39 WebIDL::CallbackType* attribute_name(); 40 ENUMERATE_WINDOW_EVENT_HANDLERS(__ENUMERATE) 41#undef __ENUMERATE 42 43protected: 44 virtual DOM::EventTarget& window_event_handlers_to_event_target() = 0; 45}; 46 47}