GlobalEventHandlers.h 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@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_GLOBAL_EVENT_HANDLERS(E) \
  10. E(onabort, HTML::EventNames::abort) \
  11. E(onauxclick, "auxclick") \
  12. E(onblur, HTML::EventNames::blur) \
  13. E(oncancel, HTML::EventNames::cancel) \
  14. E(oncanplay, "canplay") \
  15. E(oncanplaythrough, "canplaythrough") \
  16. E(onchange, HTML::EventNames::change) \
  17. E(onclick, UIEvents::EventNames::click) \
  18. E(onclose, HTML::EventNames::close) \
  19. E(oncontextmenu, HTML::EventNames::contextmenu) \
  20. E(oncuechange, "cuechange") \
  21. E(ondblclick, "dblclick") \
  22. E(ondrag, "drag") \
  23. E(ondragend, "dragend") \
  24. E(ondragenter, "dragenter") \
  25. E(ondragleave, "dragleave") \
  26. E(ondragover, "dragover") \
  27. E(ondragstart, "dragstart") \
  28. E(ondrop, "drop") \
  29. E(ondurationchange, "durationchange") \
  30. E(onemptied, "emptied") \
  31. E(onended, "ended") \
  32. E(onerror, HTML::EventNames::error) \
  33. E(onfocus, "focus") \
  34. E(onformdata, "formdata") \
  35. E(oninput, HTML::EventNames::input) \
  36. E(oninvalid, HTML::EventNames::invalid) \
  37. E(onkeydown, "keydown") \
  38. E(onkeypress, "keypress") \
  39. E(onkeyup, "keyup") \
  40. E(onload, HTML::EventNames::load) \
  41. E(onloadeddata, "loadeddata") \
  42. E(onloadedmetadata, "loadedmetadata") \
  43. E(onloadstart, "loadstart") \
  44. E(onmousedown, UIEvents::EventNames::mousedown) \
  45. E(onmouseenter, UIEvents::EventNames::mouseenter) \
  46. E(onmouseleave, UIEvents::EventNames::mouseleave) \
  47. E(onmousemove, UIEvents::EventNames::mousemove) \
  48. E(onmouseout, UIEvents::EventNames::mouseout) \
  49. E(onmouseover, UIEvents::EventNames::mouseover) \
  50. E(onmouseup, UIEvents::EventNames::mouseup) \
  51. E(onpause, "pause") \
  52. E(onplay, "play") \
  53. E(onplaying, "playing") \
  54. E(onprogress, "progress") \
  55. E(onratechange, "ratechange") \
  56. E(onreset, "reset") \
  57. E(onresize, "resize") \
  58. E(onscroll, "scroll") \
  59. E(onsecuritypolicyviolation, "securitypolicyviolation") \
  60. E(onseeked, "seeked") \
  61. E(onseeking, "seeking") \
  62. E(onselect, HTML::EventNames::select) \
  63. E(onslotchange, "slotchange") \
  64. E(onstalled, "stalled") \
  65. E(onsubmit, HTML::EventNames::submit) \
  66. E(onsuspend, "suspend") \
  67. E(ontimeupdate, "timeupdate") \
  68. E(ontoggle, "toggle") \
  69. E(onvolumechange, "volumechange") \
  70. E(onwaiting, "waiting") \
  71. E(onwebkitanimationend, "webkitanimationend") \
  72. E(onwebkitanimationiteration, "webkitanimationiteration") \
  73. E(onwebkitanimationstart, "webkitanimationstart") \
  74. E(onwebkittransitionend, "webkittransitionend") \
  75. E(onwheel, "wheel")
  76. namespace Web::HTML {
  77. class GlobalEventHandlers {
  78. public:
  79. virtual ~GlobalEventHandlers();
  80. #undef __ENUMERATE
  81. #define __ENUMERATE(attribute_name, event_name) \
  82. void set_##attribute_name(Bindings::CallbackType*); \
  83. Bindings::CallbackType* attribute_name();
  84. ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
  85. #undef __ENUMERATE
  86. protected:
  87. virtual DOM::EventTarget& global_event_handlers_to_event_target(FlyString const& event_name) = 0;
  88. };
  89. }