nsIDOMEventTarget.idl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 2000
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Tom Pixley <[email protected]> (original author)
  24. * Johnny Stenback <[email protected]>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either of the GNU General Public License Version 2 or later (the "GPL"),
  28. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "domstubs.idl"
  40. /**
  41. * The nsIDOMEventTarget interface is the interface implemented by all
  42. * event targets in the Document Object Model.
  43. *
  44. * For more information on this interface please see
  45. * http://www.w3.org/TR/DOM-Level-2-Events/
  46. *
  47. * @status FROZEN
  48. */
  49. [scriptable, uuid(1c773b30-d1cf-11d2-bd95-00805f8ae3f4)]
  50. interface nsIDOMEventTarget : nsISupports
  51. {
  52. /**
  53. * This method allows the registration of event listeners on the event target.
  54. * If an EventListener is added to an EventTarget while it is processing an
  55. * event, it will not be triggered by the current actions but may be
  56. * triggered during a later stage of event flow, such as the bubbling phase.
  57. *
  58. * If multiple identical EventListeners are registered on the same
  59. * EventTarget with the same parameters the duplicate instances are
  60. * discarded. They do not cause the EventListener to be called twice
  61. * and since they are discarded they do not need to be removed with the
  62. * removeEventListener method.
  63. *
  64. * @param type The event type for which the user is registering
  65. * @param listener The listener parameter takes an interface
  66. * implemented by the user which contains the methods
  67. * to be called when the event occurs.
  68. * @param useCapture If true, useCapture indicates that the user
  69. * wishes to initiate capture. After initiating
  70. * capture, all events of the specified type will be
  71. * dispatched to the registered EventListener before
  72. * being dispatched to any EventTargets beneath them
  73. * in the tree. Events which are bubbling upward
  74. * through the tree will not trigger an
  75. * EventListener designated to use capture.
  76. */
  77. void addEventListener(in DOMString type,
  78. in nsIDOMEventListener listener,
  79. in boolean useCapture);
  80. /**
  81. * This method allows the removal of event listeners from the event
  82. * target. If an EventListener is removed from an EventTarget while it
  83. * is processing an event, it will not be triggered by the current actions.
  84. * EventListeners can never be invoked after being removed.
  85. * Calling removeEventListener with arguments which do not identify any
  86. * currently registered EventListener on the EventTarget has no effect.
  87. *
  88. * @param type Specifies the event type of the EventListener being
  89. * removed.
  90. * @param listener The EventListener parameter indicates the
  91. * EventListener to be removed.
  92. * @param useCapture Specifies whether the EventListener being
  93. * removed was registered as a capturing listener or
  94. * not. If a listener was registered twice, one with
  95. * capture and one without, each must be removed
  96. * separately. Removal of a capturing listener does
  97. * not affect a non-capturing version of the same
  98. * listener, and vice versa.
  99. */
  100. void removeEventListener(in DOMString type,
  101. in nsIDOMEventListener listener,
  102. in boolean useCapture);
  103. /**
  104. * This method allows the dispatch of events into the implementations
  105. * event model. Events dispatched in this manner will have the same
  106. * capturing and bubbling behavior as events dispatched directly by the
  107. * implementation. The target of the event is the EventTarget on which
  108. * dispatchEvent is called.
  109. *
  110. * @param evt Specifies the event type, behavior, and contextual
  111. * information to be used in processing the event.
  112. * @return Indicates whether any of the listeners which handled the
  113. * event called preventDefault. If preventDefault was called
  114. * the value is false, else the value is true.
  115. * @throws UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was
  116. * not specified by initializing the event before
  117. * dispatchEvent was called. Specification of the Event's
  118. * type as null or an empty string will also trigger this
  119. * exception.
  120. */
  121. boolean dispatchEvent(in nsIDOMEvent evt)
  122. raises(DOMException);
  123. };