|
1 /* -*- Mode: C++; 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 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIDOMEventListener; |
|
9 interface nsIDOMEventTarget; |
|
10 |
|
11 /** |
|
12 * An instance of this interface describes how an event listener |
|
13 * was added to an event target. |
|
14 */ |
|
15 [scriptable, uuid(c4776eb7-05bc-49ce-a0ca-6213a346d53a)] |
|
16 interface nsIEventListenerInfo : nsISupports |
|
17 { |
|
18 /** |
|
19 * The type of the event for which the listener was added. |
|
20 * Null if the listener is for all the events. |
|
21 */ |
|
22 readonly attribute AString type; |
|
23 readonly attribute boolean capturing; |
|
24 readonly attribute boolean allowsUntrusted; |
|
25 readonly attribute boolean inSystemEventGroup; |
|
26 |
|
27 /** |
|
28 * The underlying JS object of the event listener, if this listener |
|
29 * has one. Null otherwise. |
|
30 */ |
|
31 [implicit_jscontext] |
|
32 readonly attribute jsval listenerObject; |
|
33 |
|
34 /** |
|
35 * Tries to serialize event listener to a string. |
|
36 * Returns null if serialization isn't possible |
|
37 * (for example with C++ listeners). |
|
38 */ |
|
39 AString toSource(); |
|
40 |
|
41 /** |
|
42 * If jsdIDebuggerService is active and the listener is implemented in JS, |
|
43 * this returns the listener as a jsdIValue. Otherwise null. |
|
44 */ |
|
45 nsISupports getDebugObject(); |
|
46 }; |
|
47 |
|
48 [scriptable, uuid(f6964bfb-dabe-4cab-9733-be0ee2bf8171)] |
|
49 interface nsIEventListenerService : nsISupports |
|
50 { |
|
51 /** |
|
52 * Returns an array of nsIEventListenerInfo objects. |
|
53 * If aEventTarget doesn't have any listeners, this returns null. |
|
54 */ |
|
55 void getListenerInfoFor(in nsIDOMEventTarget aEventTarget, |
|
56 [optional] out unsigned long aCount, |
|
57 [retval, array, size_is(aCount)] out |
|
58 nsIEventListenerInfo aOutArray); |
|
59 |
|
60 /** |
|
61 * Returns an array of event targets. |
|
62 * aEventTarget will be at index 0. |
|
63 * The objects are the ones that would be used as DOMEvent.currentTarget while |
|
64 * dispatching an event to aEventTarget |
|
65 * @note Some events, especially 'load', may actually have a shorter |
|
66 * event target chain than what this methods returns. |
|
67 */ |
|
68 void getEventTargetChainFor(in nsIDOMEventTarget aEventTarget, |
|
69 [optional] out unsigned long aCount, |
|
70 [retval, array, size_is(aCount)] out |
|
71 nsIDOMEventTarget aOutArray); |
|
72 |
|
73 /** |
|
74 * Returns true if a event target has any listener for the given type. |
|
75 */ |
|
76 boolean hasListenersFor(in nsIDOMEventTarget aEventTarget, |
|
77 in DOMString aType); |
|
78 |
|
79 /** |
|
80 * Add a system-group eventlistener to a event target. |
|
81 */ |
|
82 void addSystemEventListener(in nsIDOMEventTarget target, |
|
83 in DOMString type, |
|
84 in nsIDOMEventListener listener, |
|
85 in boolean useCapture); |
|
86 |
|
87 /** |
|
88 * Remove a system-group eventlistener from a event target. |
|
89 */ |
|
90 void removeSystemEventListener(in nsIDOMEventTarget target, |
|
91 in DOMString type, |
|
92 in nsIDOMEventListener listener, |
|
93 in boolean useCapture); |
|
94 |
|
95 void addListenerForAllEvents(in nsIDOMEventTarget target, |
|
96 in nsIDOMEventListener listener, |
|
97 [optional] in boolean aUseCapture, |
|
98 [optional] in boolean aWantsUntrusted, |
|
99 [optional] in boolean aSystemEventGroup); |
|
100 |
|
101 void removeListenerForAllEvents(in nsIDOMEventTarget target, |
|
102 in nsIDOMEventListener listener, |
|
103 [optional] in boolean aUseCapture, |
|
104 [optional] in boolean aSystemEventGroup); |
|
105 }; |
|
106 |