GlobalEventHandlers.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #include <AK/Forward.h>
  28. #include <LibWeb/Forward.h>
  29. #define ENUMERATE_GLOBAL_EVENT_HANDLERS(E) \
  30. E(onabort, HTML::EventNames::abort) \
  31. E(onauxclick, "auxclick") \
  32. E(onblur, HTML::EventNames::blur) \
  33. E(oncancel, HTML::EventNames::cancel) \
  34. E(oncanplay, "canplay") \
  35. E(oncanplaythrough, "canplaythrough") \
  36. E(onchange, HTML::EventNames::change) \
  37. E(onclick, UIEvents::EventNames::click) \
  38. E(onclose, HTML::EventNames::close) \
  39. E(oncontextmenu, HTML::EventNames::contextmenu) \
  40. E(oncuechange, "cuechange") \
  41. E(ondblclick, "dblclick") \
  42. E(ondrag, "drag") \
  43. E(ondragend, "dragend") \
  44. E(ondragenter, "dragenter") \
  45. E(ondragleave, "dragleave") \
  46. E(ondragover, "dragover") \
  47. E(ondragstart, "dragstart") \
  48. E(ondrop, "drop") \
  49. E(ondurationchange, "durationchange") \
  50. E(onemptied, "emptied") \
  51. E(onended, "ended") \
  52. E(onerror, HTML::EventNames::error) \
  53. E(onfocus, "focus") \
  54. E(onformdata, "formdata") \
  55. E(oninput, HTML::EventNames::input) \
  56. E(oninvalid, HTML::EventNames::invalid) \
  57. E(onkeydown, "keydown") \
  58. E(onkeypress, "keypress") \
  59. E(onkeyup, "keyup") \
  60. E(onload, HTML::EventNames::load) \
  61. E(onloadeddata, "loadeddata") \
  62. E(onloadedmetadata, "loadedmetadata") \
  63. E(onloadstart, "loadstart") \
  64. E(onmousedown, UIEvents::EventNames::mousedown) \
  65. E(onmouseenter, UIEvents::EventNames::mouseenter) \
  66. E(onmouseleave, UIEvents::EventNames::mouseleave) \
  67. E(onmousemove, UIEvents::EventNames::mousedown) \
  68. E(onmouseout, UIEvents::EventNames::mouseout) \
  69. E(onmouseover, UIEvents::EventNames::mouseover) \
  70. E(onmouseup, UIEvents::EventNames::mouseup) \
  71. E(onpause, "pause") \
  72. E(onplay, "play") \
  73. E(onplaying, "playing") \
  74. E(onprogress, "progress") \
  75. E(onratechange, "ratechange") \
  76. E(onreset, "reset") \
  77. E(onresize, "resize") \
  78. E(onscroll, "scroll") \
  79. E(onsecuritypolicyviolation, "securitypolicyviolation") \
  80. E(onseeked, "seeked") \
  81. E(onseeking, "seeking") \
  82. E(onselect, HTML::EventNames::select) \
  83. E(onslotchange, "slotchange") \
  84. E(onstalled, "stalled") \
  85. E(onsubmit, HTML::EventNames::submit) \
  86. E(onsuspend, "suspend") \
  87. E(ontimeupdate, "timeupdate") \
  88. E(ontoggle, "toggle") \
  89. E(onvolumechange, "volumechange") \
  90. E(onwaiting, "waiting") \
  91. E(onwebkitanimationend, "webkitanimationend") \
  92. E(onwebkitanimationiteration, "webkitanimationiteration") \
  93. E(onwebkitanimationstart, "webkitanimationstart") \
  94. E(onwebkittransitionend, "webkittransitionend") \
  95. E(onwheel, "wheel")
  96. namespace Web::HTML {
  97. class GlobalEventHandlers {
  98. public:
  99. virtual ~GlobalEventHandlers();
  100. #undef __ENUMERATE
  101. #define __ENUMERATE(attribute_name, event_name) \
  102. void set_##attribute_name(HTML::EventHandler); \
  103. HTML::EventHandler attribute_name();
  104. ENUMERATE_GLOBAL_EVENT_HANDLERS(__ENUMERATE)
  105. #undef __ENUMERATE
  106. void set_event_handler_attribute(const FlyString& name, HTML::EventHandler);
  107. HTML::EventHandler get_event_handler_attribute(const FlyString& name);
  108. protected:
  109. virtual DOM::EventTarget& global_event_handlers_to_event_target() = 0;
  110. };
  111. }