Bug 461680 - Improve video control fade in/out animation. r=enn
[wine-gecko.git] / widget / public / nsGUIEvent.h
blob2896e497a4dd75ab41606a04c2bf4a89fcbfb847
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
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/
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.
15 * The Original Code is mozilla.org code.
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.
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)
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef nsGUIEvent_h__
42 #define nsGUIEvent_h__
44 #include "nsPoint.h"
45 #include "nsRect.h"
46 #include "nsRegion.h"
47 #include "nsEvent.h"
48 #include "nsStringGlue.h"
49 #include "nsCOMPtr.h"
50 #include "nsIAtom.h"
51 #include "nsIDOMKeyEvent.h"
52 #include "nsIDOMDataTransfer.h"
53 #include "nsWeakPtr.h"
54 #include "nsIWidget.h"
55 #include "nsTArray.h"
56 #include "nsTraceRefcnt.h"
58 class nsIRenderingContext;
59 class nsIRegion;
60 class nsIMenuItem;
61 class nsIAccessible;
62 class nsIContent;
63 class nsIURI;
64 class nsIDOMEvent;
65 class nsHashKey;
67 /**
68 * Event Struct Types
70 #define NS_EVENT 1
71 #define NS_GUI_EVENT 2
72 #define NS_SIZE_EVENT 3
73 #define NS_SIZEMODE_EVENT 4
74 #define NS_ZLEVEL_EVENT 5
75 #define NS_PAINT_EVENT 6
76 #define NS_SCROLLBAR_EVENT 7
77 #define NS_INPUT_EVENT 8
78 #define NS_KEY_EVENT 9
79 #define NS_MOUSE_EVENT 10
80 #define NS_MENU_EVENT 11
81 #define NS_SCRIPT_ERROR_EVENT 12
82 #define NS_TEXT_EVENT 13
83 #define NS_COMPOSITION_EVENT 14
84 #define NS_MOUSE_SCROLL_EVENT 16
85 #define NS_SCROLLPORT_EVENT 18
86 #define NS_MUTATION_EVENT 19 // |nsMutationEvent| in content
87 #define NS_ACCESSIBLE_EVENT 20
88 #define NS_FORM_EVENT 21
89 #define NS_FOCUS_EVENT 22
90 #define NS_POPUP_EVENT 23
91 #define NS_COMMAND_EVENT 24
92 #define NS_POPUPBLOCKED_EVENT 25
93 #define NS_BEFORE_PAGE_UNLOAD_EVENT 26
94 #define NS_UI_EVENT 27
95 #define NS_PAGETRANSITION_EVENT 29
96 #ifdef MOZ_SVG
97 #define NS_SVG_EVENT 30
98 #define NS_SVGZOOM_EVENT 31
99 #endif // MOZ_SVG
100 #define NS_XUL_COMMAND_EVENT 32
101 #define NS_QUERY_CONTENT_EVENT 33
102 #ifdef MOZ_MEDIA
103 #define NS_MEDIA_EVENT 34
104 #endif // MOZ_MEDIA
105 #define NS_DRAG_EVENT 35
106 #define NS_NOTIFYPAINT_EVENT 36
107 #define NS_SIMPLE_GESTURE_EVENT 37
109 // These flags are sort of a mess. They're sort of shared between event
110 // listener flags and event flags, but only some of them. You've been
111 // warned!
112 #define NS_EVENT_FLAG_NONE 0x0000
113 #define NS_EVENT_FLAG_TRUSTED 0x0001
114 #define NS_EVENT_FLAG_BUBBLE 0x0002
115 #define NS_EVENT_FLAG_CAPTURE 0x0004
116 #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
117 #define NS_EVENT_FLAG_NO_DEFAULT 0x0010
118 #define NS_EVENT_FLAG_CANT_CANCEL 0x0020
119 #define NS_EVENT_FLAG_CANT_BUBBLE 0x0040
120 #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
121 #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
122 #define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
123 // Event has been dispatched at least once
124 #define NS_EVENT_DISPATCHED 0x0400
125 #define NS_EVENT_FLAG_DISPATCHING 0x0800
127 #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
129 #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
130 #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
132 #define NS_EVENT_TYPE_NULL 0
135 * GUI MESSAGES
137 //@{
138 #define NS_EVENT_NULL 0
141 #define NS_WINDOW_START 100
143 // Widget is being created
144 #define NS_CREATE (NS_WINDOW_START)
145 // Widget may be destroyed
146 #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
147 // Widget is being destroyed
148 #define NS_DESTROY (NS_WINDOW_START + 2)
149 // Widget was resized
150 #define NS_SIZE (NS_WINDOW_START + 3)
151 // Widget size mode was changed
152 #define NS_SIZEMODE (NS_WINDOW_START + 4)
153 // Widget gained focus
154 #define NS_GOTFOCUS (NS_WINDOW_START + 5)
155 // Widget lost focus
156 #define NS_LOSTFOCUS (NS_WINDOW_START + 6)
157 // Widget got activated
158 #define NS_ACTIVATE (NS_WINDOW_START + 7)
159 // Widget got deactivated
160 #define NS_DEACTIVATE (NS_WINDOW_START + 8)
161 // top-level window z-level change request
162 #define NS_SETZLEVEL (NS_WINDOW_START + 9)
163 // Widget needs to be repainted
164 #define NS_PAINT (NS_WINDOW_START + 30)
165 // Key is pressed within a window
166 #define NS_KEY_PRESS (NS_WINDOW_START + 31)
167 // Key is released within a window
168 #define NS_KEY_UP (NS_WINDOW_START + 32)
169 // Key is pressed within a window
170 #define NS_KEY_DOWN (NS_WINDOW_START + 33)
171 // Window has been moved to a new location.
172 // The events point contains the x, y location in screen coordinates
173 #define NS_MOVE (NS_WINDOW_START + 34)
175 // Tab control's selected tab has changed
176 #define NS_TABCHANGE (NS_WINDOW_START + 35)
178 #define NS_OS_TOOLBAR (NS_WINDOW_START + 36)
180 // Menu item selected
181 #define NS_MENU_SELECTED (NS_WINDOW_START + 38)
183 // Form control changed: currently == combo box selection changed
184 // but could be expanded to mean textbox, checkbox changed, etc.
185 // This is a GUI specific event that does not necessarily correspond
186 // directly to a mouse click or a key press.
187 #define NS_CONTROL_CHANGE (NS_WINDOW_START + 39)
189 // Indicates the display has changed depth
190 #define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
192 // Indicates a theme change has occurred
193 #define NS_THEMECHANGED (NS_WINDOW_START + 41)
195 // Indicates a System color has changed. It is the platform
196 // toolkits responsibility to invalidate the window to
197 // ensure that it is drawn using the current system colors.
198 #define NS_SYSCOLORCHANGED (NS_WINDOW_START + 42)
200 #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
201 #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
203 #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
205 #define NS_OFFLINE (NS_WINDOW_START + 63)
206 #define NS_ONLINE (NS_WINDOW_START + 64)
208 #define NS_MOUSE_MESSAGE_START 300
209 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
210 #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
211 #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
212 #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
213 #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
214 #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
215 #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
216 #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
217 #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
218 #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
220 #define NS_CONTEXTMENU_MESSAGE_START 500
221 #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
223 #define NS_SCROLLBAR_MESSAGE_START 1000
224 #define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
225 #define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
226 #define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
227 #define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
228 #define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
230 #define NS_STREAM_EVENT_START 1100
231 #define NS_LOAD (NS_STREAM_EVENT_START)
232 #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
233 #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
234 #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
235 #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
236 #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
238 #define NS_FORM_EVENT_START 1200
239 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
240 #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
241 #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
242 #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
243 #define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
245 //Need separate focus/blur notifications for non-native widgets
246 #define NS_FOCUS_EVENT_START 1300
247 #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
248 #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
250 #define NS_DRAGDROP_EVENT_START 1400
251 #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
252 #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
253 #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
254 #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
255 #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
256 #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
257 #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
258 #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
259 #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
260 #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
261 #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
262 #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
264 // Events for popups
265 #define NS_XUL_EVENT_START 1500
266 #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
267 #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
268 #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
269 #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
270 // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
271 #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
272 #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
273 //@}
275 // Scroll events
276 #define NS_MOUSE_SCROLL_START 1600
277 #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
278 #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
280 #define NS_SCROLLPORT_START 1700
281 #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
282 #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
283 #define NS_SCROLLPORT_OVERFLOWCHANGED (NS_SCROLLPORT_START+2)
285 // Mutation events defined elsewhere starting at 1800
287 // accessible events
288 #define NS_ACCESSIBLE_START 1900
289 #define NS_GETACCESSIBLE (NS_ACCESSIBLE_START)
291 #define NS_USER_DEFINED_EVENT 2000
293 // composition events
294 #define NS_COMPOSITION_EVENT_START 2200
295 #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
296 #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
297 #define NS_COMPOSITION_QUERY (NS_COMPOSITION_EVENT_START + 2)
299 // text events
300 #define NS_TEXT_START 2400
301 #define NS_TEXT_TEXT (NS_TEXT_START)
303 // UI events
304 #define NS_UI_EVENT_START 2500
305 // this is not to be confused with NS_ACTIVATE!
306 #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
307 #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
308 #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
310 // pagetransition events
311 #define NS_PAGETRANSITION_START 2700
312 #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
313 #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
315 #ifdef MOZ_SVG
316 // SVG events
317 #define NS_SVG_EVENT_START 2800
318 #define NS_SVG_LOAD (NS_SVG_EVENT_START)
319 #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
320 #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
321 #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
322 #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
323 #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
325 // SVG Zoom events
326 #define NS_SVGZOOM_EVENT_START 2900
327 #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
328 #endif // MOZ_SVG
330 // XUL command events
331 #define NS_XULCOMMAND_EVENT_START 3000
332 #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
334 // Cut, copy, paste events
335 #define NS_CUTCOPYPASTE_EVENT_START 3100
336 #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
337 #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
338 #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
340 // Query the content information
341 #define NS_QUERY_CONTENT_EVENT_START 3200
342 // Query for the selected text information, it return the selection offset,
343 // selection length and selected text.
344 #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
345 // Query for the text content of specified range, it returns actual lengh (if
346 // the specified range is too long) and the text of the specified range.
347 #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
348 // Query for the character rect of nth character. If there is no character at
349 // the offset, the query will be failed. The offset of the result is relative
350 // position from the top level widget.
351 #define NS_QUERY_CHARACTER_RECT (NS_QUERY_CONTENT_EVENT_START + 2)
352 // Query for the caret rect of nth insertion point. The offset of the result is
353 // relative position from the top level widget.
354 #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
356 // Video events
357 #ifdef MOZ_MEDIA
358 #define NS_MEDIA_EVENT_START 3300
359 #define NS_LOADSTART (NS_MEDIA_EVENT_START)
360 #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
361 #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+2)
362 #define NS_LOADEDFIRSTFRAME (NS_MEDIA_EVENT_START+3)
363 #define NS_EMPTIED (NS_MEDIA_EVENT_START+4)
364 #define NS_STALLED (NS_MEDIA_EVENT_START+5)
365 #define NS_PLAY (NS_MEDIA_EVENT_START+6)
366 #define NS_PAUSE (NS_MEDIA_EVENT_START+7)
367 #define NS_WAITING (NS_MEDIA_EVENT_START+8)
368 #define NS_SEEKING (NS_MEDIA_EVENT_START+9)
369 #define NS_SEEKED (NS_MEDIA_EVENT_START+10)
370 #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+11)
371 #define NS_ENDED (NS_MEDIA_EVENT_START+12)
372 #define NS_DATAUNAVAILABLE (NS_MEDIA_EVENT_START+13)
373 #define NS_CANSHOWCURRENTFRAME (NS_MEDIA_EVENT_START+14)
374 #define NS_CANPLAY (NS_MEDIA_EVENT_START+15)
375 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+16)
376 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
377 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
378 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
379 #define NS_MEDIA_ABORT (NS_MEDIA_EVENT_START+20)
380 #define NS_MEDIA_ERROR (NS_MEDIA_EVENT_START+21)
381 #endif // MOZ_MEDIA
383 // paint notification events
384 #define NS_NOTIFYPAINT_START 3400
385 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
387 // Simple gesture events
388 #define NS_SIMPLE_GESTURE_EVENT_START 3500
389 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
390 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
391 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
392 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
393 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
394 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
395 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
398 * Return status for event processors, nsEventStatus, is defined in
399 * nsEvent.h.
403 * sizemode is an adjunct to widget size
405 enum nsSizeMode {
406 nsSizeMode_Normal = 0,
407 nsSizeMode_Minimized,
408 nsSizeMode_Maximized
412 * different types of (top-level) window z-level positioning
414 enum nsWindowZ {
415 nsWindowZTop = 0, // on top
416 nsWindowZBottom, // on bottom
417 nsWindowZRelative // just below some specified widget
421 * General event
424 class nsEvent
426 protected:
427 nsEvent(PRBool isTrusted, PRUint32 msg, PRUint8 structType)
428 : eventStructType(structType),
429 message(msg),
430 refPoint(0, 0),
431 time(0),
432 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
433 userType(0)
435 MOZ_COUNT_CTOR(nsEvent);
438 public:
439 nsEvent(PRBool isTrusted, PRUint32 msg)
440 : eventStructType(NS_EVENT),
441 message(msg),
442 refPoint(0, 0),
443 time(0),
444 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
445 userType(0)
447 MOZ_COUNT_CTOR(nsEvent);
450 ~nsEvent()
452 MOZ_COUNT_DTOR(nsEvent);
455 // See event struct types
456 PRUint8 eventStructType;
457 // See GUI MESSAGES,
458 PRUint32 message;
459 // In widget relative coordinates, not modified by layout code.
460 nsPoint refPoint;
461 // Elapsed time, in milliseconds, from a platform-specific zero time
462 // to the time the message was created
463 PRUint32 time;
464 // Flags to hold event flow stage and capture/bubble cancellation
465 // status. This is used also to indicate whether the event is trusted.
466 PRUint32 flags;
467 // Additional type info for user defined events
468 nsCOMPtr<nsIAtom> userType;
469 // Event targets, needed by DOM Events
470 // Using nsISupports, not nsIDOMEventTarget because in some cases
471 // nsIDOMEventTarget is implemented as a tearoff.
472 nsCOMPtr<nsISupports> target;
473 nsCOMPtr<nsISupports> currentTarget;
474 nsCOMPtr<nsISupports> originalTarget;
478 * General graphic user interface event
481 class nsGUIEvent : public nsEvent
483 protected:
484 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
485 : nsEvent(isTrusted, msg, structType),
486 widget(w), nativeMsg(nsnull)
490 public:
491 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
492 : nsEvent(isTrusted, msg, NS_GUI_EVENT),
493 widget(w), nativeMsg(nsnull)
497 /// Originator of the event
498 nsCOMPtr<nsIWidget> widget;
500 /// Internal platform specific message.
501 void* nativeMsg;
505 * Script error event
508 class nsScriptErrorEvent : public nsEvent
510 public:
511 nsScriptErrorEvent(PRBool isTrusted, PRUint32 msg)
512 : nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
513 lineNr(0), errorMsg(nsnull), fileName(nsnull)
517 PRInt32 lineNr;
518 const PRUnichar* errorMsg;
519 const PRUnichar* fileName;
522 class nsBeforePageUnloadEvent : public nsEvent
524 public:
525 nsBeforePageUnloadEvent(PRBool isTrusted, PRUint32 msg)
526 : nsEvent(isTrusted, msg, NS_BEFORE_PAGE_UNLOAD_EVENT)
530 nsString text;
534 * Window resize event
537 class nsSizeEvent : public nsGUIEvent
539 public:
540 nsSizeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
541 : nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
542 windowSize(nsnull), mWinWidth(0), mWinHeight(0)
546 /// x,y width, height in pixels (client area)
547 nsRect *windowSize;
548 /// width of entire window (in pixels)
549 PRInt32 mWinWidth;
550 /// height of entire window (in pixels)
551 PRInt32 mWinHeight;
555 * Window size mode event
558 class nsSizeModeEvent : public nsGUIEvent
560 public:
561 nsSizeModeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
562 : nsGUIEvent(isTrusted, msg, w, NS_SIZEMODE_EVENT),
563 mSizeMode(nsSizeMode_Normal)
567 nsSizeMode mSizeMode;
571 * Window z-level event
574 class nsZLevelEvent : public nsGUIEvent
576 public:
577 nsZLevelEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
578 : nsGUIEvent(isTrusted, msg, w, NS_ZLEVEL_EVENT),
579 mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull),
580 mImmediate(PR_FALSE), mAdjusted(PR_FALSE)
584 nsWindowZ mPlacement;
585 nsIWidget *mReqBelow, // widget we request being below, if any
586 *mActualBelow; // widget to be below, returned by handler
587 PRBool mImmediate, // handler should make changes immediately
588 mAdjusted; // handler changed placement
592 * Window repaint event
595 class nsPaintEvent : public nsGUIEvent
597 public:
598 nsPaintEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
599 : nsGUIEvent(isTrusted, msg, w, NS_PAINT_EVENT),
600 renderingContext(nsnull), region(nsnull), rect(nsnull)
604 /// Context to paint in.
605 nsIRenderingContext *renderingContext;
606 /// area to paint (should be used instead of rect)
607 nsIRegion *region;
608 /// x,y, width, height in pixels of area to paint
609 nsRect *rect;
613 * Scrollbar event
616 class nsScrollbarEvent : public nsGUIEvent
618 public:
619 nsScrollbarEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
620 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
621 position(0)
625 /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
626 PRUint32 position;
629 class nsScrollPortEvent : public nsGUIEvent
631 public:
632 enum orientType {
633 vertical = 0,
634 horizontal = 1,
635 both = 2
638 nsScrollPortEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
639 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
640 orient(vertical)
644 orientType orient;
647 class nsInputEvent : public nsGUIEvent
649 protected:
650 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
651 PRUint8 structType)
652 : nsGUIEvent(isTrusted, msg, w, structType),
653 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
657 public:
658 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
659 : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
660 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
664 /// PR_TRUE indicates the shift key is down
665 PRBool isShift;
666 /// PR_TRUE indicates the control key is down
667 PRBool isControl;
668 /// PR_TRUE indicates the alt key is down
669 PRBool isAlt;
670 /// PR_TRUE indicates the meta key is down (or, on Mac, the Command key)
671 PRBool isMeta;
675 * Mouse event
678 class nsMouseEvent_base : public nsInputEvent
680 public:
681 nsMouseEvent_base(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 type)
682 : nsInputEvent(isTrusted, msg, w, type), button(0) {}
684 /// The possible related target
685 nsCOMPtr<nsISupports> relatedTarget;
687 PRInt16 button;
690 class nsMouseEvent : public nsMouseEvent_base
692 public:
693 enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
694 enum reasonType { eReal, eSynthesized };
695 enum contextType { eNormal, eContextMenuKey };
696 enum exitType { eChild, eTopLevel };
698 protected:
699 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
700 PRUint8 structType, reasonType aReason)
701 : nsMouseEvent_base(isTrusted, msg, w, structType),
702 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
703 reason(aReason), context(eNormal), exit(eChild), clickCount(0)
705 if (msg == NS_MOUSE_MOVE) {
706 flags |= NS_EVENT_FLAG_CANT_CANCEL;
710 public:
712 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
713 reasonType aReason, contextType aContext = eNormal)
714 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
715 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
716 reason(aReason), context(aContext), exit(eChild), clickCount(0)
718 if (msg == NS_MOUSE_MOVE) {
719 flags |= NS_EVENT_FLAG_CANT_CANCEL;
720 } else if (msg == NS_CONTEXTMENU) {
721 button = (context == eNormal) ? eRightButton : eLeftButton;
724 #ifdef NS_DEBUG
725 ~nsMouseEvent() {
726 NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
727 button ==
728 ((context == eNormal) ? eRightButton : eLeftButton),
729 "Wrong button set to NS_CONTEXTMENU event?");
731 #endif
733 /// Special return code for MOUSE_ACTIVATE to signal
734 /// if the target accepts activation (1), or denies it (0)
735 PRPackedBool acceptActivation;
736 // Whether the event should ignore scroll frame bounds
737 // during dispatch.
738 PRPackedBool ignoreRootScrollFrame;
740 reasonType reason : 4;
741 contextType context : 4;
742 exitType exit;
744 /// The number of mouse clicks
745 PRUint32 clickCount;
749 * Drag event
752 class nsDragEvent : public nsMouseEvent
754 public:
755 nsDragEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
756 : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal)
758 if (msg == NS_DRAGDROP_EXIT_SYNTH ||
759 msg == NS_DRAGDROP_LEAVE_SYNTH ||
760 msg == NS_DRAGDROP_END) {
761 flags |= NS_EVENT_FLAG_CANT_CANCEL;
765 nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
769 * Accessible event
772 class nsAccessibleEvent : public nsInputEvent
774 public:
775 nsAccessibleEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
776 : nsInputEvent(isTrusted, msg, w, NS_ACCESSIBLE_EVENT),
777 accessible(nsnull)
781 nsIAccessible* accessible;
785 * Keyboard event
788 struct nsAlternativeCharCode {
789 nsAlternativeCharCode(PRUint32 aUnshiftedCharCode,
790 PRUint32 aShiftedCharCode) :
791 mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
794 PRUint32 mUnshiftedCharCode;
795 PRUint32 mShiftedCharCode;
798 class nsKeyEvent : public nsInputEvent
800 public:
801 nsKeyEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
802 : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
803 keyCode(0), charCode(0), isChar(0)
807 /// see NS_VK codes
808 PRUint32 keyCode;
809 /// OS translated Unicode char
810 PRUint32 charCode;
811 // OS translated Unicode chars which are used for accesskey and accelkey
812 // handling. The handlers will try from first character to last character.
813 nsTArray<nsAlternativeCharCode> alternativeCharCodes;
814 // indicates whether the event signifies a printable character
815 PRBool isChar;
819 * IME Related Events
821 struct nsTextRange
823 nsTextRange()
824 : mStartOffset(0), mEndOffset(0), mRangeType(0)
828 PRUint32 mStartOffset;
829 PRUint32 mEndOffset;
830 PRUint32 mRangeType;
833 typedef nsTextRange* nsTextRangeArray;
835 struct nsTextEventReply
837 nsTextEventReply()
838 : mCursorIsCollapsed(PR_FALSE), mReferenceWidget(nsnull)
842 nsRect mCursorPosition;
843 PRBool mCursorIsCollapsed;
844 nsIWidget* mReferenceWidget;
847 typedef struct nsTextEventReply nsTextEventReply;
849 class nsTextEvent : public nsInputEvent
851 public:
852 nsTextEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
853 : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
854 theText(nsnull), rangeCount(0), rangeArray(nsnull), isChar(PR_FALSE)
858 const PRUnichar* theText;
859 nsTextEventReply theReply;
860 PRUint32 rangeCount;
861 nsTextRangeArray rangeArray;
862 PRBool isChar;
865 class nsCompositionEvent : public nsInputEvent
867 public:
868 nsCompositionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
869 : nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
873 nsTextEventReply theReply;
876 /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
878 * There are two common event flows:
879 * (1) Normal line scrolling:
880 * 1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
881 * 2. A DOMMouseScroll event is sent into the DOM.
882 * 3. A MozMousePixelScroll event is sent into the DOM.
883 * 4. If neither event has been consumed, the default handling of the
884 * NS_MOUSE_SCROLL event is executed.
886 * (2) Pixel scrolling:
887 * 1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
888 * 2. A DOMMouseScroll event is sent into the DOM.
889 * 3. No scrolling takes place in the default handler.
890 * 4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
891 * 5. A MozMousePixelScroll event is sent into the DOM.
892 * 6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
893 * NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
894 * 7. Steps 4.-6. are repeated for every pixel scroll that belongs to
895 * the announced line scroll. Once enough pixels have been sent to
896 * complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
898 * If a DOMMouseScroll event has been preventDefaulted, the associated
899 * following MozMousePixelScroll events are still sent - they just don't result
900 * in any scrolling (their default handler isn't executed).
902 * How many pixel scrolls make up one line scroll is decided in the widget layer
903 * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
905 * This event flow model satisfies several requirements:
906 * - DOMMouseScroll handlers don't need to be aware of the existence of pixel
907 * scrolling.
908 * - preventDefault on a DOMMouseScroll event results in no scrolling.
909 * - DOMMouseScroll events aren't polluted with a kHasPixels flag.
910 * - You can make use of pixel scroll DOM events (MozMousePixelScroll).
913 class nsMouseScrollEvent : public nsMouseEvent_base
915 public:
916 enum nsMouseScrollFlags {
917 kIsFullPage = 1 << 0,
918 kIsVertical = 1 << 1,
919 kIsHorizontal = 1 << 2,
920 kHasPixels = 1 << 3 // Marks line scroll events that are provided as
921 // a fallback for pixel scroll events.
922 // These scroll events are used by things that can't
923 // be scrolled pixel-wise, like trees. You should
924 // ignore them when processing pixel scroll events
925 // to avoid double-processing the same scroll gesture.
926 // When kHasPixels is set, the event is guaranteed to
927 // be followed up by an event that contains pixel
928 // scrolling information.
931 nsMouseScrollEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
932 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
933 scrollFlags(0), delta(0)
937 PRInt32 scrollFlags;
938 PRInt32 delta;
941 class nsQueryContentEvent : public nsGUIEvent
943 public:
944 nsQueryContentEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
945 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
946 mSucceeded(PR_FALSE)
950 void InitForQueryTextContent(PRUint32 aOffset, PRUint32 aLength)
952 NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
953 "wrong initializer is called");
954 mInput.mOffset = aOffset;
955 mInput.mLength = aLength;
958 void InitForQueryCharacterRect(PRUint32 aOffset)
960 NS_ASSERTION(message == NS_QUERY_CHARACTER_RECT,
961 "wrong initializer is called");
962 mInput.mOffset = aOffset;
965 void InitForQueryCaretRect(PRUint32 aOffset)
967 NS_ASSERTION(message == NS_QUERY_CARET_RECT,
968 "wrong initializer is called");
969 mInput.mOffset = aOffset;
972 PRBool mSucceeded;
973 struct {
974 PRUint32 mOffset;
975 PRUint32 mLength;
976 } mInput;
977 struct {
978 void* mContentsRoot;
979 PRUint32 mOffset;
980 nsString mString;
981 nsRect mRect; // Finally, the coordinates is system coordinates.
982 // The return widget has the caret. This is set at all query events.
983 nsIWidget* mFocusedWidget;
984 } mReply;
988 * MenuItem event
990 * When this event occurs the widget field in nsGUIEvent holds the "target"
991 * for the event
994 class nsMenuEvent : public nsGUIEvent
996 public:
997 nsMenuEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
998 : nsGUIEvent(isTrusted, msg, w, NS_MENU_EVENT),
999 mMenuItem(nsnull), mCommand(0)
1003 nsIMenuItem * mMenuItem;
1004 PRUint32 mCommand;
1008 * Form event
1010 * We hold the originating form control for form submit and reset events.
1011 * originator is a weak pointer (does not hold a strong reference).
1014 class nsFormEvent : public nsEvent
1016 public:
1017 nsFormEvent(PRBool isTrusted, PRUint32 msg)
1018 : nsEvent(isTrusted, msg, NS_FORM_EVENT),
1019 originator(nsnull)
1023 nsIContent *originator;
1027 * Focus event
1029 class nsFocusEvent : public nsGUIEvent
1031 public:
1032 nsFocusEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1033 : nsGUIEvent(isTrusted, msg, w, NS_FOCUS_EVENT),
1034 isMozWindowTakingFocus(PR_FALSE)
1038 PRBool isMozWindowTakingFocus;
1042 * Command event
1044 * Custom commands for example from the operating system.
1047 class nsCommandEvent : public nsGUIEvent
1049 public:
1050 nsCommandEvent(PRBool isTrusted, nsIAtom* aEventType,
1051 nsIAtom* aCommand, nsIWidget* w)
1052 : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
1054 userType = aEventType;
1055 command = aCommand;
1058 nsCOMPtr<nsIAtom> command;
1062 * blocked popup window event
1064 class nsPopupBlockedEvent : public nsEvent
1066 public:
1067 nsPopupBlockedEvent(PRBool isTrusted, PRUint32 msg)
1068 : nsEvent(isTrusted, msg, NS_POPUPBLOCKED_EVENT),
1069 mPopupWindowURI(nsnull)
1073 nsWeakPtr mRequestingWindow;
1074 nsIURI* mPopupWindowURI; // owning reference
1075 nsString mPopupWindowFeatures;
1076 nsString mPopupWindowName;
1080 * DOM UIEvent
1082 class nsUIEvent : public nsEvent
1084 public:
1085 nsUIEvent(PRBool isTrusted, PRUint32 msg, PRInt32 d)
1086 : nsEvent(isTrusted, msg, NS_UI_EVENT),
1087 detail(d)
1091 PRInt32 detail;
1095 * NotifyPaint event
1097 class nsNotifyPaintEvent : public nsEvent
1099 public:
1100 nsNotifyPaintEvent(PRBool isTrusted, PRUint32 msg,
1101 const nsRegion& aSameDocRegion, const nsRegion& aCrossDocRegion)
1102 : nsEvent(isTrusted, msg, NS_NOTIFYPAINT_EVENT),
1103 sameDocRegion(aSameDocRegion), crossDocRegion(aCrossDocRegion)
1107 nsRegion sameDocRegion;
1108 nsRegion crossDocRegion;
1112 * PageTransition event
1114 class nsPageTransitionEvent : public nsEvent
1116 public:
1117 nsPageTransitionEvent(PRBool isTrusted, PRUint32 msg, PRBool p)
1118 : nsEvent(isTrusted, msg, NS_PAGETRANSITION_EVENT),
1119 persisted(p)
1123 PRBool persisted;
1127 * XUL command event
1129 class nsXULCommandEvent : public nsInputEvent
1131 public:
1132 nsXULCommandEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1133 : nsInputEvent(isTrusted, msg, w, NS_XUL_COMMAND_EVENT)
1137 nsCOMPtr<nsIDOMEvent> sourceEvent;
1141 * Simple gesture event
1143 class nsSimpleGestureEvent : public nsInputEvent
1145 public:
1146 nsSimpleGestureEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w,
1147 PRUint32 directionArg, PRFloat64 deltaArg)
1148 : nsInputEvent(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
1149 direction(directionArg), delta(deltaArg)
1153 PRUint32 direction; // See nsIDOMSimpleGestureEvent for values
1154 PRFloat64 delta; // Delta for magnify and rotate events
1158 * Event status for D&D Event
1160 enum nsDragDropEventStatus {
1161 /// The event is a enter
1162 nsDragDropEventStatus_eDragEntered,
1163 /// The event is exit
1164 nsDragDropEventStatus_eDragExited,
1165 /// The event is drop
1166 nsDragDropEventStatus_eDrop
1170 #define NS_IS_MOUSE_EVENT(evnt) \
1171 (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1172 ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1173 ((evnt)->message == NS_MOUSE_CLICK) || \
1174 ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1175 ((evnt)->message == NS_MOUSE_ENTER) || \
1176 ((evnt)->message == NS_MOUSE_EXIT) || \
1177 ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1178 ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1179 ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1180 ((evnt)->message == NS_MOUSE_MOVE))
1182 #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1183 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1184 (evnt)->message == NS_MOUSE_CLICK && \
1185 static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1187 #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1188 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1189 (evnt)->message == NS_CONTEXTMENU && \
1190 static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1192 #define NS_IS_DRAG_EVENT(evnt) \
1193 (((evnt)->message == NS_DRAGDROP_ENTER) || \
1194 ((evnt)->message == NS_DRAGDROP_OVER) || \
1195 ((evnt)->message == NS_DRAGDROP_EXIT) || \
1196 ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1197 ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1198 ((evnt)->message == NS_DRAGDROP_DRAG) || \
1199 ((evnt)->message == NS_DRAGDROP_END) || \
1200 ((evnt)->message == NS_DRAGDROP_START) || \
1201 ((evnt)->message == NS_DRAGDROP_DROP) || \
1202 ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1204 #define NS_IS_KEY_EVENT(evnt) \
1205 (((evnt)->message == NS_KEY_DOWN) || \
1206 ((evnt)->message == NS_KEY_PRESS) || \
1207 ((evnt)->message == NS_KEY_UP))
1209 #define NS_IS_IME_EVENT(evnt) \
1210 (((evnt)->message == NS_TEXT_TEXT) || \
1211 ((evnt)->message == NS_COMPOSITION_START) || \
1212 ((evnt)->message == NS_COMPOSITION_END) || \
1213 ((evnt)->message == NS_COMPOSITION_QUERY))
1215 #define NS_IS_FOCUS_EVENT(evnt) \
1216 (((evnt)->message == NS_GOTFOCUS) || \
1217 ((evnt)->message == NS_LOSTFOCUS) || \
1218 ((evnt)->message == NS_ACTIVATE) || \
1219 ((evnt)->message == NS_DEACTIVATE) || \
1220 ((evnt)->message == NS_PLUGIN_ACTIVATE))
1222 #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1223 (((evnt)->message == NS_QUERY_SELECTED_TEXT) || \
1224 ((evnt)->message == NS_QUERY_TEXT_CONTENT) || \
1225 ((evnt)->message == NS_QUERY_CHARACTER_RECT) || \
1226 ((evnt)->message == NS_QUERY_CARET_RECT))
1228 #define NS_IS_TRUSTED_EVENT(event) \
1229 (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1231 // Mark an event as being dispatching.
1232 #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1233 (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1235 #define NS_IS_EVENT_IN_DISPATCH(event) \
1236 (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1238 // Mark an event as being done dispatching.
1239 #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1240 NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1241 "Event never got marked for dispatch!"); \
1242 (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1243 (event)->flags |= NS_EVENT_DISPATCHED;
1246 * Virtual key bindings for keyboard events.
1247 * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1248 * Really, it would be better if we phased out the NS_VK symbols altogether
1249 * in favor of the DOM ones, but at least this way they'll be in sync.
1252 #define NS_VK_CANCEL nsIDOMKeyEvent::DOM_VK_CANCEL
1253 #define NS_VK_HELP nsIDOMKeyEvent::DOM_VK_HELP
1254 #define NS_VK_BACK nsIDOMKeyEvent::DOM_VK_BACK_SPACE
1255 #define NS_VK_TAB nsIDOMKeyEvent::DOM_VK_TAB
1256 #define NS_VK_CLEAR nsIDOMKeyEvent::DOM_VK_CLEAR
1257 #define NS_VK_RETURN nsIDOMKeyEvent::DOM_VK_RETURN
1258 #define NS_VK_ENTER nsIDOMKeyEvent::DOM_VK_ENTER
1259 #define NS_VK_SHIFT nsIDOMKeyEvent::DOM_VK_SHIFT
1260 #define NS_VK_CONTROL nsIDOMKeyEvent::DOM_VK_CONTROL
1261 #define NS_VK_ALT nsIDOMKeyEvent::DOM_VK_ALT
1262 #define NS_VK_PAUSE nsIDOMKeyEvent::DOM_VK_PAUSE
1263 #define NS_VK_CAPS_LOCK nsIDOMKeyEvent::DOM_VK_CAPS_LOCK
1264 #define NS_VK_ESCAPE nsIDOMKeyEvent::DOM_VK_ESCAPE
1265 #define NS_VK_SPACE nsIDOMKeyEvent::DOM_VK_SPACE
1266 #define NS_VK_PAGE_UP nsIDOMKeyEvent::DOM_VK_PAGE_UP
1267 #define NS_VK_PAGE_DOWN nsIDOMKeyEvent::DOM_VK_PAGE_DOWN
1268 #define NS_VK_END nsIDOMKeyEvent::DOM_VK_END
1269 #define NS_VK_HOME nsIDOMKeyEvent::DOM_VK_HOME
1270 #define NS_VK_LEFT nsIDOMKeyEvent::DOM_VK_LEFT
1271 #define NS_VK_UP nsIDOMKeyEvent::DOM_VK_UP
1272 #define NS_VK_RIGHT nsIDOMKeyEvent::DOM_VK_RIGHT
1273 #define NS_VK_DOWN nsIDOMKeyEvent::DOM_VK_DOWN
1274 #define NS_VK_PRINTSCREEN nsIDOMKeyEvent::DOM_VK_PRINTSCREEN
1275 #define NS_VK_INSERT nsIDOMKeyEvent::DOM_VK_INSERT
1276 #define NS_VK_DELETE nsIDOMKeyEvent::DOM_VK_DELETE
1278 // NS_VK_0 - NS_VK_9 match their ascii values
1279 #define NS_VK_0 nsIDOMKeyEvent::DOM_VK_0
1280 #define NS_VK_1 nsIDOMKeyEvent::DOM_VK_1
1281 #define NS_VK_2 nsIDOMKeyEvent::DOM_VK_2
1282 #define NS_VK_3 nsIDOMKeyEvent::DOM_VK_3
1283 #define NS_VK_4 nsIDOMKeyEvent::DOM_VK_4
1284 #define NS_VK_5 nsIDOMKeyEvent::DOM_VK_5
1285 #define NS_VK_6 nsIDOMKeyEvent::DOM_VK_6
1286 #define NS_VK_7 nsIDOMKeyEvent::DOM_VK_7
1287 #define NS_VK_8 nsIDOMKeyEvent::DOM_VK_8
1288 #define NS_VK_9 nsIDOMKeyEvent::DOM_VK_9
1290 #define NS_VK_SEMICOLON nsIDOMKeyEvent::DOM_VK_SEMICOLON
1291 #define NS_VK_EQUALS nsIDOMKeyEvent::DOM_VK_EQUALS
1293 // NS_VK_A - NS_VK_Z match their ascii values
1294 #define NS_VK_A nsIDOMKeyEvent::DOM_VK_A
1295 #define NS_VK_B nsIDOMKeyEvent::DOM_VK_B
1296 #define NS_VK_C nsIDOMKeyEvent::DOM_VK_C
1297 #define NS_VK_D nsIDOMKeyEvent::DOM_VK_D
1298 #define NS_VK_E nsIDOMKeyEvent::DOM_VK_E
1299 #define NS_VK_F nsIDOMKeyEvent::DOM_VK_F
1300 #define NS_VK_G nsIDOMKeyEvent::DOM_VK_G
1301 #define NS_VK_H nsIDOMKeyEvent::DOM_VK_H
1302 #define NS_VK_I nsIDOMKeyEvent::DOM_VK_I
1303 #define NS_VK_J nsIDOMKeyEvent::DOM_VK_J
1304 #define NS_VK_K nsIDOMKeyEvent::DOM_VK_K
1305 #define NS_VK_L nsIDOMKeyEvent::DOM_VK_L
1306 #define NS_VK_M nsIDOMKeyEvent::DOM_VK_M
1307 #define NS_VK_N nsIDOMKeyEvent::DOM_VK_N
1308 #define NS_VK_O nsIDOMKeyEvent::DOM_VK_O
1309 #define NS_VK_P nsIDOMKeyEvent::DOM_VK_P
1310 #define NS_VK_Q nsIDOMKeyEvent::DOM_VK_Q
1311 #define NS_VK_R nsIDOMKeyEvent::DOM_VK_R
1312 #define NS_VK_S nsIDOMKeyEvent::DOM_VK_S
1313 #define NS_VK_T nsIDOMKeyEvent::DOM_VK_T
1314 #define NS_VK_U nsIDOMKeyEvent::DOM_VK_U
1315 #define NS_VK_V nsIDOMKeyEvent::DOM_VK_V
1316 #define NS_VK_W nsIDOMKeyEvent::DOM_VK_W
1317 #define NS_VK_X nsIDOMKeyEvent::DOM_VK_X
1318 #define NS_VK_Y nsIDOMKeyEvent::DOM_VK_Y
1319 #define NS_VK_Z nsIDOMKeyEvent::DOM_VK_Z
1321 #define NS_VK_CONTEXT_MENU nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU
1323 #define NS_VK_NUMPAD0 nsIDOMKeyEvent::DOM_VK_NUMPAD0
1324 #define NS_VK_NUMPAD1 nsIDOMKeyEvent::DOM_VK_NUMPAD1
1325 #define NS_VK_NUMPAD2 nsIDOMKeyEvent::DOM_VK_NUMPAD2
1326 #define NS_VK_NUMPAD3 nsIDOMKeyEvent::DOM_VK_NUMPAD3
1327 #define NS_VK_NUMPAD4 nsIDOMKeyEvent::DOM_VK_NUMPAD4
1328 #define NS_VK_NUMPAD5 nsIDOMKeyEvent::DOM_VK_NUMPAD5
1329 #define NS_VK_NUMPAD6 nsIDOMKeyEvent::DOM_VK_NUMPAD6
1330 #define NS_VK_NUMPAD7 nsIDOMKeyEvent::DOM_VK_NUMPAD7
1331 #define NS_VK_NUMPAD8 nsIDOMKeyEvent::DOM_VK_NUMPAD8
1332 #define NS_VK_NUMPAD9 nsIDOMKeyEvent::DOM_VK_NUMPAD9
1333 #define NS_VK_MULTIPLY nsIDOMKeyEvent::DOM_VK_MULTIPLY
1334 #define NS_VK_ADD nsIDOMKeyEvent::DOM_VK_ADD
1335 #define NS_VK_SEPARATOR nsIDOMKeyEvent::DOM_VK_SEPARATOR
1336 #define NS_VK_SUBTRACT nsIDOMKeyEvent::DOM_VK_SUBTRACT
1337 #define NS_VK_DECIMAL nsIDOMKeyEvent::DOM_VK_DECIMAL
1338 #define NS_VK_DIVIDE nsIDOMKeyEvent::DOM_VK_DIVIDE
1339 #define NS_VK_F1 nsIDOMKeyEvent::DOM_VK_F1
1340 #define NS_VK_F2 nsIDOMKeyEvent::DOM_VK_F2
1341 #define NS_VK_F3 nsIDOMKeyEvent::DOM_VK_F3
1342 #define NS_VK_F4 nsIDOMKeyEvent::DOM_VK_F4
1343 #define NS_VK_F5 nsIDOMKeyEvent::DOM_VK_F5
1344 #define NS_VK_F6 nsIDOMKeyEvent::DOM_VK_F6
1345 #define NS_VK_F7 nsIDOMKeyEvent::DOM_VK_F7
1346 #define NS_VK_F8 nsIDOMKeyEvent::DOM_VK_F8
1347 #define NS_VK_F9 nsIDOMKeyEvent::DOM_VK_F9
1348 #define NS_VK_F10 nsIDOMKeyEvent::DOM_VK_F10
1349 #define NS_VK_F11 nsIDOMKeyEvent::DOM_VK_F11
1350 #define NS_VK_F12 nsIDOMKeyEvent::DOM_VK_F12
1351 #define NS_VK_F13 nsIDOMKeyEvent::DOM_VK_F13
1352 #define NS_VK_F14 nsIDOMKeyEvent::DOM_VK_F14
1353 #define NS_VK_F15 nsIDOMKeyEvent::DOM_VK_F15
1354 #define NS_VK_F16 nsIDOMKeyEvent::DOM_VK_F16
1355 #define NS_VK_F17 nsIDOMKeyEvent::DOM_VK_F17
1356 #define NS_VK_F18 nsIDOMKeyEvent::DOM_VK_F18
1357 #define NS_VK_F19 nsIDOMKeyEvent::DOM_VK_F19
1358 #define NS_VK_F20 nsIDOMKeyEvent::DOM_VK_F20
1359 #define NS_VK_F21 nsIDOMKeyEvent::DOM_VK_F21
1360 #define NS_VK_F22 nsIDOMKeyEvent::DOM_VK_F22
1361 #define NS_VK_F23 nsIDOMKeyEvent::DOM_VK_F23
1362 #define NS_VK_F24 nsIDOMKeyEvent::DOM_VK_F24
1364 #define NS_VK_NUM_LOCK nsIDOMKeyEvent::DOM_VK_NUM_LOCK
1365 #define NS_VK_SCROLL_LOCK nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK
1367 #define NS_VK_COMMA nsIDOMKeyEvent::DOM_VK_COMMA
1368 #define NS_VK_PERIOD nsIDOMKeyEvent::DOM_VK_PERIOD
1369 #define NS_VK_SLASH nsIDOMKeyEvent::DOM_VK_SLASH
1370 #define NS_VK_BACK_QUOTE nsIDOMKeyEvent::DOM_VK_BACK_QUOTE
1371 #define NS_VK_OPEN_BRACKET nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET
1372 #define NS_VK_BACK_SLASH nsIDOMKeyEvent::DOM_VK_BACK_SLASH
1373 #define NS_VK_CLOSE_BRACKET nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET
1374 #define NS_VK_QUOTE nsIDOMKeyEvent::DOM_VK_QUOTE
1376 #define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
1378 // IME Constants -- keep in synch with nsIDOMTextRange.h
1379 #define NS_TEXTRANGE_CARETPOSITION 0x01
1380 #define NS_TEXTRANGE_RAWINPUT 0X02
1381 #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1382 #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1383 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1385 inline PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent)
1387 #if defined(MOZ_X11) || defined(XP_MACOSX)
1388 // bug 52416 (MOZ_X11)
1389 // Lookup region (candidate window) of UNIX IME grabs
1390 // input focus from Mozilla but wants to send IME event
1391 // to redraw pre-edit (composed) string
1392 // If Mozilla does not have input focus and event is IME,
1393 // sends IME event to pre-focused element
1395 // bug 417315 (XP_MACOSX)
1396 // The commit event when the window is deactivating is sent after
1397 // the next focused widget getting the focus.
1398 // We need to send the commit event to last focused content.
1400 return NS_IS_IME_EVENT(aEvent);
1401 #elif defined(XP_WIN)
1402 // bug 292263 (XP_WIN)
1403 // If software keyboard has focus, it may send the key messages and
1404 // the IME messages to pre-focused window. Therefore, if Mozilla
1405 // doesn't have focus and event is key event or IME event, we should
1406 // send the events to pre-focused element.
1408 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent);
1409 #else
1410 return PR_FALSE;
1411 #endif
1414 #endif // nsGUIEvent_h__