nsIDOMEvent.idl 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "domstubs.idl"
  6. interface nsIDOMEventTarget;
  7. [ptr] native WidgetEvent(mozilla::WidgetEvent);
  8. [ptr] native DOMEventPtr(mozilla::dom::Event);
  9. [ptr] native IPCMessagePtr(IPC::Message);
  10. [ptr] native ConstIPCMessagePtr(const IPC::Message);
  11. [ptr] native PickleIterator(PickleIterator);
  12. [ptr] native EventTargetPtr(mozilla::dom::EventTarget);
  13. %{C++
  14. #ifdef ERROR
  15. #undef ERROR
  16. #endif
  17. #include "mozilla/EventForwards.h"
  18. class nsPresContext;
  19. class nsInvalidateRequestList;
  20. namespace IPC {
  21. class Message;
  22. }
  23. class PickleIterator;
  24. namespace mozilla {
  25. namespace dom {
  26. class Event;
  27. class EventTarget;
  28. } // namespace dom
  29. } // namespace mozilla
  30. %}
  31. /**
  32. * The nsIDOMEvent interface is the primary datatype for all events in
  33. * the Document Object Model.
  34. *
  35. * For more information on this interface please see
  36. * http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html and
  37. * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  38. */
  39. [builtinclass, uuid(f58daacf-4d1a-4002-8fd7-06b614dfbcf6)]
  40. interface nsIDOMEvent : nsISupports
  41. {
  42. // PhaseType
  43. /**
  44. * The event isn't being dispatched.
  45. */
  46. const unsigned short NONE = 0;
  47. /**
  48. * The current event phase is the capturing phase.
  49. */
  50. const unsigned short CAPTURING_PHASE = 1;
  51. /**
  52. * The event is currently being evaluated at the target EventTarget.
  53. */
  54. const unsigned short AT_TARGET = 2;
  55. /**
  56. * The current event phase is the bubbling phase.
  57. */
  58. const unsigned short BUBBLING_PHASE = 3;
  59. /**
  60. * The name of the event (case-insensitive). The name must be an XML
  61. * name.
  62. */
  63. readonly attribute DOMString type;
  64. /**
  65. * Used to indicate the EventTarget to which the event was originally
  66. * dispatched.
  67. */
  68. readonly attribute nsIDOMEventTarget target;
  69. /**
  70. * Used to indicate the EventTarget whose EventListeners are currently
  71. * being processed. This is particularly useful during capturing and
  72. * bubbling.
  73. */
  74. readonly attribute nsIDOMEventTarget currentTarget;
  75. /**
  76. * Used to indicate which phase of event flow is currently being
  77. * evaluated.
  78. */
  79. readonly attribute unsigned short eventPhase;
  80. /**
  81. * Used to indicate whether or not an event is a bubbling event. If the
  82. * event can bubble the value is true, else the value is false.
  83. */
  84. readonly attribute boolean bubbles;
  85. /**
  86. * Used to indicate whether or not an event can have its default action
  87. * prevented. If the default action can be prevented the value is true,
  88. * else the value is false.
  89. */
  90. readonly attribute boolean cancelable;
  91. /**
  92. * Used to specify the time (in milliseconds relative to the epoch) at
  93. * which the event was created. Due to the fact that some systems may
  94. * not provide this information the value of timeStamp may be not
  95. * available for all events. When not available, a value of 0 will be
  96. * returned. Examples of epoch time are the time of the system start or
  97. * 0:0:0 UTC 1st January 1970.
  98. */
  99. readonly attribute DOMTimeStamp timeStamp;
  100. /**
  101. * The stopPropagation method is used prevent further propagation of an
  102. * event during event flow. If this method is called by any
  103. * EventListener the event will cease propagating through the tree. The
  104. * event will complete dispatch to all listeners on the current
  105. * EventTarget before event flow stops. This method may be used during
  106. * any stage of event flow.
  107. */
  108. void stopPropagation();
  109. /**
  110. * If an event is cancelable, the preventDefault method is used to
  111. * signify that the event is to be canceled, meaning any default action
  112. * normally taken by the implementation as a result of the event will
  113. * not occur. If, during any stage of event flow, the preventDefault
  114. * method is called the event is canceled. Any default action associated
  115. * with the event will not occur. Calling this method for a
  116. * non-cancelable event has no effect. Once preventDefault has been
  117. * called it will remain in effect throughout the remainder of the
  118. * event's propagation. This method may be used during any stage of
  119. * event flow.
  120. */
  121. void preventDefault();
  122. /**
  123. * The initEvent method is used to initialize the value of an Event
  124. * created through the DocumentEvent interface. This method may only be
  125. * called before the Event has been dispatched via the dispatchEvent
  126. * method, though it may be called multiple times during that phase if
  127. * necessary. If called multiple times the final invocation takes
  128. * precedence. If called from a subclass of Event interface only the
  129. * values specified in the initEvent method are modified, all other
  130. * attributes are left unchanged.
  131. *
  132. * @param eventTypeArg Specifies the event type. This type may be
  133. * any event type currently defined in this
  134. * specification or a new event type.. The string
  135. * must be an XML name.
  136. * Any new event type must not begin with any
  137. * upper, lower, or mixed case version of the
  138. * string "DOM". This prefix is reserved for
  139. * future DOM event sets. It is also strongly
  140. * recommended that third parties adding their
  141. * own events use their own prefix to avoid
  142. * confusion and lessen the probability of
  143. * conflicts with other new events.
  144. * @param canBubbleArg Specifies whether or not the event can bubble.
  145. * @param cancelableArg Specifies whether or not the event's default
  146. * action can be prevented.
  147. */
  148. [notxpcom,nostdcall]
  149. void initEvent(in DOMString eventTypeArg,
  150. in boolean canBubbleArg,
  151. in boolean cancelableArg);
  152. /**
  153. * Used to indicate whether preventDefault() has been called for this event.
  154. */
  155. readonly attribute boolean defaultPrevented;
  156. /**
  157. * Prevents other event listeners from being triggered and,
  158. * unlike Event.stopPropagation() its effect is immediate.
  159. */
  160. void stopImmediatePropagation();
  161. const long ALT_MASK = 0x00000001;
  162. const long CONTROL_MASK = 0x00000002;
  163. const long SHIFT_MASK = 0x00000004;
  164. const long META_MASK = 0x00000008;
  165. /** The original target of the event, before any retargetings. */
  166. readonly attribute nsIDOMEventTarget originalTarget;
  167. /**
  168. * The explicit original target of the event. If the event was retargeted
  169. * for some reason other than an anonymous boundary crossing, this will be set
  170. * to the target before the retargeting occurs. For example, mouse events
  171. * are retargeted to their parent node when they happen over text nodes (bug
  172. * 185889), and in that case .target will show the parent and
  173. * .explicitOriginalTarget will show the text node.
  174. * .explicitOriginalTarget differs from .originalTarget in that it will never
  175. * contain anonymous content.
  176. */
  177. readonly attribute nsIDOMEventTarget explicitOriginalTarget;
  178. /**
  179. * @deprecated Use nsIDOMEvent::defaultPrevented.
  180. * To be removed in bug 691151.
  181. */
  182. boolean getPreventDefault();
  183. readonly attribute boolean isTrusted;
  184. attribute boolean cancelBubble;
  185. [noscript] void duplicatePrivateData();
  186. [noscript] void setTarget(in nsIDOMEventTarget aTarget);
  187. [notxpcom] boolean IsDispatchStopped();
  188. [notxpcom] WidgetEvent WidgetEventPtr();
  189. [noscript,notxpcom] void SetTrusted(in boolean aTrusted);
  190. [notxpcom] void Serialize(in IPCMessagePtr aMsg,
  191. in boolean aSerializeInterfaceType);
  192. [notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, in PickleIterator aIter);
  193. [noscript,notxpcom] void SetOwner(in EventTargetPtr aOwner);
  194. [notxpcom] DOMEventPtr InternalDOMEvent();
  195. [noscript] void stopCrossProcessForwarding();
  196. };