WindowEventHandlers.h 1.7 KB

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