1 : /* -*- Mode: C++; 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) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsDOMEvent_h__
39 : #define nsDOMEvent_h__
40 :
41 : #include "nsIDOMEvent.h"
42 : #include "nsIDOMNSEvent.h"
43 : #include "nsISupports.h"
44 : #include "nsIPrivateDOMEvent.h"
45 : #include "nsCOMPtr.h"
46 : #include "nsIDOMEventTarget.h"
47 : #include "nsPIDOMWindow.h"
48 : #include "nsPoint.h"
49 : #include "nsGUIEvent.h"
50 : #include "nsCycleCollectionParticipant.h"
51 : #include "nsAutoPtr.h"
52 : #include "nsIJSNativeInitializer.h"
53 :
54 : class nsIContent;
55 : class nsPresContext;
56 : struct JSContext;
57 : struct JSObject;
58 :
59 : class nsDOMEvent : public nsIDOMEvent,
60 : public nsIDOMNSEvent,
61 : public nsIPrivateDOMEvent,
62 : public nsIJSNativeInitializer
63 : {
64 : public:
65 :
66 : // Note: this enum must be kept in sync with sEventNames in nsDOMEvent.cpp
67 : enum nsDOMEvents {
68 : eDOMEvents_mousedown=0,
69 : eDOMEvents_mouseup,
70 : eDOMEvents_click,
71 : eDOMEvents_dblclick,
72 : eDOMEvents_mouseenter,
73 : eDOMEvents_mouseleave,
74 : eDOMEvents_mouseover,
75 : eDOMEvents_mouseout,
76 : eDOMEvents_MozMouseHittest,
77 : eDOMEvents_mousemove,
78 : eDOMEvents_contextmenu,
79 : eDOMEvents_keydown,
80 : eDOMEvents_keyup,
81 : eDOMEvents_keypress,
82 : eDOMEvents_focus,
83 : eDOMEvents_blur,
84 : eDOMEvents_load,
85 : eDOMEvents_popstate,
86 : eDOMEvents_beforescriptexecute,
87 : eDOMEvents_afterscriptexecute,
88 : eDOMEvents_beforeunload,
89 : eDOMEvents_unload,
90 : eDOMEvents_hashchange,
91 : eDOMEvents_readystatechange,
92 : eDOMEvents_abort,
93 : eDOMEvents_error,
94 : eDOMEvents_submit,
95 : eDOMEvents_reset,
96 : eDOMEvents_change,
97 : eDOMEvents_select,
98 : eDOMEvents_input,
99 : eDOMEvents_invalid,
100 : eDOMEvents_text,
101 : eDOMEvents_compositionstart,
102 : eDOMEvents_compositionend,
103 : eDOMEvents_compositionupdate,
104 : eDOMEvents_popupShowing,
105 : eDOMEvents_popupShown,
106 : eDOMEvents_popupHiding,
107 : eDOMEvents_popupHidden,
108 : eDOMEvents_close,
109 : eDOMEvents_command,
110 : eDOMEvents_broadcast,
111 : eDOMEvents_commandupdate,
112 : eDOMEvents_dragenter,
113 : eDOMEvents_dragover,
114 : eDOMEvents_dragexit,
115 : eDOMEvents_dragdrop,
116 : eDOMEvents_draggesture,
117 : eDOMEvents_drag,
118 : eDOMEvents_dragend,
119 : eDOMEvents_dragstart,
120 : eDOMEvents_dragleave,
121 : eDOMEvents_drop,
122 : eDOMEvents_resize,
123 : eDOMEvents_scroll,
124 : eDOMEvents_overflow,
125 : eDOMEvents_underflow,
126 : eDOMEvents_overflowchanged,
127 : eDOMEvents_subtreemodified,
128 : eDOMEvents_nodeinserted,
129 : eDOMEvents_noderemoved,
130 : eDOMEvents_noderemovedfromdocument,
131 : eDOMEvents_nodeinsertedintodocument,
132 : eDOMEvents_attrmodified,
133 : eDOMEvents_characterdatamodified,
134 : eDOMEvents_DOMActivate,
135 : eDOMEvents_DOMFocusIn,
136 : eDOMEvents_DOMFocusOut,
137 : eDOMEvents_pageshow,
138 : eDOMEvents_pagehide,
139 : eDOMEvents_DOMMouseScroll,
140 : eDOMEvents_MozMousePixelScroll,
141 : eDOMEvents_offline,
142 : eDOMEvents_online,
143 : eDOMEvents_copy,
144 : eDOMEvents_cut,
145 : eDOMEvents_paste,
146 : eDOMEvents_open,
147 : eDOMEvents_message,
148 : eDOMEvents_show,
149 : eDOMEvents_SVGLoad,
150 : eDOMEvents_SVGUnload,
151 : eDOMEvents_SVGAbort,
152 : eDOMEvents_SVGError,
153 : eDOMEvents_SVGResize,
154 : eDOMEvents_SVGScroll,
155 : eDOMEvents_SVGZoom,
156 : eDOMEvents_beginEvent,
157 : eDOMEvents_endEvent,
158 : eDOMEvents_repeatEvent,
159 : #ifdef MOZ_MEDIA
160 : eDOMEvents_loadstart,
161 : eDOMEvents_progress,
162 : eDOMEvents_suspend,
163 : eDOMEvents_emptied,
164 : eDOMEvents_stalled,
165 : eDOMEvents_play,
166 : eDOMEvents_pause,
167 : eDOMEvents_loadedmetadata,
168 : eDOMEvents_loadeddata,
169 : eDOMEvents_waiting,
170 : eDOMEvents_playing,
171 : eDOMEvents_canplay,
172 : eDOMEvents_canplaythrough,
173 : eDOMEvents_seeking,
174 : eDOMEvents_seeked,
175 : eDOMEvents_timeupdate,
176 : eDOMEvents_ended,
177 : eDOMEvents_ratechange,
178 : eDOMEvents_durationchange,
179 : eDOMEvents_volumechange,
180 : eDOMEvents_mozaudioavailable,
181 : #endif
182 : eDOMEvents_afterpaint,
183 : eDOMEvents_beforeresize,
184 : eDOMEvents_mozfullscreenchange,
185 : eDOMEvents_mozfullscreenerror,
186 : eDOMEvents_MozSwipeGesture,
187 : eDOMEvents_MozMagnifyGestureStart,
188 : eDOMEvents_MozMagnifyGestureUpdate,
189 : eDOMEvents_MozMagnifyGesture,
190 : eDOMEvents_MozRotateGestureStart,
191 : eDOMEvents_MozRotateGestureUpdate,
192 : eDOMEvents_MozRotateGesture,
193 : eDOMEvents_MozTapGesture,
194 : eDOMEvents_MozPressTapGesture,
195 : eDOMEvents_MozTouchDown,
196 : eDOMEvents_MozTouchMove,
197 : eDOMEvents_MozTouchUp,
198 : eDOMEvents_touchstart,
199 : eDOMEvents_touchend,
200 : eDOMEvents_touchmove,
201 : eDOMEvents_touchcancel,
202 : eDOMEvents_touchenter,
203 : eDOMEvents_touchleave,
204 : eDOMEvents_MozScrolledAreaChanged,
205 : eDOMEvents_transitionend,
206 : eDOMEvents_animationstart,
207 : eDOMEvents_animationend,
208 : eDOMEvents_animationiteration,
209 : eDOMEvents_devicemotion,
210 : eDOMEvents_deviceorientation
211 : };
212 :
213 : nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
214 : virtual ~nsDOMEvent();
215 :
216 29 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
217 241238 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMEvent, nsIDOMEvent)
218 :
219 : // nsIDOMEvent Interface
220 : NS_DECL_NSIDOMEVENT
221 :
222 : // nsIDOMNSEvent Interface
223 : NS_DECL_NSIDOMNSEVENT
224 :
225 : // nsIPrivateDOMEvent interface
226 : NS_IMETHOD DuplicatePrivateData();
227 : NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
228 : NS_IMETHOD_(bool) IsDispatchStopped();
229 : NS_IMETHOD_(nsEvent*) GetInternalNSEvent();
230 : NS_IMETHOD SetTrusted(bool aTrusted);
231 :
232 : // nsIJSNativeInitializer
233 : NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
234 : PRUint32 aArgc, jsval* aArgv);
235 :
236 : virtual nsresult InitFromCtor(const nsAString& aType,
237 : JSContext* aCx, jsval* aVal);
238 :
239 : void InitPresContextData(nsPresContext* aPresContext);
240 :
241 : virtual void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
242 : virtual bool Deserialize(const IPC::Message* aMsg, void** aIter);
243 :
244 : static PopupControlState GetEventPopupControlState(nsEvent *aEvent);
245 :
246 : static void PopupAllowedEventsChanged();
247 :
248 : static void Shutdown();
249 :
250 : static const char* GetEventName(PRUint32 aEventType);
251 : static nsIntPoint GetClientCoords(nsPresContext* aPresContext,
252 : nsEvent* aEvent,
253 : nsIntPoint aPoint,
254 : nsIntPoint aDefaultPoint);
255 : static nsIntPoint GetPageCoords(nsPresContext* aPresContext,
256 : nsEvent* aEvent,
257 : nsIntPoint aPoint,
258 : nsIntPoint aDefaultPoint);
259 : static nsIntPoint GetScreenCoords(nsPresContext* aPresContext,
260 : nsEvent* aEvent,
261 : nsIntPoint aPoint);
262 : protected:
263 :
264 : // Internal helper functions
265 : nsresult SetEventType(const nsAString& aEventTypeArg);
266 : already_AddRefed<nsIContent> GetTargetFromFrame();
267 :
268 : nsEvent* mEvent;
269 : nsRefPtr<nsPresContext> mPresContext;
270 : nsCOMPtr<nsIDOMEventTarget> mExplicitOriginalTarget;
271 : nsString mCachedType;
272 : bool mEventIsInternal;
273 : bool mPrivateDataDuplicated;
274 : };
275 :
276 : #define NS_FORWARD_TO_NSDOMEVENT \
277 : NS_FORWARD_NSIDOMEVENT(nsDOMEvent::)
278 :
279 : #endif // nsDOMEvent_h__
|