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 : * Makoto Kato <m_kato@ga2.so-net.ne.jp>
24 : * Dean Tessman <dean_tessman@hotmail.com>
25 : * Thomas K. Dyas <tdyas@zecador.org> (simple gestures support)
26 : * Masayuki Nakano <masayuki@d-toybox.com>
27 : *
28 : * Alternatively, the contents of this file may be used under the terms of
29 : * either the GNU General Public License Version 2 or later (the "GPL"), or
30 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 : * in which case the provisions of the GPL or the LGPL are applicable instead
32 : * of those above. If you wish to allow use of your version of this file only
33 : * under the terms of either the GPL or the LGPL, and not to allow others to
34 : * use your version of this file under the terms of the MPL, indicate your
35 : * decision by deleting the provisions above and replace them with the notice
36 : * and other provisions required by the GPL or the LGPL. If you do not delete
37 : * the provisions above, a recipient may use your version of this file under
38 : * the terms of any one of the MPL, the GPL or the LGPL.
39 : *
40 : * ***** END LICENSE BLOCK ***** */
41 :
42 : #ifndef nsGUIEvent_h__
43 : #define nsGUIEvent_h__
44 :
45 : #include "nsCOMArray.h"
46 : #include "nsPoint.h"
47 : #include "nsRect.h"
48 : #include "nsRegion.h"
49 : #include "nsEvent.h"
50 : #include "nsStringGlue.h"
51 : #include "nsCOMPtr.h"
52 : #include "nsIAtom.h"
53 : #include "nsIDOMKeyEvent.h"
54 : #include "nsIDOMMouseEvent.h"
55 : #include "nsIDOMDataTransfer.h"
56 : #include "nsIDOMEventTarget.h"
57 : #include "nsIDOMTouchEvent.h"
58 : #include "nsWeakPtr.h"
59 : #include "nsIWidget.h"
60 : #include "nsTArray.h"
61 : #include "nsTraceRefcnt.h"
62 : #include "nsITransferable.h"
63 : #include "nsIVariant.h"
64 : #include "nsStyleConsts.h"
65 : #include "nsAutoPtr.h"
66 :
67 : namespace mozilla {
68 : namespace dom {
69 : class PBrowserParent;
70 : class PBrowserChild;
71 : }
72 : namespace plugins {
73 : class PPluginInstanceChild;
74 : }
75 : }
76 :
77 : #ifdef ACCESSIBILITY
78 : class nsAccessible;
79 : #endif
80 : class nsRenderingContext;
81 : class nsIMenuItem;
82 : class nsIContent;
83 : class nsIURI;
84 : class nsHashKey;
85 :
86 : /**
87 : * Event Struct Types
88 : */
89 : #define NS_EVENT 1
90 : #define NS_GUI_EVENT 2
91 : #define NS_SIZE_EVENT 3
92 : #define NS_SIZEMODE_EVENT 4
93 : #define NS_ZLEVEL_EVENT 5
94 : #define NS_PAINT_EVENT 6
95 : #define NS_SCROLLBAR_EVENT 7
96 : #define NS_INPUT_EVENT 8
97 : #define NS_KEY_EVENT 9
98 : #define NS_MOUSE_EVENT 10
99 : #define NS_SCRIPT_ERROR_EVENT 12
100 : #define NS_TEXT_EVENT 13
101 : #define NS_COMPOSITION_EVENT 14
102 : #define NS_MOUSE_SCROLL_EVENT 16
103 : #define NS_SCROLLPORT_EVENT 18
104 : #define NS_MUTATION_EVENT 19 // |nsMutationEvent| in content
105 : #define NS_ACCESSIBLE_EVENT 20
106 : #define NS_FORM_EVENT 21
107 : #define NS_FOCUS_EVENT 22
108 : #define NS_POPUP_EVENT 23
109 : #define NS_COMMAND_EVENT 24
110 : #define NS_SCROLLAREA_EVENT 25
111 : #define NS_TRANSITION_EVENT 26
112 : #define NS_ANIMATION_EVENT 27
113 :
114 : #define NS_UI_EVENT 28
115 : #define NS_SVG_EVENT 30
116 : #define NS_SVGZOOM_EVENT 31
117 : #define NS_SMIL_TIME_EVENT 32
118 :
119 : #define NS_QUERY_CONTENT_EVENT 33
120 :
121 : #define NS_DRAG_EVENT 35
122 : #define NS_NOTIFYPAINT_EVENT 36
123 : #define NS_SIMPLE_GESTURE_EVENT 37
124 : #define NS_SELECTION_EVENT 38
125 : #define NS_CONTENT_COMMAND_EVENT 39
126 : #define NS_GESTURENOTIFY_EVENT 40
127 : #define NS_UISTATECHANGE_EVENT 41
128 : #define NS_MOZTOUCH_EVENT 42
129 : #define NS_PLUGIN_EVENT 43
130 : #define NS_TOUCH_EVENT 44
131 :
132 : // These flags are sort of a mess. They're sort of shared between event
133 : // listener flags and event flags, but only some of them. You've been
134 : // warned!
135 : #define NS_EVENT_FLAG_NONE 0x0000
136 : #define NS_EVENT_FLAG_TRUSTED 0x0001
137 : #define NS_EVENT_FLAG_BUBBLE 0x0002
138 : #define NS_EVENT_FLAG_CAPTURE 0x0004
139 : #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
140 : #define NS_EVENT_FLAG_NO_DEFAULT 0x0010
141 : #define NS_EVENT_FLAG_CANT_CANCEL 0x0020
142 : #define NS_EVENT_FLAG_CANT_BUBBLE 0x0040
143 : #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
144 : #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
145 : #define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
146 : // Event has been dispatched at least once
147 : #define NS_EVENT_DISPATCHED 0x0400
148 : #define NS_EVENT_FLAG_DISPATCHING 0x0800
149 : // When an event is synthesized for testing, this flag will be set.
150 : // Note that this is currently used only with mouse events, because this
151 : // flag is not needed on other events now. It could be added to other
152 : // events.
153 : #define NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT 0x1000
154 :
155 : // Use this flag if the event should be dispatched only to chrome.
156 : #define NS_EVENT_FLAG_ONLY_CHROME_DISPATCH 0x2000
157 :
158 : // A flag for drag&drop handling.
159 : #define NS_EVENT_FLAG_NO_DEFAULT_CALLED_IN_CONTENT 0x4000
160 :
161 : #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
162 :
163 : #define NS_EVENT_FLAG_EXCEPTION_THROWN 0x10000
164 :
165 : #define NS_EVENT_FLAG_PREVENT_MULTIPLE_ACTIONS 0x20000
166 :
167 : #define NS_EVENT_RETARGET_TO_NON_NATIVE_ANONYMOUS 0x40000
168 :
169 : #define NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY 0x80000
170 :
171 : #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
172 : #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
173 :
174 : #define NS_EVENT_TYPE_NULL 0
175 :
176 : /**
177 : * GUI MESSAGES
178 : */
179 : //@{
180 : #define NS_EVENT_NULL 0
181 :
182 :
183 : #define NS_WINDOW_START 100
184 :
185 : // Widget is being created
186 : #define NS_CREATE (NS_WINDOW_START)
187 : // Widget may be destroyed
188 : #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
189 : // Widget is being destroyed
190 : #define NS_DESTROY (NS_WINDOW_START + 2)
191 : // Widget was resized
192 : #define NS_SIZE (NS_WINDOW_START + 3)
193 : // Widget size mode was changed
194 : #define NS_SIZEMODE (NS_WINDOW_START + 4)
195 : // Widget got activated
196 : #define NS_ACTIVATE (NS_WINDOW_START + 7)
197 : // Widget got deactivated
198 : #define NS_DEACTIVATE (NS_WINDOW_START + 8)
199 : // top-level window z-level change request
200 : #define NS_SETZLEVEL (NS_WINDOW_START + 9)
201 : // Widget was repainted (dispatched when it's safe to move widgets, but
202 : // only on some platforms (including GTK2 and Windows))
203 : #define NS_DID_PAINT (NS_WINDOW_START + 28)
204 : // Widget will need to be painted
205 : #define NS_WILL_PAINT (NS_WINDOW_START + 29)
206 : // Widget needs to be repainted
207 : #define NS_PAINT (NS_WINDOW_START + 30)
208 : // Key is pressed within a window
209 : #define NS_KEY_PRESS (NS_WINDOW_START + 31)
210 : // Key is released within a window
211 : #define NS_KEY_UP (NS_WINDOW_START + 32)
212 : // Key is pressed within a window
213 : #define NS_KEY_DOWN (NS_WINDOW_START + 33)
214 : // Window has been moved to a new location.
215 : // The events point contains the x, y location in screen coordinates
216 : #define NS_MOVE (NS_WINDOW_START + 34)
217 :
218 : // Tab control's selected tab has changed
219 : #define NS_TABCHANGE (NS_WINDOW_START + 35)
220 :
221 : #define NS_OS_TOOLBAR (NS_WINDOW_START + 36)
222 :
223 : // Indicates the display has changed depth
224 : #define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
225 :
226 : // Indicates a theme change has occurred
227 : #define NS_THEMECHANGED (NS_WINDOW_START + 41)
228 :
229 : // Indicates a System color has changed. It is the platform
230 : // toolkits responsibility to invalidate the window to
231 : // ensure that it is drawn using the current system colors.
232 : #define NS_SYSCOLORCHANGED (NS_WINDOW_START + 42)
233 :
234 : // Indicates that the ui state such as whether to show focus or
235 : // keyboard accelerator indicators has changed.
236 : #define NS_UISTATECHANGED (NS_WINDOW_START + 43)
237 :
238 : // Done sizing or moving a window, so ensure that the mousedown state was cleared.
239 : #define NS_DONESIZEMOVE (NS_WINDOW_START + 44)
240 :
241 : #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
242 : #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
243 :
244 : // A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be
245 : // used when the window is not active. NS_PLUGIN_FOCUS should be used when
246 : // the window is active. In the latter case, the dispatcher of the event
247 : // is expected to ensure that the plugin's widget is focused beforehand.
248 : #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
249 : #define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63)
250 :
251 : #define NS_OFFLINE (NS_WINDOW_START + 64)
252 : #define NS_ONLINE (NS_WINDOW_START + 65)
253 :
254 : // Indicates a resize will occur
255 : #define NS_BEFORERESIZE_EVENT (NS_WINDOW_START + 66)
256 :
257 : #define NS_MOUSE_MESSAGE_START 300
258 : #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
259 : #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
260 : #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
261 : #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
262 : #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
263 : #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
264 : #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
265 : #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
266 : #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
267 : #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
268 : #define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
269 : #define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34)
270 : #define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35)
271 :
272 : #define NS_CONTEXTMENU_MESSAGE_START 500
273 : #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
274 :
275 : #define NS_SCROLLBAR_MESSAGE_START 1000
276 : #define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
277 : #define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
278 : #define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
279 : #define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
280 : #define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
281 :
282 : #define NS_STREAM_EVENT_START 1100
283 : #define NS_LOAD (NS_STREAM_EVENT_START)
284 : #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
285 : #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
286 : #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
287 : #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
288 : #define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
289 : #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
290 : #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
291 : #define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8)
292 :
293 : #define NS_FORM_EVENT_START 1200
294 : #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
295 : #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
296 : #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
297 : #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
298 : #define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
299 : #define NS_FORM_INVALID (NS_FORM_EVENT_START + 5)
300 :
301 : //Need separate focus/blur notifications for non-native widgets
302 : #define NS_FOCUS_EVENT_START 1300
303 : #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
304 : #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
305 :
306 : #define NS_DRAGDROP_EVENT_START 1400
307 : #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
308 : #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
309 : #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
310 : #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
311 : #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
312 : #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
313 : #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
314 : #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
315 : #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
316 : #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
317 : #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
318 : #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
319 :
320 : // Events for popups
321 : #define NS_XUL_EVENT_START 1500
322 : #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
323 : #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
324 : #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
325 : #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
326 : // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
327 : #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
328 : #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
329 : //@}
330 :
331 : // Scroll events
332 : #define NS_MOUSE_SCROLL_START 1600
333 : #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
334 : #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
335 :
336 : #define NS_SCROLLPORT_START 1700
337 : #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
338 : #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
339 : #define NS_SCROLLPORT_OVERFLOWCHANGED (NS_SCROLLPORT_START+2)
340 :
341 : // Mutation events defined elsewhere starting at 1800
342 :
343 : // accessible events
344 : #define NS_ACCESSIBLE_START 1900
345 : #define NS_GETACCESSIBLE (NS_ACCESSIBLE_START)
346 :
347 : #define NS_USER_DEFINED_EVENT 2000
348 :
349 : // composition events
350 : #define NS_COMPOSITION_EVENT_START 2200
351 : #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
352 : #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
353 : #define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2)
354 :
355 : // text events
356 : #define NS_TEXT_START 2400
357 : #define NS_TEXT_TEXT (NS_TEXT_START)
358 :
359 : // UI events
360 : #define NS_UI_EVENT_START 2500
361 : // this is not to be confused with NS_ACTIVATE!
362 : #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
363 : #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
364 : #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
365 :
366 : // pagetransition events
367 : #define NS_PAGETRANSITION_START 2700
368 : #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
369 : #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
370 :
371 : // SVG events
372 : #define NS_SVG_EVENT_START 2800
373 : #define NS_SVG_LOAD (NS_SVG_EVENT_START)
374 : #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
375 : #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
376 : #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
377 : #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
378 : #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
379 :
380 : // SVG Zoom events
381 : #define NS_SVGZOOM_EVENT_START 2900
382 : #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
383 :
384 : // XUL command events
385 : #define NS_XULCOMMAND_EVENT_START 3000
386 : #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
387 :
388 : // Cut, copy, paste events
389 : #define NS_CUTCOPYPASTE_EVENT_START 3100
390 : #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
391 : #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
392 : #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
393 :
394 : // Query the content information
395 : #define NS_QUERY_CONTENT_EVENT_START 3200
396 : // Query for the selected text information, it return the selection offset,
397 : // selection length and selected text.
398 : #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
399 : // Query for the text content of specified range, it returns actual lengh (if
400 : // the specified range is too long) and the text of the specified range.
401 : // Returns the entire text if requested length > actual length.
402 : #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
403 : // Query for the caret rect of nth insertion point. The offset of the result is
404 : // relative position from the top level widget.
405 : #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
406 : // Query for the bounding rect of a range of characters. This works on any
407 : // valid character range given offset and length. Result is relative to top
408 : // level widget coordinates
409 : #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
410 : // Query for the bounding rect of the current focused frame. Result is relative
411 : // to top level widget coordinates
412 : #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
413 : // Query for the current state of the content. The particular members of
414 : // mReply that are set for each query content event will be valid on success.
415 : #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
416 : // Query for the selection in the form of a nsITransferable.
417 : #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
418 : // Query for character at a point. This returns the character offset and its
419 : // rect. The point is specified by nsEvent::refPoint.
420 : #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
421 : // Query if the DOM element under nsEvent::refPoint belongs to our widget
422 : // or not.
423 : #define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9)
424 : // Query for some information about mouse wheel event's target
425 : // XXX This is used only for supporting high resolution mouse scroll on Windows
426 : // and it's going to be reimplemented with another approach. At that time,
427 : // this even is going to be removed. Therefore, DON'T use this event for
428 : // other purpose.
429 : #define NS_QUERY_SCROLL_TARGET_INFO (NS_QUERY_CONTENT_EVENT_START + 99)
430 :
431 : // Video events
432 : #define NS_MEDIA_EVENT_START 3300
433 : #define NS_LOADSTART (NS_MEDIA_EVENT_START)
434 : #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
435 : #define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
436 : #define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
437 : #define NS_STALLED (NS_MEDIA_EVENT_START+4)
438 : #define NS_PLAY (NS_MEDIA_EVENT_START+5)
439 : #define NS_PAUSE (NS_MEDIA_EVENT_START+6)
440 : #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
441 : #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
442 : #define NS_WAITING (NS_MEDIA_EVENT_START+9)
443 : #define NS_PLAYING (NS_MEDIA_EVENT_START+10)
444 : #define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
445 : #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
446 : #define NS_SEEKING (NS_MEDIA_EVENT_START+13)
447 : #define NS_SEEKED (NS_MEDIA_EVENT_START+14)
448 : #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
449 : #define NS_ENDED (NS_MEDIA_EVENT_START+16)
450 : #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
451 : #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
452 : #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
453 : #define NS_MOZAUDIOAVAILABLE (NS_MEDIA_EVENT_START+20)
454 :
455 : // paint notification events
456 : #define NS_NOTIFYPAINT_START 3400
457 : #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
458 :
459 : // Simple gesture events
460 : #define NS_SIMPLE_GESTURE_EVENT_START 3500
461 : #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
462 : #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
463 : #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
464 : #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
465 : #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
466 : #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
467 : #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
468 : #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
469 : #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
470 :
471 : // These are used to send native events to plugins.
472 : #define NS_PLUGIN_EVENT_START 3600
473 : #define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START)
474 : #define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1)
475 :
476 : // Events to manipulate selection (nsSelectionEvent)
477 : #define NS_SELECTION_EVENT_START 3700
478 : // Clear any previous selection and set the given range as the selection
479 : #define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
480 :
481 : // Events of commands for the contents
482 : #define NS_CONTENT_COMMAND_EVENT_START 3800
483 : #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
484 : #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
485 : #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
486 : #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
487 : #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
488 : #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
489 : #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
490 : // NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the
491 : // currently focused content or latest DOM selection. This would normally be
492 : // the same element scrolled by keyboard scroll commands, except that this event
493 : // will scroll an element scrollable in either direction. I.e., if the nearest
494 : // scrollable ancestor element can only be scrolled vertically, and horizontal
495 : // scrolling is requested using this event, no scrolling will occur.
496 : #define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7)
497 :
498 : // Event to gesture notification
499 : #define NS_GESTURENOTIFY_EVENT_START 3900
500 :
501 : #define NS_ORIENTATION_EVENT 4000
502 :
503 : #define NS_SCROLLAREA_EVENT_START 4100
504 : #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
505 :
506 : #define NS_TRANSITION_EVENT_START 4200
507 : #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
508 :
509 : #define NS_ANIMATION_EVENT_START 4250
510 : #define NS_ANIMATION_START (NS_ANIMATION_EVENT_START)
511 : #define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1)
512 : #define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2)
513 :
514 : #define NS_SMIL_TIME_EVENT_START 4300
515 : #define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START)
516 : #define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1)
517 : #define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
518 :
519 : #define NS_MOZTOUCH_EVENT_START 4400
520 : #define NS_MOZTOUCH_DOWN (NS_MOZTOUCH_EVENT_START)
521 : #define NS_MOZTOUCH_MOVE (NS_MOZTOUCH_EVENT_START+1)
522 : #define NS_MOZTOUCH_UP (NS_MOZTOUCH_EVENT_START+2)
523 :
524 : // script notification events
525 : #define NS_NOTIFYSCRIPT_START 4500
526 : #define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
527 : #define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1)
528 :
529 : #define NS_PRINT_EVENT_START 4600
530 : #define NS_BEFOREPRINT (NS_PRINT_EVENT_START)
531 : #define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1)
532 :
533 : #define NS_MESSAGE_EVENT_START 4700
534 : #define NS_MESSAGE (NS_MESSAGE_EVENT_START)
535 :
536 : // Open and close events
537 : #define NS_OPENCLOSE_EVENT_START 4800
538 : #define NS_OPEN (NS_OPENCLOSE_EVENT_START)
539 : #define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1)
540 :
541 : // Device motion and orientation
542 : #define NS_DEVICE_ORIENTATION_START 4900
543 : #define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START)
544 : #define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1)
545 :
546 : #define NS_SHOW_EVENT 5000
547 :
548 : // Fullscreen DOM API
549 : #define NS_FULL_SCREEN_START 5100
550 : #define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START)
551 : #define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1)
552 :
553 : #define NS_TOUCH_EVENT_START 5200
554 : #define NS_TOUCH_START (NS_TOUCH_EVENT_START)
555 : #define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1)
556 : #define NS_TOUCH_END (NS_TOUCH_EVENT_START+2)
557 : #define NS_TOUCH_ENTER (NS_TOUCH_EVENT_START+3)
558 : #define NS_TOUCH_LEAVE (NS_TOUCH_EVENT_START+4)
559 : #define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+5)
560 :
561 : /**
562 : * Return status for event processors, nsEventStatus, is defined in
563 : * nsEvent.h.
564 : */
565 :
566 : /**
567 : * different types of (top-level) window z-level positioning
568 : */
569 : enum nsWindowZ {
570 : nsWindowZTop = 0, // on top
571 : nsWindowZBottom, // on bottom
572 : nsWindowZRelative // just below some specified widget
573 : };
574 :
575 : /**
576 : * General event
577 : */
578 :
579 : class nsEvent
580 0 : {
581 : protected:
582 90 : nsEvent(bool isTrusted, PRUint32 msg, PRUint8 structType)
583 : : eventStructType(structType),
584 : message(msg),
585 : refPoint(0, 0),
586 : time(0),
587 : flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
588 90 : userType(0)
589 : {
590 90 : MOZ_COUNT_CTOR(nsEvent);
591 90 : }
592 :
593 0 : nsEvent()
594 0 : {
595 0 : }
596 :
597 : public:
598 17405 : nsEvent(bool isTrusted, PRUint32 msg)
599 : : eventStructType(NS_EVENT),
600 : message(msg),
601 : refPoint(0, 0),
602 : time(0),
603 : flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
604 17405 : userType(0)
605 : {
606 17405 : MOZ_COUNT_CTOR(nsEvent);
607 17405 : }
608 :
609 17495 : ~nsEvent()
610 17495 : {
611 17495 : MOZ_COUNT_DTOR(nsEvent);
612 17495 : }
613 :
614 : // See event struct types
615 : PRUint8 eventStructType;
616 : // See GUI MESSAGES,
617 : PRUint32 message;
618 : // Relative to the widget of the event, or if there is no widget then it is
619 : // in screen coordinates. Not modified by layout code.
620 : nsIntPoint refPoint;
621 : // Elapsed time, in milliseconds, from a platform-specific zero time
622 : // to the time the message was created
623 : PRUint64 time;
624 : // Flags to hold event flow stage and capture/bubble cancellation
625 : // status. This is used also to indicate whether the event is trusted.
626 : PRUint32 flags;
627 : // Additional type info for user defined events
628 : nsCOMPtr<nsIAtom> userType;
629 : // Event targets, needed by DOM Events
630 : nsCOMPtr<nsIDOMEventTarget> target;
631 : nsCOMPtr<nsIDOMEventTarget> currentTarget;
632 : nsCOMPtr<nsIDOMEventTarget> originalTarget;
633 : };
634 :
635 : /**
636 : * General graphic user interface event
637 : */
638 :
639 : class nsGUIEvent : public nsEvent
640 2 : {
641 : protected:
642 2 : nsGUIEvent(bool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
643 : : nsEvent(isTrusted, msg, structType),
644 2 : widget(w), pluginEvent(nsnull)
645 : {
646 2 : }
647 :
648 0 : nsGUIEvent()
649 0 : : pluginEvent(nsnull)
650 : {
651 0 : }
652 :
653 : public:
654 0 : nsGUIEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
655 : : nsEvent(isTrusted, msg, NS_GUI_EVENT),
656 0 : widget(w), pluginEvent(nsnull)
657 : {
658 0 : }
659 :
660 : /// Originator of the event
661 : nsCOMPtr<nsIWidget> widget;
662 :
663 : /// Event for NPAPI plugin
664 : void* pluginEvent;
665 : };
666 :
667 : /**
668 : * Script error event
669 : */
670 :
671 : class nsScriptErrorEvent : public nsEvent
672 0 : {
673 : public:
674 0 : nsScriptErrorEvent(bool isTrusted, PRUint32 msg)
675 : : nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
676 0 : lineNr(0), errorMsg(nsnull), fileName(nsnull)
677 : {
678 0 : }
679 :
680 : PRInt32 lineNr;
681 : const PRUnichar* errorMsg;
682 : const PRUnichar* fileName;
683 : };
684 :
685 : /**
686 : * Window resize event
687 : */
688 :
689 : class nsSizeEvent : public nsGUIEvent
690 0 : {
691 : public:
692 0 : nsSizeEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
693 : : nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
694 0 : windowSize(nsnull), mWinWidth(0), mWinHeight(0)
695 : {
696 0 : }
697 :
698 : /// x,y width, height in pixels (client area)
699 : nsIntRect *windowSize;
700 : /// width of entire window (in pixels)
701 : PRInt32 mWinWidth;
702 : /// height of entire window (in pixels)
703 : PRInt32 mWinHeight;
704 : };
705 :
706 : /**
707 : * Window size mode event
708 : */
709 :
710 : class nsSizeModeEvent : public nsGUIEvent
711 0 : {
712 : public:
713 0 : nsSizeModeEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
714 : : nsGUIEvent(isTrusted, msg, w, NS_SIZEMODE_EVENT),
715 0 : mSizeMode(nsSizeMode_Normal)
716 : {
717 0 : }
718 :
719 : nsSizeMode mSizeMode;
720 : };
721 :
722 : /**
723 : * Window z-level event
724 : */
725 :
726 : class nsZLevelEvent : public nsGUIEvent
727 : {
728 : public:
729 0 : nsZLevelEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
730 : : nsGUIEvent(isTrusted, msg, w, NS_ZLEVEL_EVENT),
731 : mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull),
732 0 : mImmediate(false), mAdjusted(false)
733 : {
734 0 : }
735 :
736 : nsWindowZ mPlacement;
737 : nsIWidget *mReqBelow, // widget we request being below, if any
738 : *mActualBelow; // widget to be below, returned by handler
739 : bool mImmediate, // handler should make changes immediately
740 : mAdjusted; // handler changed placement
741 : };
742 :
743 : /**
744 : * Window repaint event
745 : */
746 :
747 : class nsPaintEvent : public nsGUIEvent
748 0 : {
749 : public:
750 0 : nsPaintEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
751 : : nsGUIEvent(isTrusted, msg, w, NS_PAINT_EVENT),
752 : willSendDidPaint(false),
753 0 : didSendWillPaint(false)
754 : {
755 0 : }
756 :
757 : // area that needs repainting
758 : nsIntRegion region;
759 : bool willSendDidPaint;
760 : bool didSendWillPaint;
761 : };
762 :
763 : /**
764 : * Scrollbar event
765 : */
766 :
767 : class nsScrollbarEvent : public nsGUIEvent
768 0 : {
769 : public:
770 0 : nsScrollbarEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
771 : : nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
772 0 : position(0)
773 : {
774 0 : }
775 :
776 : /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
777 : PRUint32 position;
778 : };
779 :
780 : class nsScrollPortEvent : public nsGUIEvent
781 0 : {
782 : public:
783 : enum orientType {
784 : vertical = 0,
785 : horizontal = 1,
786 : both = 2
787 : };
788 :
789 0 : nsScrollPortEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
790 : : nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
791 0 : orient(vertical)
792 : {
793 0 : }
794 :
795 : orientType orient;
796 : };
797 :
798 : class nsScrollAreaEvent : public nsGUIEvent
799 0 : {
800 : public:
801 0 : nsScrollAreaEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
802 0 : : nsGUIEvent(isTrusted, msg, w, NS_SCROLLAREA_EVENT)
803 : {
804 0 : }
805 :
806 : nsRect mArea;
807 : };
808 :
809 : class nsInputEvent : public nsGUIEvent
810 2 : {
811 : protected:
812 2 : nsInputEvent(bool isTrusted, PRUint32 msg, nsIWidget *w,
813 : PRUint8 structType)
814 : : nsGUIEvent(isTrusted, msg, w, structType),
815 2 : isShift(false), isControl(false), isAlt(false), isMeta(false)
816 : {
817 2 : }
818 :
819 0 : nsInputEvent()
820 0 : {
821 0 : }
822 :
823 : public:
824 0 : nsInputEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
825 : : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
826 0 : isShift(false), isControl(false), isAlt(false), isMeta(false)
827 : {
828 0 : }
829 :
830 : /// true indicates the shift key is down
831 : bool isShift;
832 : /// true indicates the control key is down
833 : bool isControl;
834 : /// true indicates the alt key is down
835 : bool isAlt;
836 : /// true indicates the meta key is down (or, on Mac, the Command key)
837 : bool isMeta;
838 : };
839 :
840 : /**
841 : * Mouse event
842 : */
843 :
844 : class nsMouseEvent_base : public nsInputEvent
845 2 : {
846 : private:
847 : friend class mozilla::dom::PBrowserParent;
848 : friend class mozilla::dom::PBrowserChild;
849 :
850 : public:
851 :
852 0 : nsMouseEvent_base()
853 0 : {
854 0 : }
855 :
856 2 : nsMouseEvent_base(bool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 type)
857 : : nsInputEvent(isTrusted, msg, w, type), button(0), pressure(0)
858 2 : , inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
859 :
860 : /// The possible related target
861 : nsCOMPtr<nsISupports> relatedTarget;
862 :
863 : PRInt16 button;
864 :
865 : // Finger or touch pressure of event
866 : // ranges between 0.0 and 1.0
867 : float pressure;
868 :
869 : // Possible values at nsIDOMMouseEvent
870 : PRUint16 inputSource;
871 : };
872 :
873 : class nsMouseEvent : public nsMouseEvent_base
874 0 : {
875 : private:
876 : friend class mozilla::dom::PBrowserParent;
877 : friend class mozilla::dom::PBrowserChild;
878 :
879 : public:
880 : enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
881 : enum reasonType { eReal, eSynthesized };
882 : enum contextType { eNormal, eContextMenuKey };
883 : enum exitType { eChild, eTopLevel };
884 :
885 0 : nsMouseEvent()
886 0 : {
887 0 : }
888 :
889 : protected:
890 0 : nsMouseEvent(bool isTrusted, PRUint32 msg, nsIWidget *w,
891 : PRUint8 structType, reasonType aReason)
892 : : nsMouseEvent_base(isTrusted, msg, w, structType),
893 : acceptActivation(false), ignoreRootScrollFrame(false),
894 0 : reason(aReason), context(eNormal), exit(eChild), clickCount(0)
895 : {
896 0 : switch (msg) {
897 : case NS_MOUSE_MOVE:
898 0 : flags |= NS_EVENT_FLAG_CANT_CANCEL;
899 0 : break;
900 : case NS_MOUSEENTER:
901 : case NS_MOUSELEAVE:
902 0 : flags |= (NS_EVENT_FLAG_CANT_CANCEL & NS_EVENT_FLAG_CANT_BUBBLE);
903 0 : break;
904 : default:
905 0 : break;
906 : }
907 0 : }
908 :
909 : public:
910 :
911 2 : nsMouseEvent(bool isTrusted, PRUint32 msg, nsIWidget *w,
912 : reasonType aReason, contextType aContext = eNormal)
913 : : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
914 : acceptActivation(false), ignoreRootScrollFrame(false),
915 2 : reason(aReason), context(aContext), exit(eChild), clickCount(0)
916 : {
917 2 : switch (msg) {
918 : case NS_MOUSE_MOVE:
919 0 : flags |= NS_EVENT_FLAG_CANT_CANCEL;
920 0 : break;
921 : case NS_MOUSEENTER:
922 : case NS_MOUSELEAVE:
923 0 : flags |= (NS_EVENT_FLAG_CANT_CANCEL | NS_EVENT_FLAG_CANT_BUBBLE);
924 0 : break;
925 : case NS_CONTEXTMENU:
926 0 : button = (context == eNormal) ? eRightButton : eLeftButton;
927 0 : break;
928 : default:
929 2 : break;
930 : }
931 2 : }
932 :
933 : #ifdef NS_DEBUG
934 4 : ~nsMouseEvent() {
935 2 : NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
936 : button ==
937 : ((context == eNormal) ? eRightButton : eLeftButton),
938 : "Wrong button set to NS_CONTEXTMENU event?");
939 2 : }
940 : #endif
941 :
942 : /// Special return code for MOUSE_ACTIVATE to signal
943 : /// if the target accepts activation (1), or denies it (0)
944 : bool acceptActivation;
945 : // Whether the event should ignore scroll frame bounds
946 : // during dispatch.
947 : bool ignoreRootScrollFrame;
948 :
949 : reasonType reason : 4;
950 : contextType context : 4;
951 : exitType exit;
952 :
953 : /// The number of mouse clicks
954 : PRUint32 clickCount;
955 : };
956 :
957 : /**
958 : * Drag event
959 : */
960 :
961 : class nsDragEvent : public nsMouseEvent
962 0 : {
963 : public:
964 0 : nsDragEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
965 : : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
966 0 : userCancelled(false)
967 : {
968 0 : if (msg == NS_DRAGDROP_EXIT_SYNTH ||
969 : msg == NS_DRAGDROP_LEAVE_SYNTH ||
970 : msg == NS_DRAGDROP_END) {
971 0 : flags |= NS_EVENT_FLAG_CANT_CANCEL;
972 : }
973 0 : }
974 :
975 : nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
976 : bool userCancelled;
977 : };
978 :
979 : #ifdef ACCESSIBILITY
980 : /**
981 : * Accessible event
982 : */
983 :
984 : class nsAccessibleEvent : public nsInputEvent
985 0 : {
986 : public:
987 0 : nsAccessibleEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
988 : : nsInputEvent(isTrusted, msg, w, NS_ACCESSIBLE_EVENT),
989 0 : mAccessible(nsnull)
990 : {
991 0 : }
992 :
993 : nsAccessible *mAccessible;
994 : };
995 : #endif
996 :
997 : /**
998 : * Keyboard event
999 : */
1000 :
1001 0 : struct nsAlternativeCharCode {
1002 0 : nsAlternativeCharCode(PRUint32 aUnshiftedCharCode,
1003 : PRUint32 aShiftedCharCode) :
1004 0 : mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
1005 : {
1006 0 : }
1007 : PRUint32 mUnshiftedCharCode;
1008 : PRUint32 mShiftedCharCode;
1009 : };
1010 :
1011 : class nsKeyEvent : public nsInputEvent
1012 0 : {
1013 : private:
1014 : friend class mozilla::dom::PBrowserParent;
1015 : friend class mozilla::dom::PBrowserChild;
1016 :
1017 : public:
1018 0 : nsKeyEvent()
1019 0 : {
1020 0 : }
1021 :
1022 0 : nsKeyEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
1023 : : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
1024 0 : keyCode(0), charCode(0), isChar(0)
1025 : {
1026 0 : }
1027 :
1028 : /// see NS_VK codes
1029 : PRUint32 keyCode;
1030 : /// OS translated Unicode char
1031 : PRUint32 charCode;
1032 : // OS translated Unicode chars which are used for accesskey and accelkey
1033 : // handling. The handlers will try from first character to last character.
1034 : nsTArray<nsAlternativeCharCode> alternativeCharCodes;
1035 : // indicates whether the event signifies a printable character
1036 : bool isChar;
1037 : };
1038 :
1039 : /**
1040 : * IME Related Events
1041 : */
1042 :
1043 : struct nsTextRangeStyle
1044 : {
1045 : enum {
1046 : LINESTYLE_NONE = NS_STYLE_TEXT_DECORATION_STYLE_NONE,
1047 : LINESTYLE_SOLID = NS_STYLE_TEXT_DECORATION_STYLE_SOLID,
1048 : LINESTYLE_DOTTED = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED,
1049 : LINESTYLE_DASHED = NS_STYLE_TEXT_DECORATION_STYLE_DASHED,
1050 : LINESTYLE_DOUBLE = NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE,
1051 : LINESTYLE_WAVY = NS_STYLE_TEXT_DECORATION_STYLE_WAVY
1052 : };
1053 :
1054 : enum {
1055 : DEFINED_NONE = 0x00,
1056 : DEFINED_LINESTYLE = 0x01,
1057 : DEFINED_FOREGROUND_COLOR = 0x02,
1058 : DEFINED_BACKGROUND_COLOR = 0x04,
1059 : DEFINED_UNDERLINE_COLOR = 0x08
1060 : };
1061 :
1062 : // Initialize all members, because nsTextRange instances may be compared by
1063 : // memcomp.
1064 1464 : nsTextRangeStyle()
1065 : {
1066 1464 : Clear();
1067 1464 : }
1068 :
1069 1464 : void Clear()
1070 : {
1071 1464 : mDefinedStyles = DEFINED_NONE;
1072 1464 : mLineStyle = LINESTYLE_NONE;
1073 1464 : mIsBoldLine = false;
1074 1464 : mForegroundColor = mBackgroundColor = mUnderlineColor = NS_RGBA(0, 0, 0, 0);
1075 1464 : }
1076 :
1077 0 : bool IsDefined() const { return mDefinedStyles != DEFINED_NONE; }
1078 :
1079 0 : bool IsLineStyleDefined() const
1080 : {
1081 0 : return (mDefinedStyles & DEFINED_LINESTYLE) != 0;
1082 : }
1083 :
1084 0 : bool IsForegroundColorDefined() const
1085 : {
1086 0 : return (mDefinedStyles & DEFINED_FOREGROUND_COLOR) != 0;
1087 : }
1088 :
1089 0 : bool IsBackgroundColorDefined() const
1090 : {
1091 0 : return (mDefinedStyles & DEFINED_BACKGROUND_COLOR) != 0;
1092 : }
1093 :
1094 0 : bool IsUnderlineColorDefined() const
1095 : {
1096 0 : return (mDefinedStyles & DEFINED_UNDERLINE_COLOR) != 0;
1097 : }
1098 :
1099 : bool IsNoChangeStyle() const
1100 : {
1101 : return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
1102 : IsLineStyleDefined() && mLineStyle == LINESTYLE_NONE;
1103 : }
1104 :
1105 : bool Equals(const nsTextRangeStyle& aOther)
1106 : {
1107 : if (mDefinedStyles != aOther.mDefinedStyles)
1108 : return false;
1109 : if (IsLineStyleDefined() && (mLineStyle != aOther.mLineStyle ||
1110 : !mIsBoldLine != !aOther.mIsBoldLine))
1111 : return false;
1112 : if (IsForegroundColorDefined() &&
1113 : (mForegroundColor != aOther.mForegroundColor))
1114 : return false;
1115 : if (IsBackgroundColorDefined() &&
1116 : (mBackgroundColor != aOther.mBackgroundColor))
1117 : return false;
1118 : if (IsUnderlineColorDefined() &&
1119 : (mUnderlineColor != aOther.mUnderlineColor))
1120 : return false;
1121 : return true;
1122 : }
1123 :
1124 : bool operator !=(const nsTextRangeStyle &aOther)
1125 : {
1126 : return !Equals(aOther);
1127 : }
1128 :
1129 : bool operator ==(const nsTextRangeStyle &aOther)
1130 : {
1131 : return Equals(aOther);
1132 : }
1133 :
1134 : PRUint8 mDefinedStyles;
1135 : PRUint8 mLineStyle; // DEFINED_LINESTYLE
1136 :
1137 : bool mIsBoldLine; // DEFINED_LINESTYLE
1138 :
1139 : nscolor mForegroundColor; // DEFINED_FOREGROUND_COLOR
1140 : nscolor mBackgroundColor; // DEFINED_BACKGROUND_COLOR
1141 : nscolor mUnderlineColor; // DEFINED_UNDERLINE_COLOR
1142 : };
1143 :
1144 : struct nsTextRange
1145 0 : {
1146 0 : nsTextRange()
1147 0 : : mStartOffset(0), mEndOffset(0), mRangeType(0)
1148 : {
1149 0 : }
1150 :
1151 : PRUint32 mStartOffset;
1152 : PRUint32 mEndOffset;
1153 : PRUint32 mRangeType;
1154 :
1155 : nsTextRangeStyle mRangeStyle;
1156 : };
1157 :
1158 : typedef nsTextRange* nsTextRangeArray;
1159 :
1160 : class nsTextEvent : public nsInputEvent
1161 0 : {
1162 : private:
1163 : friend class mozilla::dom::PBrowserParent;
1164 : friend class mozilla::dom::PBrowserChild;
1165 : friend class mozilla::plugins::PPluginInstanceChild;
1166 :
1167 0 : nsTextEvent()
1168 0 : {
1169 0 : }
1170 :
1171 : public:
1172 : PRUint32 seqno;
1173 :
1174 : public:
1175 0 : nsTextEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
1176 : : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
1177 0 : rangeCount(0), rangeArray(nsnull), isChar(false)
1178 : {
1179 0 : }
1180 :
1181 : nsString theText;
1182 : PRUint32 rangeCount;
1183 : // Note that the range array may not specify a caret position; in that
1184 : // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
1185 : // array.
1186 : nsTextRangeArray rangeArray;
1187 : bool isChar;
1188 : };
1189 :
1190 : class nsCompositionEvent : public nsGUIEvent
1191 0 : {
1192 : private:
1193 : friend class mozilla::dom::PBrowserParent;
1194 : friend class mozilla::dom::PBrowserChild;
1195 :
1196 0 : nsCompositionEvent()
1197 0 : {
1198 0 : }
1199 :
1200 : public:
1201 : PRUint32 seqno;
1202 :
1203 : public:
1204 0 : nsCompositionEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
1205 0 : : nsGUIEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
1206 : {
1207 : // XXX compositionstart is cancelable in draft of DOM3 Events.
1208 : // However, it doesn't make sense for us, we cannot cancel composition
1209 : // when we send compositionstart event.
1210 0 : flags |= NS_EVENT_FLAG_CANT_CANCEL;
1211 0 : }
1212 :
1213 : nsString data;
1214 : };
1215 :
1216 : /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
1217 : *
1218 : * There are two common event flows:
1219 : * (1) Normal line scrolling:
1220 : * 1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
1221 : * 2. A DOMMouseScroll event is sent into the DOM.
1222 : * 3. A MozMousePixelScroll event is sent into the DOM.
1223 : * 4. If neither event has been consumed, the default handling of the
1224 : * NS_MOUSE_SCROLL event is executed.
1225 : *
1226 : * (2) Pixel scrolling:
1227 : * 1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
1228 : * 2. A DOMMouseScroll event is sent into the DOM.
1229 : * 3. No scrolling takes place in the default handler.
1230 : * 4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
1231 : * 5. A MozMousePixelScroll event is sent into the DOM.
1232 : * 6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
1233 : * NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
1234 : * 7. Steps 4.-6. are repeated for every pixel scroll that belongs to
1235 : * the announced line scroll. Once enough pixels have been sent to
1236 : * complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
1237 : *
1238 : * If a DOMMouseScroll event has been preventDefaulted, the associated
1239 : * following MozMousePixelScroll events are still sent - they just don't result
1240 : * in any scrolling (their default handler isn't executed).
1241 : *
1242 : * How many pixel scrolls make up one line scroll is decided in the widget layer
1243 : * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
1244 : *
1245 : * This event flow model satisfies several requirements:
1246 : * - DOMMouseScroll handlers don't need to be aware of the existence of pixel
1247 : * scrolling.
1248 : * - preventDefault on a DOMMouseScroll event results in no scrolling.
1249 : * - DOMMouseScroll events aren't polluted with a kHasPixels flag.
1250 : * - You can make use of pixel scroll DOM events (MozMousePixelScroll).
1251 : */
1252 :
1253 : class nsMouseScrollEvent : public nsMouseEvent_base
1254 0 : {
1255 : private:
1256 : friend class mozilla::dom::PBrowserParent;
1257 : friend class mozilla::dom::PBrowserChild;
1258 :
1259 0 : nsMouseScrollEvent()
1260 0 : {
1261 0 : }
1262 :
1263 : public:
1264 : enum nsMouseScrollFlags {
1265 : kIsFullPage = 1 << 0,
1266 : kIsVertical = 1 << 1,
1267 : kIsHorizontal = 1 << 2,
1268 : kHasPixels = 1 << 3, // Marks line scroll events that are provided as
1269 : // a fallback for pixel scroll events.
1270 : // These scroll events are used by things that can't
1271 : // be scrolled pixel-wise, like trees. You should
1272 : // ignore them when processing pixel scroll events
1273 : // to avoid double-processing the same scroll gesture.
1274 : // When kHasPixels is set, the event is guaranteed to
1275 : // be followed up by an event that contains pixel
1276 : // scrolling information.
1277 : kNoLines = 1 << 4, // Marks pixel scroll events that will not be
1278 : // followed by a line scroll events. EventStateManager
1279 : // will compute the appropriate height/width based on
1280 : // view lineHeight and generate line scroll events
1281 : // as needed.
1282 : kNoDefer = 1 << 5, // For scrollable views, indicates scroll should not
1283 : // occur asynchronously.
1284 : kIsMomentum = 1 << 6, // Marks scroll events that aren't controlled by the
1285 : // user but fire automatically as the result of a
1286 : // "momentum" scroll.
1287 : kAllowSmoothScroll = 1 << 7, // Allow smooth scroll for the pixel scroll
1288 : // event.
1289 : kFromLines = 1 << 8 // For a pixels scroll event, indicates that it
1290 : // originated from a lines scroll event.
1291 : // (Only used on windows which generates "faked"
1292 : // pixel scroll events even for simple mouse wheel
1293 : // scroll)
1294 : };
1295 :
1296 0 : nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
1297 : : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
1298 0 : scrollFlags(0), delta(0), scrollOverflow(0)
1299 : {
1300 0 : }
1301 :
1302 : PRInt32 scrollFlags;
1303 : PRInt32 delta;
1304 : PRInt32 scrollOverflow;
1305 : };
1306 :
1307 : /*
1308 : * Gesture Notify Event:
1309 : *
1310 : * This event is the first event generated when the user touches
1311 : * the screen with a finger, and it's meant to decide what kind
1312 : * of action we'll use for that touch interaction.
1313 : *
1314 : * The event is dispatched to the layout and based on what is underneath
1315 : * the initial contact point it's then decided if we should pan
1316 : * (finger scrolling) or drag the target element.
1317 : */
1318 : class nsGestureNotifyEvent : public nsGUIEvent
1319 : {
1320 : public:
1321 : enum ePanDirection {
1322 : ePanNone,
1323 : ePanVertical,
1324 : ePanHorizontal,
1325 : ePanBoth
1326 : };
1327 :
1328 : ePanDirection panDirection;
1329 : bool displayPanFeedback;
1330 :
1331 : nsGestureNotifyEvent(bool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget):
1332 : nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_GESTURENOTIFY_EVENT),
1333 : panDirection(ePanNone),
1334 : displayPanFeedback(false)
1335 : {
1336 : }
1337 : };
1338 :
1339 : class nsQueryContentEvent : public nsGUIEvent
1340 0 : {
1341 : private:
1342 : friend class mozilla::dom::PBrowserParent;
1343 : friend class mozilla::dom::PBrowserChild;
1344 :
1345 : nsQueryContentEvent()
1346 : {
1347 : mReply.mContentsRoot = nsnull;
1348 : mReply.mFocusedWidget = nsnull;
1349 : }
1350 :
1351 : public:
1352 0 : nsQueryContentEvent(bool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
1353 : nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
1354 0 : mSucceeded(false), mWasAsync(false)
1355 : {
1356 0 : }
1357 :
1358 0 : void InitForQueryTextContent(PRUint32 aOffset, PRUint32 aLength)
1359 : {
1360 0 : NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
1361 : "wrong initializer is called");
1362 0 : mInput.mOffset = aOffset;
1363 0 : mInput.mLength = aLength;
1364 0 : }
1365 :
1366 0 : void InitForQueryCaretRect(PRUint32 aOffset)
1367 : {
1368 0 : NS_ASSERTION(message == NS_QUERY_CARET_RECT,
1369 : "wrong initializer is called");
1370 0 : mInput.mOffset = aOffset;
1371 0 : }
1372 :
1373 0 : void InitForQueryTextRect(PRUint32 aOffset, PRUint32 aLength)
1374 : {
1375 0 : NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
1376 : "wrong initializer is called");
1377 0 : mInput.mOffset = aOffset;
1378 0 : mInput.mLength = aLength;
1379 0 : }
1380 :
1381 : void InitForQueryDOMWidgetHittest(nsIntPoint& aPoint)
1382 : {
1383 : NS_ASSERTION(message == NS_QUERY_DOM_WIDGET_HITTEST,
1384 : "wrong initializer is called");
1385 : refPoint = aPoint;
1386 : }
1387 :
1388 : void InitForQueryScrollTargetInfo(nsMouseScrollEvent* aEvent)
1389 : {
1390 : NS_ASSERTION(message == NS_QUERY_SCROLL_TARGET_INFO,
1391 : "wrong initializer is called");
1392 : mInput.mMouseScrollEvent = aEvent;
1393 : }
1394 :
1395 0 : PRUint32 GetSelectionStart(void) const
1396 : {
1397 0 : NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1398 : "not querying selection");
1399 0 : return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
1400 : }
1401 :
1402 0 : PRUint32 GetSelectionEnd(void) const
1403 : {
1404 0 : NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1405 : "not querying selection");
1406 0 : return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
1407 : }
1408 :
1409 : bool mSucceeded;
1410 : bool mWasAsync;
1411 : struct {
1412 : PRUint32 mOffset;
1413 : PRUint32 mLength;
1414 : // used by NS_QUERY_SCROLL_TARGET_INFO
1415 : nsMouseScrollEvent* mMouseScrollEvent;
1416 : } mInput;
1417 0 : struct {
1418 : void* mContentsRoot;
1419 : PRUint32 mOffset;
1420 : nsString mString;
1421 : nsIntRect mRect; // Finally, the coordinates is system coordinates.
1422 : // The return widget has the caret. This is set at all query events.
1423 : nsIWidget* mFocusedWidget;
1424 : bool mReversed; // true if selection is reversed (end < start)
1425 : bool mHasSelection; // true if the selection exists
1426 : bool mWidgetIsHit; // true if DOM element under mouse belongs to widget
1427 : // used by NS_QUERY_SELECTION_AS_TRANSFERABLE
1428 : nsCOMPtr<nsITransferable> mTransferable;
1429 : // used by NS_QUERY_SCROLL_TARGET_INFO
1430 : PRInt32 mLineHeight;
1431 : PRInt32 mPageWidth;
1432 : PRInt32 mPageHeight;
1433 : // used by NS_QUERY_SCROLL_TARGET_INFO
1434 : // the mouse wheel scrolling amount may be overridden by prefs or
1435 : // overriding system scrolling speed mechanism.
1436 : // If mMouseScrollEvent is a line scroll event, the unit of this value is
1437 : // line. If mMouseScrollEvent is a page scroll event, the unit of this
1438 : // value is page.
1439 : PRInt32 mComputedScrollAmount;
1440 : PRInt32 mComputedScrollAction;
1441 : } mReply;
1442 :
1443 : enum {
1444 : NOT_FOUND = PR_UINT32_MAX
1445 : };
1446 :
1447 : // values of mComputedScrollAction
1448 : enum {
1449 : SCROLL_ACTION_NONE,
1450 : SCROLL_ACTION_LINE,
1451 : SCROLL_ACTION_PAGE
1452 : };
1453 : };
1454 :
1455 : class nsFocusEvent : public nsEvent
1456 0 : {
1457 : public:
1458 0 : nsFocusEvent(bool isTrusted, PRUint32 msg)
1459 : : nsEvent(isTrusted, msg, NS_FOCUS_EVENT),
1460 : fromRaise(false),
1461 0 : isRefocus(false)
1462 : {
1463 0 : }
1464 :
1465 : bool fromRaise;
1466 : bool isRefocus;
1467 : };
1468 :
1469 : class nsSelectionEvent : public nsGUIEvent
1470 0 : {
1471 : private:
1472 : friend class mozilla::dom::PBrowserParent;
1473 : friend class mozilla::dom::PBrowserChild;
1474 :
1475 0 : nsSelectionEvent()
1476 0 : {
1477 0 : }
1478 :
1479 : public:
1480 : PRUint32 seqno;
1481 :
1482 : public:
1483 0 : nsSelectionEvent(bool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
1484 : nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_SELECTION_EVENT),
1485 0 : mExpandToClusterBoundary(true), mSucceeded(false)
1486 : {
1487 0 : }
1488 :
1489 : PRUint32 mOffset; // start offset of selection
1490 : PRUint32 mLength; // length of selection
1491 : bool mReversed; // selection "anchor" should be in front
1492 : bool mExpandToClusterBoundary; // cluster-based or character-based
1493 : bool mSucceeded;
1494 : };
1495 :
1496 : class nsContentCommandEvent : public nsGUIEvent
1497 0 : {
1498 : public:
1499 0 : nsContentCommandEvent(bool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget,
1500 : bool aOnlyEnabledCheck = false) :
1501 : nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
1502 : mOnlyEnabledCheck(bool(aOnlyEnabledCheck)),
1503 0 : mSucceeded(false), mIsEnabled(false)
1504 : {
1505 0 : }
1506 :
1507 : // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
1508 : nsCOMPtr<nsITransferable> mTransferable; // [in]
1509 :
1510 : // NS_CONTENT_COMMAND_SCROLL
1511 : // for mScroll.mUnit
1512 : enum {
1513 : eCmdScrollUnit_Line,
1514 : eCmdScrollUnit_Page,
1515 : eCmdScrollUnit_Whole
1516 : };
1517 :
1518 : struct ScrollInfo {
1519 0 : ScrollInfo() :
1520 0 : mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
1521 : {
1522 0 : }
1523 :
1524 : PRInt32 mAmount; // [in]
1525 : PRUint8 mUnit; // [in]
1526 : bool mIsHorizontal; // [in]
1527 : } mScroll;
1528 :
1529 : bool mOnlyEnabledCheck; // [in]
1530 :
1531 : bool mSucceeded; // [out]
1532 : bool mIsEnabled; // [out]
1533 : };
1534 :
1535 : class nsMozTouchEvent : public nsMouseEvent_base
1536 0 : {
1537 : public:
1538 0 : nsMozTouchEvent(bool isTrusted, PRUint32 msg, nsIWidget* w,
1539 : PRUint32 streamIdArg)
1540 : : nsMouseEvent_base(isTrusted, msg, w, NS_MOZTOUCH_EVENT),
1541 0 : streamId(streamIdArg)
1542 : {
1543 0 : }
1544 :
1545 : PRUint32 streamId;
1546 : };
1547 :
1548 : class nsTouchEvent : public nsInputEvent
1549 : {
1550 : public:
1551 0 : nsTouchEvent(nsTouchEvent *aEvent)
1552 : :nsInputEvent(aEvent->flags & NS_EVENT_FLAG_TRUSTED ? true : false,
1553 : aEvent->message,
1554 : aEvent->widget,
1555 0 : NS_TOUCH_EVENT)
1556 : {
1557 0 : touches.AppendElements(aEvent->touches);
1558 0 : MOZ_COUNT_CTOR(nsTouchEvent);
1559 0 : }
1560 0 : nsTouchEvent(bool isTrusted, PRUint32 msg, nsIWidget* w)
1561 0 : : nsInputEvent(isTrusted, msg, w, NS_TOUCH_EVENT)
1562 : {
1563 0 : MOZ_COUNT_CTOR(nsTouchEvent);
1564 0 : }
1565 0 : ~nsTouchEvent()
1566 0 : {
1567 0 : MOZ_COUNT_DTOR(nsTouchEvent);
1568 0 : }
1569 :
1570 : nsTArray<nsCOMPtr<nsIDOMTouch> > touches;
1571 : };
1572 :
1573 : /**
1574 : * Form event
1575 : *
1576 : * We hold the originating form control for form submit and reset events.
1577 : * originator is a weak pointer (does not hold a strong reference).
1578 : */
1579 :
1580 : class nsFormEvent : public nsEvent
1581 0 : {
1582 : public:
1583 0 : nsFormEvent(bool isTrusted, PRUint32 msg)
1584 : : nsEvent(isTrusted, msg, NS_FORM_EVENT),
1585 0 : originator(nsnull)
1586 : {
1587 0 : }
1588 :
1589 : nsIContent *originator;
1590 : };
1591 :
1592 : /**
1593 : * Command event
1594 : *
1595 : * Custom commands for example from the operating system.
1596 : */
1597 :
1598 : class nsCommandEvent : public nsGUIEvent
1599 0 : {
1600 : public:
1601 0 : nsCommandEvent(bool isTrusted, nsIAtom* aEventType,
1602 : nsIAtom* aCommand, nsIWidget* w)
1603 0 : : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
1604 : {
1605 0 : userType = aEventType;
1606 0 : command = aCommand;
1607 0 : }
1608 :
1609 : nsCOMPtr<nsIAtom> command;
1610 : };
1611 :
1612 : /**
1613 : * DOM UIEvent
1614 : */
1615 : class nsUIEvent : public nsEvent
1616 0 : {
1617 : public:
1618 0 : nsUIEvent(bool isTrusted, PRUint32 msg, PRInt32 d)
1619 : : nsEvent(isTrusted, msg, NS_UI_EVENT),
1620 0 : detail(d)
1621 : {
1622 0 : }
1623 :
1624 : PRInt32 detail;
1625 : };
1626 :
1627 : /**
1628 : * Simple gesture event
1629 : */
1630 : class nsSimpleGestureEvent : public nsMouseEvent_base
1631 0 : {
1632 : public:
1633 0 : nsSimpleGestureEvent(bool isTrusted, PRUint32 msg, nsIWidget* w,
1634 : PRUint32 directionArg, PRFloat64 deltaArg)
1635 : : nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
1636 0 : direction(directionArg), delta(deltaArg)
1637 : {
1638 0 : }
1639 :
1640 : nsSimpleGestureEvent(const nsSimpleGestureEvent& other)
1641 : : nsMouseEvent_base((other.flags & NS_EVENT_FLAG_TRUSTED) != 0,
1642 : other.message, other.widget, NS_SIMPLE_GESTURE_EVENT),
1643 : direction(other.direction), delta(other.delta)
1644 : {
1645 : }
1646 :
1647 : PRUint32 direction; // See nsIDOMSimpleGestureEvent for values
1648 : PRFloat64 delta; // Delta for magnify and rotate events
1649 : };
1650 :
1651 : class nsTransitionEvent : public nsEvent
1652 0 : {
1653 : public:
1654 0 : nsTransitionEvent(bool isTrusted, PRUint32 msg,
1655 : const nsString &propertyNameArg, float elapsedTimeArg)
1656 : : nsEvent(isTrusted, msg, NS_TRANSITION_EVENT),
1657 0 : propertyName(propertyNameArg), elapsedTime(elapsedTimeArg)
1658 : {
1659 0 : }
1660 :
1661 : nsString propertyName;
1662 : float elapsedTime;
1663 : };
1664 :
1665 : class nsAnimationEvent : public nsEvent
1666 0 : {
1667 : public:
1668 0 : nsAnimationEvent(bool isTrusted, PRUint32 msg,
1669 : const nsString &animationNameArg, float elapsedTimeArg)
1670 : : nsEvent(isTrusted, msg, NS_ANIMATION_EVENT),
1671 0 : animationName(animationNameArg), elapsedTime(elapsedTimeArg)
1672 : {
1673 0 : }
1674 :
1675 : nsString animationName;
1676 : float elapsedTime;
1677 : };
1678 :
1679 : class nsUIStateChangeEvent : public nsGUIEvent
1680 : {
1681 : public:
1682 : nsUIStateChangeEvent(bool isTrusted, PRUint32 msg, nsIWidget* w)
1683 : : nsGUIEvent(isTrusted, msg, w, NS_UISTATECHANGE_EVENT),
1684 : showAccelerators(UIStateChangeType_NoChange),
1685 : showFocusRings(UIStateChangeType_NoChange)
1686 : {
1687 : }
1688 :
1689 : UIStateChangeType showAccelerators;
1690 : UIStateChangeType showFocusRings;
1691 : };
1692 :
1693 : /**
1694 : * Native event pluginEvent for plugins.
1695 : */
1696 :
1697 : class nsPluginEvent : public nsGUIEvent
1698 : {
1699 : public:
1700 : nsPluginEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
1701 : : nsGUIEvent(isTrusted, msg, w, NS_PLUGIN_EVENT),
1702 : retargetToFocusedDocument(false)
1703 : {
1704 : }
1705 :
1706 : // If TRUE, this event needs to be retargeted to focused document.
1707 : // Otherwise, never retargeted.
1708 : // Defaults to false.
1709 : bool retargetToFocusedDocument;
1710 : };
1711 :
1712 : /**
1713 : * Event status for D&D Event
1714 : */
1715 : enum nsDragDropEventStatus {
1716 : /// The event is a enter
1717 : nsDragDropEventStatus_eDragEntered,
1718 : /// The event is exit
1719 : nsDragDropEventStatus_eDragExited,
1720 : /// The event is drop
1721 : nsDragDropEventStatus_eDrop
1722 : };
1723 :
1724 :
1725 : #define NS_IS_MOUSE_EVENT(evnt) \
1726 : (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1727 : ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1728 : ((evnt)->message == NS_MOUSE_CLICK) || \
1729 : ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1730 : ((evnt)->message == NS_MOUSE_ENTER) || \
1731 : ((evnt)->message == NS_MOUSE_EXIT) || \
1732 : ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1733 : ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1734 : ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1735 : ((evnt)->message == NS_MOUSE_MOZHITTEST) || \
1736 : ((evnt)->message == NS_MOUSE_MOVE))
1737 :
1738 : #define NS_IS_MOUSE_EVENT_STRUCT(evnt) \
1739 : ((evnt)->eventStructType == NS_MOUSE_EVENT || \
1740 : (evnt)->eventStructType == NS_DRAG_EVENT)
1741 :
1742 : #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1743 : ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1744 : (evnt)->message == NS_MOUSE_CLICK && \
1745 : static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1746 :
1747 : #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1748 : ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1749 : (evnt)->message == NS_CONTEXTMENU && \
1750 : static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1751 :
1752 : #define NS_IS_DRAG_EVENT(evnt) \
1753 : (((evnt)->message == NS_DRAGDROP_ENTER) || \
1754 : ((evnt)->message == NS_DRAGDROP_OVER) || \
1755 : ((evnt)->message == NS_DRAGDROP_EXIT) || \
1756 : ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1757 : ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1758 : ((evnt)->message == NS_DRAGDROP_DRAG) || \
1759 : ((evnt)->message == NS_DRAGDROP_END) || \
1760 : ((evnt)->message == NS_DRAGDROP_START) || \
1761 : ((evnt)->message == NS_DRAGDROP_DROP) || \
1762 : ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1763 :
1764 : #define NS_IS_KEY_EVENT(evnt) \
1765 : (((evnt)->message == NS_KEY_DOWN) || \
1766 : ((evnt)->message == NS_KEY_PRESS) || \
1767 : ((evnt)->message == NS_KEY_UP))
1768 :
1769 : #define NS_IS_IME_EVENT(evnt) \
1770 : (((evnt)->message == NS_TEXT_TEXT) || \
1771 : ((evnt)->message == NS_COMPOSITION_START) || \
1772 : ((evnt)->message == NS_COMPOSITION_END) || \
1773 : ((evnt)->message == NS_COMPOSITION_UPDATE))
1774 :
1775 : #define NS_IS_ACTIVATION_EVENT(evnt) \
1776 : (((evnt)->message == NS_ACTIVATE) || \
1777 : ((evnt)->message == NS_DEACTIVATE) || \
1778 : ((evnt)->message == NS_PLUGIN_ACTIVATE) || \
1779 : ((evnt)->message == NS_PLUGIN_FOCUS))
1780 :
1781 : #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1782 : ((evnt)->eventStructType == NS_QUERY_CONTENT_EVENT)
1783 :
1784 : #define NS_IS_SELECTION_EVENT(evnt) \
1785 : (((evnt)->message == NS_SELECTION_SET))
1786 :
1787 : #define NS_IS_CONTENT_COMMAND_EVENT(evnt) \
1788 : ((evnt)->eventStructType == NS_CONTENT_COMMAND_EVENT)
1789 :
1790 : #define NS_IS_PLUGIN_EVENT(evnt) \
1791 : (((evnt)->message == NS_PLUGIN_INPUT_EVENT) || \
1792 : ((evnt)->message == NS_PLUGIN_FOCUS_EVENT))
1793 :
1794 : #define NS_IS_RETARGETED_PLUGIN_EVENT(evnt) \
1795 : (NS_IS_PLUGIN_EVENT(evnt) && \
1796 : (static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
1797 :
1798 : #define NS_IS_NON_RETARGETED_PLUGIN_EVENT(evnt) \
1799 : (NS_IS_PLUGIN_EVENT(evnt) && \
1800 : !(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
1801 :
1802 : #define NS_IS_TRUSTED_EVENT(event) \
1803 : (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1804 :
1805 : // Mark an event as being dispatching.
1806 : #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1807 : (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1808 :
1809 : #define NS_IS_EVENT_IN_DISPATCH(event) \
1810 : (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1811 :
1812 : // Mark an event as being done dispatching.
1813 : #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1814 : NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1815 : "Event never got marked for dispatch!"); \
1816 : (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1817 : (event)->flags |= NS_EVENT_DISPATCHED;
1818 :
1819 : // Be aware the query content events and the selection events are a part of IME
1820 : // processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
1821 : // cases, you should use NS_IS_IME_RELATED_EVENT instead.
1822 : #define NS_IS_IME_RELATED_EVENT(evnt) \
1823 : (NS_IS_IME_EVENT(evnt) || \
1824 : (NS_IS_QUERY_CONTENT_EVENT(evnt) && \
1825 : evnt->message != NS_QUERY_SCROLL_TARGET_INFO) || \
1826 : NS_IS_SELECTION_EVENT(evnt))
1827 :
1828 : /*
1829 : * Virtual key bindings for keyboard events.
1830 : * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1831 : * Really, it would be better if we phased out the NS_VK symbols altogether
1832 : * in favor of the DOM ones, but at least this way they'll be in sync.
1833 : */
1834 :
1835 : #define NS_VK_CANCEL nsIDOMKeyEvent::DOM_VK_CANCEL
1836 : #define NS_VK_HELP nsIDOMKeyEvent::DOM_VK_HELP
1837 : #define NS_VK_BACK nsIDOMKeyEvent::DOM_VK_BACK_SPACE
1838 : #define NS_VK_TAB nsIDOMKeyEvent::DOM_VK_TAB
1839 : #define NS_VK_CLEAR nsIDOMKeyEvent::DOM_VK_CLEAR
1840 : #define NS_VK_RETURN nsIDOMKeyEvent::DOM_VK_RETURN
1841 : #define NS_VK_ENTER nsIDOMKeyEvent::DOM_VK_ENTER
1842 : #define NS_VK_SHIFT nsIDOMKeyEvent::DOM_VK_SHIFT
1843 : #define NS_VK_CONTROL nsIDOMKeyEvent::DOM_VK_CONTROL
1844 : #define NS_VK_ALT nsIDOMKeyEvent::DOM_VK_ALT
1845 : #define NS_VK_PAUSE nsIDOMKeyEvent::DOM_VK_PAUSE
1846 : #define NS_VK_CAPS_LOCK nsIDOMKeyEvent::DOM_VK_CAPS_LOCK
1847 : #define NS_VK_KANA nsIDOMKeyEvent::DOM_VK_KANA
1848 : #define NS_VK_HANGUL nsIDOMKeyEvent::DOM_VK_HANGUL
1849 : #define NS_VK_JUNJA nsIDOMKeyEvent::DOM_VK_JUNJA
1850 : #define NS_VK_FINAL nsIDOMKeyEvent::DOM_VK_FINAL
1851 : #define NS_VK_HANJA nsIDOMKeyEvent::DOM_VK_HANJA
1852 : #define NS_VK_KANJI nsIDOMKeyEvent::DOM_VK_KANJI
1853 : #define NS_VK_ESCAPE nsIDOMKeyEvent::DOM_VK_ESCAPE
1854 : #define NS_VK_CONVERT nsIDOMKeyEvent::DOM_VK_CONVERT
1855 : #define NS_VK_NONCONVERT nsIDOMKeyEvent::DOM_VK_NONCONVERT
1856 : #define NS_VK_ACCEPT nsIDOMKeyEvent::DOM_VK_ACCEPT
1857 : #define NS_VK_MODECHANGE nsIDOMKeyEvent::DOM_VK_MODECHANGE
1858 : #define NS_VK_SPACE nsIDOMKeyEvent::DOM_VK_SPACE
1859 : #define NS_VK_PAGE_UP nsIDOMKeyEvent::DOM_VK_PAGE_UP
1860 : #define NS_VK_PAGE_DOWN nsIDOMKeyEvent::DOM_VK_PAGE_DOWN
1861 : #define NS_VK_END nsIDOMKeyEvent::DOM_VK_END
1862 : #define NS_VK_HOME nsIDOMKeyEvent::DOM_VK_HOME
1863 : #define NS_VK_LEFT nsIDOMKeyEvent::DOM_VK_LEFT
1864 : #define NS_VK_UP nsIDOMKeyEvent::DOM_VK_UP
1865 : #define NS_VK_RIGHT nsIDOMKeyEvent::DOM_VK_RIGHT
1866 : #define NS_VK_DOWN nsIDOMKeyEvent::DOM_VK_DOWN
1867 : #define NS_VK_SELECT nsIDOMKeyEvent::DOM_VK_SELECT
1868 : #define NS_VK_PRINT nsIDOMKeyEvent::DOM_VK_PRINT
1869 : #define NS_VK_EXECUTE nsIDOMKeyEvent::DOM_VK_EXECUTE
1870 : #define NS_VK_PRINTSCREEN nsIDOMKeyEvent::DOM_VK_PRINTSCREEN
1871 : #define NS_VK_INSERT nsIDOMKeyEvent::DOM_VK_INSERT
1872 : #define NS_VK_DELETE nsIDOMKeyEvent::DOM_VK_DELETE
1873 :
1874 : // NS_VK_0 - NS_VK_9 match their ascii values
1875 : #define NS_VK_0 nsIDOMKeyEvent::DOM_VK_0
1876 : #define NS_VK_1 nsIDOMKeyEvent::DOM_VK_1
1877 : #define NS_VK_2 nsIDOMKeyEvent::DOM_VK_2
1878 : #define NS_VK_3 nsIDOMKeyEvent::DOM_VK_3
1879 : #define NS_VK_4 nsIDOMKeyEvent::DOM_VK_4
1880 : #define NS_VK_5 nsIDOMKeyEvent::DOM_VK_5
1881 : #define NS_VK_6 nsIDOMKeyEvent::DOM_VK_6
1882 : #define NS_VK_7 nsIDOMKeyEvent::DOM_VK_7
1883 : #define NS_VK_8 nsIDOMKeyEvent::DOM_VK_8
1884 : #define NS_VK_9 nsIDOMKeyEvent::DOM_VK_9
1885 :
1886 : #define NS_VK_SEMICOLON nsIDOMKeyEvent::DOM_VK_SEMICOLON
1887 : #define NS_VK_EQUALS nsIDOMKeyEvent::DOM_VK_EQUALS
1888 :
1889 : // NS_VK_A - NS_VK_Z match their ascii values
1890 : #define NS_VK_A nsIDOMKeyEvent::DOM_VK_A
1891 : #define NS_VK_B nsIDOMKeyEvent::DOM_VK_B
1892 : #define NS_VK_C nsIDOMKeyEvent::DOM_VK_C
1893 : #define NS_VK_D nsIDOMKeyEvent::DOM_VK_D
1894 : #define NS_VK_E nsIDOMKeyEvent::DOM_VK_E
1895 : #define NS_VK_F nsIDOMKeyEvent::DOM_VK_F
1896 : #define NS_VK_G nsIDOMKeyEvent::DOM_VK_G
1897 : #define NS_VK_H nsIDOMKeyEvent::DOM_VK_H
1898 : #define NS_VK_I nsIDOMKeyEvent::DOM_VK_I
1899 : #define NS_VK_J nsIDOMKeyEvent::DOM_VK_J
1900 : #define NS_VK_K nsIDOMKeyEvent::DOM_VK_K
1901 : #define NS_VK_L nsIDOMKeyEvent::DOM_VK_L
1902 : #define NS_VK_M nsIDOMKeyEvent::DOM_VK_M
1903 : #define NS_VK_N nsIDOMKeyEvent::DOM_VK_N
1904 : #define NS_VK_O nsIDOMKeyEvent::DOM_VK_O
1905 : #define NS_VK_P nsIDOMKeyEvent::DOM_VK_P
1906 : #define NS_VK_Q nsIDOMKeyEvent::DOM_VK_Q
1907 : #define NS_VK_R nsIDOMKeyEvent::DOM_VK_R
1908 : #define NS_VK_S nsIDOMKeyEvent::DOM_VK_S
1909 : #define NS_VK_T nsIDOMKeyEvent::DOM_VK_T
1910 : #define NS_VK_U nsIDOMKeyEvent::DOM_VK_U
1911 : #define NS_VK_V nsIDOMKeyEvent::DOM_VK_V
1912 : #define NS_VK_W nsIDOMKeyEvent::DOM_VK_W
1913 : #define NS_VK_X nsIDOMKeyEvent::DOM_VK_X
1914 : #define NS_VK_Y nsIDOMKeyEvent::DOM_VK_Y
1915 : #define NS_VK_Z nsIDOMKeyEvent::DOM_VK_Z
1916 :
1917 : #define NS_VK_CONTEXT_MENU nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU
1918 : #define NS_VK_SLEEP nsIDOMKeyEvent::DOM_VK_SLEEP
1919 :
1920 : #define NS_VK_NUMPAD0 nsIDOMKeyEvent::DOM_VK_NUMPAD0
1921 : #define NS_VK_NUMPAD1 nsIDOMKeyEvent::DOM_VK_NUMPAD1
1922 : #define NS_VK_NUMPAD2 nsIDOMKeyEvent::DOM_VK_NUMPAD2
1923 : #define NS_VK_NUMPAD3 nsIDOMKeyEvent::DOM_VK_NUMPAD3
1924 : #define NS_VK_NUMPAD4 nsIDOMKeyEvent::DOM_VK_NUMPAD4
1925 : #define NS_VK_NUMPAD5 nsIDOMKeyEvent::DOM_VK_NUMPAD5
1926 : #define NS_VK_NUMPAD6 nsIDOMKeyEvent::DOM_VK_NUMPAD6
1927 : #define NS_VK_NUMPAD7 nsIDOMKeyEvent::DOM_VK_NUMPAD7
1928 : #define NS_VK_NUMPAD8 nsIDOMKeyEvent::DOM_VK_NUMPAD8
1929 : #define NS_VK_NUMPAD9 nsIDOMKeyEvent::DOM_VK_NUMPAD9
1930 : #define NS_VK_MULTIPLY nsIDOMKeyEvent::DOM_VK_MULTIPLY
1931 : #define NS_VK_ADD nsIDOMKeyEvent::DOM_VK_ADD
1932 : #define NS_VK_SEPARATOR nsIDOMKeyEvent::DOM_VK_SEPARATOR
1933 : #define NS_VK_SUBTRACT nsIDOMKeyEvent::DOM_VK_SUBTRACT
1934 : #define NS_VK_DECIMAL nsIDOMKeyEvent::DOM_VK_DECIMAL
1935 : #define NS_VK_DIVIDE nsIDOMKeyEvent::DOM_VK_DIVIDE
1936 : #define NS_VK_F1 nsIDOMKeyEvent::DOM_VK_F1
1937 : #define NS_VK_F2 nsIDOMKeyEvent::DOM_VK_F2
1938 : #define NS_VK_F3 nsIDOMKeyEvent::DOM_VK_F3
1939 : #define NS_VK_F4 nsIDOMKeyEvent::DOM_VK_F4
1940 : #define NS_VK_F5 nsIDOMKeyEvent::DOM_VK_F5
1941 : #define NS_VK_F6 nsIDOMKeyEvent::DOM_VK_F6
1942 : #define NS_VK_F7 nsIDOMKeyEvent::DOM_VK_F7
1943 : #define NS_VK_F8 nsIDOMKeyEvent::DOM_VK_F8
1944 : #define NS_VK_F9 nsIDOMKeyEvent::DOM_VK_F9
1945 : #define NS_VK_F10 nsIDOMKeyEvent::DOM_VK_F10
1946 : #define NS_VK_F11 nsIDOMKeyEvent::DOM_VK_F11
1947 : #define NS_VK_F12 nsIDOMKeyEvent::DOM_VK_F12
1948 : #define NS_VK_F13 nsIDOMKeyEvent::DOM_VK_F13
1949 : #define NS_VK_F14 nsIDOMKeyEvent::DOM_VK_F14
1950 : #define NS_VK_F15 nsIDOMKeyEvent::DOM_VK_F15
1951 : #define NS_VK_F16 nsIDOMKeyEvent::DOM_VK_F16
1952 : #define NS_VK_F17 nsIDOMKeyEvent::DOM_VK_F17
1953 : #define NS_VK_F18 nsIDOMKeyEvent::DOM_VK_F18
1954 : #define NS_VK_F19 nsIDOMKeyEvent::DOM_VK_F19
1955 : #define NS_VK_F20 nsIDOMKeyEvent::DOM_VK_F20
1956 : #define NS_VK_F21 nsIDOMKeyEvent::DOM_VK_F21
1957 : #define NS_VK_F22 nsIDOMKeyEvent::DOM_VK_F22
1958 : #define NS_VK_F23 nsIDOMKeyEvent::DOM_VK_F23
1959 : #define NS_VK_F24 nsIDOMKeyEvent::DOM_VK_F24
1960 :
1961 : #define NS_VK_NUM_LOCK nsIDOMKeyEvent::DOM_VK_NUM_LOCK
1962 : #define NS_VK_SCROLL_LOCK nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK
1963 :
1964 : #define NS_VK_COMMA nsIDOMKeyEvent::DOM_VK_COMMA
1965 : #define NS_VK_PERIOD nsIDOMKeyEvent::DOM_VK_PERIOD
1966 : #define NS_VK_SLASH nsIDOMKeyEvent::DOM_VK_SLASH
1967 : #define NS_VK_BACK_QUOTE nsIDOMKeyEvent::DOM_VK_BACK_QUOTE
1968 : #define NS_VK_OPEN_BRACKET nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET
1969 : #define NS_VK_BACK_SLASH nsIDOMKeyEvent::DOM_VK_BACK_SLASH
1970 : #define NS_VK_CLOSE_BRACKET nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET
1971 : #define NS_VK_QUOTE nsIDOMKeyEvent::DOM_VK_QUOTE
1972 :
1973 : #define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
1974 :
1975 : // IME Constants -- keep in synch with nsIPrivateTextRange.h
1976 : #define NS_TEXTRANGE_CARETPOSITION 0x01
1977 : #define NS_TEXTRANGE_RAWINPUT 0x02
1978 : #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1979 : #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1980 : #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1981 :
1982 : /**
1983 : * Whether the event should be handled by the frame of the mouse cursor
1984 : * position or not. When it should be handled there (e.g., the mouse events),
1985 : * this returns TRUE.
1986 : */
1987 0 : inline bool NS_IsEventUsingCoordinates(nsEvent* aEvent)
1988 : {
1989 0 : return !NS_IS_KEY_EVENT(aEvent) && !NS_IS_IME_RELATED_EVENT(aEvent) &&
1990 0 : !NS_IS_CONTEXT_MENU_KEY(aEvent) && !NS_IS_ACTIVATION_EVENT(aEvent) &&
1991 0 : !NS_IS_PLUGIN_EVENT(aEvent) &&
1992 0 : !NS_IS_CONTENT_COMMAND_EVENT(aEvent) &&
1993 0 : aEvent->eventStructType != NS_ACCESSIBLE_EVENT;
1994 : }
1995 :
1996 : /**
1997 : * Whether the event should be handled by the focused DOM window in the
1998 : * same top level window's or not. E.g., key events, IME related events
1999 : * (including the query content events, they are used in IME transaction)
2000 : * should be handled by the (last) focused window rather than the dispatched
2001 : * window.
2002 : *
2003 : * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
2004 : * application level active DOM window which is on another top level window.
2005 : * So, when the event is fired on a deactive window, the event is going to be
2006 : * handled by the last focused DOM window in the last focused window.
2007 : */
2008 0 : inline bool NS_IsEventTargetedAtFocusedWindow(nsEvent* aEvent)
2009 : {
2010 : return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
2011 : NS_IS_CONTEXT_MENU_KEY(aEvent) ||
2012 : NS_IS_CONTENT_COMMAND_EVENT(aEvent) ||
2013 0 : NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
2014 : }
2015 :
2016 : /**
2017 : * Whether the event should be handled by the focused content or not. E.g.,
2018 : * key events, IME related events and other input events which are not handled
2019 : * by the frame of the mouse cursor position.
2020 : *
2021 : * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
2022 : * application level active DOM window which is on another top level window.
2023 : * So, when the event is fired on a deactive window, the event is going to be
2024 : * handled by the last focused DOM element of the last focused DOM window in
2025 : * the last focused window.
2026 : */
2027 0 : inline bool NS_IsEventTargetedAtFocusedContent(nsEvent* aEvent)
2028 : {
2029 : return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
2030 : NS_IS_CONTEXT_MENU_KEY(aEvent) ||
2031 0 : NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
2032 : }
2033 :
2034 : #endif // nsGUIEvent_h__
|