Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / widget / public / nsGUIEvent.h
bloba3eecafe4315578ceecf6c8490b616cfd9e4f9c0
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_LOADEDDATA (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_CANPLAY (NS_MEDIA_EVENT_START+13)
373 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+14)
374 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+15)
375 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+16)
376 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+17)
377 #define NS_MEDIA_ABORT (NS_MEDIA_EVENT_START+18)
378 #define NS_MEDIA_ERROR (NS_MEDIA_EVENT_START+19)
379 #endif // MOZ_MEDIA
381 // paint notification events
382 #define NS_NOTIFYPAINT_START 3400
383 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
385 // Simple gesture events
386 #define NS_SIMPLE_GESTURE_EVENT_START 3500
387 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
388 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
389 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
390 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
391 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
392 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
393 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
395 // Plug-in event. This is used when a plug-in has focus and when the native
396 // event needs to be passed to the focused plug-in directly.
397 #define NS_PLUGIN_EVENT_START 3600
398 #define NS_PLUGIN_EVENT (NS_PLUGIN_EVENT_START)
401 * Return status for event processors, nsEventStatus, is defined in
402 * nsEvent.h.
406 * sizemode is an adjunct to widget size
408 enum nsSizeMode {
409 nsSizeMode_Normal = 0,
410 nsSizeMode_Minimized,
411 nsSizeMode_Maximized
415 * different types of (top-level) window z-level positioning
417 enum nsWindowZ {
418 nsWindowZTop = 0, // on top
419 nsWindowZBottom, // on bottom
420 nsWindowZRelative // just below some specified widget
424 * General event
427 class nsEvent
429 protected:
430 nsEvent(PRBool isTrusted, PRUint32 msg, PRUint8 structType)
431 : eventStructType(structType),
432 message(msg),
433 refPoint(0, 0),
434 time(0),
435 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
436 userType(0)
438 MOZ_COUNT_CTOR(nsEvent);
441 public:
442 nsEvent(PRBool isTrusted, PRUint32 msg)
443 : eventStructType(NS_EVENT),
444 message(msg),
445 refPoint(0, 0),
446 time(0),
447 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
448 userType(0)
450 MOZ_COUNT_CTOR(nsEvent);
453 ~nsEvent()
455 MOZ_COUNT_DTOR(nsEvent);
458 // See event struct types
459 PRUint8 eventStructType;
460 // See GUI MESSAGES,
461 PRUint32 message;
462 // In widget relative coordinates, not modified by layout code.
463 nsPoint refPoint;
464 // Elapsed time, in milliseconds, from a platform-specific zero time
465 // to the time the message was created
466 PRUint32 time;
467 // Flags to hold event flow stage and capture/bubble cancellation
468 // status. This is used also to indicate whether the event is trusted.
469 PRUint32 flags;
470 // Additional type info for user defined events
471 nsCOMPtr<nsIAtom> userType;
472 // Event targets, needed by DOM Events
473 // Using nsISupports, not nsIDOMEventTarget because in some cases
474 // nsIDOMEventTarget is implemented as a tearoff.
475 nsCOMPtr<nsISupports> target;
476 nsCOMPtr<nsISupports> currentTarget;
477 nsCOMPtr<nsISupports> originalTarget;
481 * General graphic user interface event
484 class nsGUIEvent : public nsEvent
486 protected:
487 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
488 : nsEvent(isTrusted, msg, structType),
489 widget(w), nativeMsg(nsnull)
493 public:
494 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
495 : nsEvent(isTrusted, msg, NS_GUI_EVENT),
496 widget(w), nativeMsg(nsnull)
500 /// Originator of the event
501 nsCOMPtr<nsIWidget> widget;
503 /// Internal platform specific message.
504 void* nativeMsg;
508 * Script error event
511 class nsScriptErrorEvent : public nsEvent
513 public:
514 nsScriptErrorEvent(PRBool isTrusted, PRUint32 msg)
515 : nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
516 lineNr(0), errorMsg(nsnull), fileName(nsnull)
520 PRInt32 lineNr;
521 const PRUnichar* errorMsg;
522 const PRUnichar* fileName;
525 class nsBeforePageUnloadEvent : public nsEvent
527 public:
528 nsBeforePageUnloadEvent(PRBool isTrusted, PRUint32 msg)
529 : nsEvent(isTrusted, msg, NS_BEFORE_PAGE_UNLOAD_EVENT)
533 nsString text;
537 * Window resize event
540 class nsSizeEvent : public nsGUIEvent
542 public:
543 nsSizeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
544 : nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
545 windowSize(nsnull), mWinWidth(0), mWinHeight(0)
549 /// x,y width, height in pixels (client area)
550 nsRect *windowSize;
551 /// width of entire window (in pixels)
552 PRInt32 mWinWidth;
553 /// height of entire window (in pixels)
554 PRInt32 mWinHeight;
558 * Window size mode event
561 class nsSizeModeEvent : public nsGUIEvent
563 public:
564 nsSizeModeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
565 : nsGUIEvent(isTrusted, msg, w, NS_SIZEMODE_EVENT),
566 mSizeMode(nsSizeMode_Normal)
570 nsSizeMode mSizeMode;
574 * Window z-level event
577 class nsZLevelEvent : public nsGUIEvent
579 public:
580 nsZLevelEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
581 : nsGUIEvent(isTrusted, msg, w, NS_ZLEVEL_EVENT),
582 mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull),
583 mImmediate(PR_FALSE), mAdjusted(PR_FALSE)
587 nsWindowZ mPlacement;
588 nsIWidget *mReqBelow, // widget we request being below, if any
589 *mActualBelow; // widget to be below, returned by handler
590 PRBool mImmediate, // handler should make changes immediately
591 mAdjusted; // handler changed placement
595 * Window repaint event
598 class nsPaintEvent : public nsGUIEvent
600 public:
601 nsPaintEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
602 : nsGUIEvent(isTrusted, msg, w, NS_PAINT_EVENT),
603 renderingContext(nsnull), region(nsnull), rect(nsnull)
607 /// Context to paint in.
608 nsIRenderingContext *renderingContext;
609 /// area to paint (should be used instead of rect)
610 nsIRegion *region;
611 /// x,y, width, height in pixels of area to paint
612 nsRect *rect;
616 * Scrollbar event
619 class nsScrollbarEvent : public nsGUIEvent
621 public:
622 nsScrollbarEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
623 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
624 position(0)
628 /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
629 PRUint32 position;
632 class nsScrollPortEvent : public nsGUIEvent
634 public:
635 enum orientType {
636 vertical = 0,
637 horizontal = 1,
638 both = 2
641 nsScrollPortEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
642 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
643 orient(vertical)
647 orientType orient;
650 class nsInputEvent : public nsGUIEvent
652 protected:
653 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
654 PRUint8 structType)
655 : nsGUIEvent(isTrusted, msg, w, structType),
656 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
660 public:
661 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
662 : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
663 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
667 /// PR_TRUE indicates the shift key is down
668 PRBool isShift;
669 /// PR_TRUE indicates the control key is down
670 PRBool isControl;
671 /// PR_TRUE indicates the alt key is down
672 PRBool isAlt;
673 /// PR_TRUE indicates the meta key is down (or, on Mac, the Command key)
674 PRBool isMeta;
678 * Mouse event
681 class nsMouseEvent_base : public nsInputEvent
683 public:
684 nsMouseEvent_base(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 type)
685 : nsInputEvent(isTrusted, msg, w, type), button(0), pressure(0) {}
687 /// The possible related target
688 nsCOMPtr<nsISupports> relatedTarget;
690 PRInt16 button;
692 // Finger or touch pressure of event
693 // ranges between 0.0 and 1.0
694 float pressure;
697 class nsMouseEvent : public nsMouseEvent_base
699 public:
700 enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
701 enum reasonType { eReal, eSynthesized };
702 enum contextType { eNormal, eContextMenuKey };
703 enum exitType { eChild, eTopLevel };
705 protected:
706 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
707 PRUint8 structType, reasonType aReason)
708 : nsMouseEvent_base(isTrusted, msg, w, structType),
709 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
710 reason(aReason), context(eNormal), exit(eChild), clickCount(0)
712 if (msg == NS_MOUSE_MOVE) {
713 flags |= NS_EVENT_FLAG_CANT_CANCEL;
717 public:
719 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
720 reasonType aReason, contextType aContext = eNormal)
721 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
722 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
723 reason(aReason), context(aContext), exit(eChild), clickCount(0)
725 if (msg == NS_MOUSE_MOVE) {
726 flags |= NS_EVENT_FLAG_CANT_CANCEL;
727 } else if (msg == NS_CONTEXTMENU) {
728 button = (context == eNormal) ? eRightButton : eLeftButton;
731 #ifdef NS_DEBUG
732 ~nsMouseEvent() {
733 NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
734 button ==
735 ((context == eNormal) ? eRightButton : eLeftButton),
736 "Wrong button set to NS_CONTEXTMENU event?");
738 #endif
740 /// Special return code for MOUSE_ACTIVATE to signal
741 /// if the target accepts activation (1), or denies it (0)
742 PRPackedBool acceptActivation;
743 // Whether the event should ignore scroll frame bounds
744 // during dispatch.
745 PRPackedBool ignoreRootScrollFrame;
747 reasonType reason : 4;
748 contextType context : 4;
749 exitType exit;
751 /// The number of mouse clicks
752 PRUint32 clickCount;
756 * Drag event
759 class nsDragEvent : public nsMouseEvent
761 public:
762 nsDragEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
763 : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal)
765 if (msg == NS_DRAGDROP_EXIT_SYNTH ||
766 msg == NS_DRAGDROP_LEAVE_SYNTH ||
767 msg == NS_DRAGDROP_END) {
768 flags |= NS_EVENT_FLAG_CANT_CANCEL;
772 nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
776 * Accessible event
779 class nsAccessibleEvent : public nsInputEvent
781 public:
782 nsAccessibleEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
783 : nsInputEvent(isTrusted, msg, w, NS_ACCESSIBLE_EVENT),
784 accessible(nsnull)
788 nsIAccessible* accessible;
792 * Keyboard event
795 struct nsAlternativeCharCode {
796 nsAlternativeCharCode(PRUint32 aUnshiftedCharCode,
797 PRUint32 aShiftedCharCode) :
798 mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
801 PRUint32 mUnshiftedCharCode;
802 PRUint32 mShiftedCharCode;
805 class nsKeyEvent : public nsInputEvent
807 public:
808 nsKeyEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
809 : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
810 keyCode(0), charCode(0), isChar(0)
814 /// see NS_VK codes
815 PRUint32 keyCode;
816 /// OS translated Unicode char
817 PRUint32 charCode;
818 // OS translated Unicode chars which are used for accesskey and accelkey
819 // handling. The handlers will try from first character to last character.
820 nsTArray<nsAlternativeCharCode> alternativeCharCodes;
821 // indicates whether the event signifies a printable character
822 PRBool isChar;
826 * IME Related Events
828 struct nsTextRange
830 nsTextRange()
831 : mStartOffset(0), mEndOffset(0), mRangeType(0)
835 PRUint32 mStartOffset;
836 PRUint32 mEndOffset;
837 PRUint32 mRangeType;
840 typedef nsTextRange* nsTextRangeArray;
842 struct nsTextEventReply
844 nsTextEventReply()
845 : mCursorIsCollapsed(PR_FALSE), mReferenceWidget(nsnull)
849 nsRect mCursorPosition;
850 PRBool mCursorIsCollapsed;
851 nsIWidget* mReferenceWidget;
854 typedef struct nsTextEventReply nsTextEventReply;
856 class nsTextEvent : public nsInputEvent
858 public:
859 nsTextEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
860 : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
861 theText(nsnull), rangeCount(0), rangeArray(nsnull), isChar(PR_FALSE)
865 const PRUnichar* theText;
866 nsTextEventReply theReply;
867 PRUint32 rangeCount;
868 // Note that the range array may not specify a caret position; in that
869 // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
870 // array.
871 nsTextRangeArray rangeArray;
872 PRBool isChar;
875 class nsCompositionEvent : public nsInputEvent
877 public:
878 nsCompositionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
879 : nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
883 nsTextEventReply theReply;
886 /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
888 * There are two common event flows:
889 * (1) Normal line scrolling:
890 * 1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
891 * 2. A DOMMouseScroll event is sent into the DOM.
892 * 3. A MozMousePixelScroll event is sent into the DOM.
893 * 4. If neither event has been consumed, the default handling of the
894 * NS_MOUSE_SCROLL event is executed.
896 * (2) Pixel scrolling:
897 * 1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
898 * 2. A DOMMouseScroll event is sent into the DOM.
899 * 3. No scrolling takes place in the default handler.
900 * 4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
901 * 5. A MozMousePixelScroll event is sent into the DOM.
902 * 6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
903 * NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
904 * 7. Steps 4.-6. are repeated for every pixel scroll that belongs to
905 * the announced line scroll. Once enough pixels have been sent to
906 * complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
908 * If a DOMMouseScroll event has been preventDefaulted, the associated
909 * following MozMousePixelScroll events are still sent - they just don't result
910 * in any scrolling (their default handler isn't executed).
912 * How many pixel scrolls make up one line scroll is decided in the widget layer
913 * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
915 * This event flow model satisfies several requirements:
916 * - DOMMouseScroll handlers don't need to be aware of the existence of pixel
917 * scrolling.
918 * - preventDefault on a DOMMouseScroll event results in no scrolling.
919 * - DOMMouseScroll events aren't polluted with a kHasPixels flag.
920 * - You can make use of pixel scroll DOM events (MozMousePixelScroll).
923 class nsMouseScrollEvent : public nsMouseEvent_base
925 public:
926 enum nsMouseScrollFlags {
927 kIsFullPage = 1 << 0,
928 kIsVertical = 1 << 1,
929 kIsHorizontal = 1 << 2,
930 kHasPixels = 1 << 3 // Marks line scroll events that are provided as
931 // a fallback for pixel scroll events.
932 // These scroll events are used by things that can't
933 // be scrolled pixel-wise, like trees. You should
934 // ignore them when processing pixel scroll events
935 // to avoid double-processing the same scroll gesture.
936 // When kHasPixels is set, the event is guaranteed to
937 // be followed up by an event that contains pixel
938 // scrolling information.
941 nsMouseScrollEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
942 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
943 scrollFlags(0), delta(0)
947 PRInt32 scrollFlags;
948 PRInt32 delta;
951 class nsQueryContentEvent : public nsGUIEvent
953 public:
954 nsQueryContentEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
955 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
956 mSucceeded(PR_FALSE)
960 void InitForQueryTextContent(PRUint32 aOffset, PRUint32 aLength)
962 NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
963 "wrong initializer is called");
964 mInput.mOffset = aOffset;
965 mInput.mLength = aLength;
968 void InitForQueryCharacterRect(PRUint32 aOffset)
970 NS_ASSERTION(message == NS_QUERY_CHARACTER_RECT,
971 "wrong initializer is called");
972 mInput.mOffset = aOffset;
975 void InitForQueryCaretRect(PRUint32 aOffset)
977 NS_ASSERTION(message == NS_QUERY_CARET_RECT,
978 "wrong initializer is called");
979 mInput.mOffset = aOffset;
982 PRBool mSucceeded;
983 struct {
984 PRUint32 mOffset;
985 PRUint32 mLength;
986 } mInput;
987 struct {
988 void* mContentsRoot;
989 PRUint32 mOffset;
990 nsString mString;
991 nsRect mRect; // Finally, the coordinates is system coordinates.
992 // The return widget has the caret. This is set at all query events.
993 nsIWidget* mFocusedWidget;
994 } mReply;
998 * MenuItem event
1000 * When this event occurs the widget field in nsGUIEvent holds the "target"
1001 * for the event
1004 class nsMenuEvent : public nsGUIEvent
1006 public:
1007 nsMenuEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1008 : nsGUIEvent(isTrusted, msg, w, NS_MENU_EVENT),
1009 mMenuItem(nsnull), mCommand(0)
1013 nsIMenuItem * mMenuItem;
1014 PRUint32 mCommand;
1018 * Form event
1020 * We hold the originating form control for form submit and reset events.
1021 * originator is a weak pointer (does not hold a strong reference).
1024 class nsFormEvent : public nsEvent
1026 public:
1027 nsFormEvent(PRBool isTrusted, PRUint32 msg)
1028 : nsEvent(isTrusted, msg, NS_FORM_EVENT),
1029 originator(nsnull)
1033 nsIContent *originator;
1037 * Focus event
1039 class nsFocusEvent : public nsGUIEvent
1041 public:
1042 nsFocusEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1043 : nsGUIEvent(isTrusted, msg, w, NS_FOCUS_EVENT),
1044 isMozWindowTakingFocus(PR_FALSE)
1048 PRBool isMozWindowTakingFocus;
1052 * Command event
1054 * Custom commands for example from the operating system.
1057 class nsCommandEvent : public nsGUIEvent
1059 public:
1060 nsCommandEvent(PRBool isTrusted, nsIAtom* aEventType,
1061 nsIAtom* aCommand, nsIWidget* w)
1062 : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
1064 userType = aEventType;
1065 command = aCommand;
1068 nsCOMPtr<nsIAtom> command;
1072 * blocked popup window event
1074 class nsPopupBlockedEvent : public nsEvent
1076 public:
1077 nsPopupBlockedEvent(PRBool isTrusted, PRUint32 msg)
1078 : nsEvent(isTrusted, msg, NS_POPUPBLOCKED_EVENT),
1079 mPopupWindowURI(nsnull)
1083 nsWeakPtr mRequestingWindow;
1084 nsIURI* mPopupWindowURI; // owning reference
1085 nsString mPopupWindowFeatures;
1086 nsString mPopupWindowName;
1090 * DOM UIEvent
1092 class nsUIEvent : public nsEvent
1094 public:
1095 nsUIEvent(PRBool isTrusted, PRUint32 msg, PRInt32 d)
1096 : nsEvent(isTrusted, msg, NS_UI_EVENT),
1097 detail(d)
1101 PRInt32 detail;
1105 * NotifyPaint event
1107 class nsNotifyPaintEvent : public nsEvent
1109 public:
1110 nsNotifyPaintEvent(PRBool isTrusted, PRUint32 msg,
1111 const nsRegion& aSameDocRegion, const nsRegion& aCrossDocRegion)
1112 : nsEvent(isTrusted, msg, NS_NOTIFYPAINT_EVENT),
1113 sameDocRegion(aSameDocRegion), crossDocRegion(aCrossDocRegion)
1117 nsRegion sameDocRegion;
1118 nsRegion crossDocRegion;
1122 * PageTransition event
1124 class nsPageTransitionEvent : public nsEvent
1126 public:
1127 nsPageTransitionEvent(PRBool isTrusted, PRUint32 msg, PRBool p)
1128 : nsEvent(isTrusted, msg, NS_PAGETRANSITION_EVENT),
1129 persisted(p)
1133 PRBool persisted;
1137 * XUL command event
1139 class nsXULCommandEvent : public nsInputEvent
1141 public:
1142 nsXULCommandEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1143 : nsInputEvent(isTrusted, msg, w, NS_XUL_COMMAND_EVENT)
1147 nsCOMPtr<nsIDOMEvent> sourceEvent;
1151 * Simple gesture event
1153 class nsSimpleGestureEvent : public nsInputEvent
1155 public:
1156 nsSimpleGestureEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w,
1157 PRUint32 directionArg, PRFloat64 deltaArg)
1158 : nsInputEvent(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
1159 direction(directionArg), delta(deltaArg)
1163 PRUint32 direction; // See nsIDOMSimpleGestureEvent for values
1164 PRFloat64 delta; // Delta for magnify and rotate events
1168 * Event status for D&D Event
1170 enum nsDragDropEventStatus {
1171 /// The event is a enter
1172 nsDragDropEventStatus_eDragEntered,
1173 /// The event is exit
1174 nsDragDropEventStatus_eDragExited,
1175 /// The event is drop
1176 nsDragDropEventStatus_eDrop
1180 #define NS_IS_MOUSE_EVENT(evnt) \
1181 (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1182 ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1183 ((evnt)->message == NS_MOUSE_CLICK) || \
1184 ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1185 ((evnt)->message == NS_MOUSE_ENTER) || \
1186 ((evnt)->message == NS_MOUSE_EXIT) || \
1187 ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1188 ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1189 ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1190 ((evnt)->message == NS_MOUSE_MOVE))
1192 #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1193 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1194 (evnt)->message == NS_MOUSE_CLICK && \
1195 static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1197 #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1198 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1199 (evnt)->message == NS_CONTEXTMENU && \
1200 static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1202 #define NS_IS_DRAG_EVENT(evnt) \
1203 (((evnt)->message == NS_DRAGDROP_ENTER) || \
1204 ((evnt)->message == NS_DRAGDROP_OVER) || \
1205 ((evnt)->message == NS_DRAGDROP_EXIT) || \
1206 ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1207 ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1208 ((evnt)->message == NS_DRAGDROP_DRAG) || \
1209 ((evnt)->message == NS_DRAGDROP_END) || \
1210 ((evnt)->message == NS_DRAGDROP_START) || \
1211 ((evnt)->message == NS_DRAGDROP_DROP) || \
1212 ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1214 #define NS_IS_KEY_EVENT(evnt) \
1215 (((evnt)->message == NS_KEY_DOWN) || \
1216 ((evnt)->message == NS_KEY_PRESS) || \
1217 ((evnt)->message == NS_KEY_UP))
1219 #define NS_IS_IME_EVENT(evnt) \
1220 (((evnt)->message == NS_TEXT_TEXT) || \
1221 ((evnt)->message == NS_COMPOSITION_START) || \
1222 ((evnt)->message == NS_COMPOSITION_END) || \
1223 ((evnt)->message == NS_COMPOSITION_QUERY))
1225 #define NS_IS_FOCUS_EVENT(evnt) \
1226 (((evnt)->message == NS_GOTFOCUS) || \
1227 ((evnt)->message == NS_LOSTFOCUS) || \
1228 ((evnt)->message == NS_ACTIVATE) || \
1229 ((evnt)->message == NS_DEACTIVATE) || \
1230 ((evnt)->message == NS_PLUGIN_ACTIVATE))
1232 #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1233 (((evnt)->message == NS_QUERY_SELECTED_TEXT) || \
1234 ((evnt)->message == NS_QUERY_TEXT_CONTENT) || \
1235 ((evnt)->message == NS_QUERY_CHARACTER_RECT) || \
1236 ((evnt)->message == NS_QUERY_CARET_RECT))
1238 #define NS_IS_PLUGIN_EVENT(evnt) \
1239 (((evnt)->message == NS_PLUGIN_EVENT))
1241 #define NS_IS_TRUSTED_EVENT(event) \
1242 (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1244 // Mark an event as being dispatching.
1245 #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1246 (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1248 #define NS_IS_EVENT_IN_DISPATCH(event) \
1249 (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1251 // Mark an event as being done dispatching.
1252 #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1253 NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1254 "Event never got marked for dispatch!"); \
1255 (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1256 (event)->flags |= NS_EVENT_DISPATCHED;
1259 * Virtual key bindings for keyboard events.
1260 * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1261 * Really, it would be better if we phased out the NS_VK symbols altogether
1262 * in favor of the DOM ones, but at least this way they'll be in sync.
1265 #define NS_VK_CANCEL nsIDOMKeyEvent::DOM_VK_CANCEL
1266 #define NS_VK_HELP nsIDOMKeyEvent::DOM_VK_HELP
1267 #define NS_VK_BACK nsIDOMKeyEvent::DOM_VK_BACK_SPACE
1268 #define NS_VK_TAB nsIDOMKeyEvent::DOM_VK_TAB
1269 #define NS_VK_CLEAR nsIDOMKeyEvent::DOM_VK_CLEAR
1270 #define NS_VK_RETURN nsIDOMKeyEvent::DOM_VK_RETURN
1271 #define NS_VK_ENTER nsIDOMKeyEvent::DOM_VK_ENTER
1272 #define NS_VK_SHIFT nsIDOMKeyEvent::DOM_VK_SHIFT
1273 #define NS_VK_CONTROL nsIDOMKeyEvent::DOM_VK_CONTROL
1274 #define NS_VK_ALT nsIDOMKeyEvent::DOM_VK_ALT
1275 #define NS_VK_PAUSE nsIDOMKeyEvent::DOM_VK_PAUSE
1276 #define NS_VK_CAPS_LOCK nsIDOMKeyEvent::DOM_VK_CAPS_LOCK
1277 #define NS_VK_ESCAPE nsIDOMKeyEvent::DOM_VK_ESCAPE
1278 #define NS_VK_SPACE nsIDOMKeyEvent::DOM_VK_SPACE
1279 #define NS_VK_PAGE_UP nsIDOMKeyEvent::DOM_VK_PAGE_UP
1280 #define NS_VK_PAGE_DOWN nsIDOMKeyEvent::DOM_VK_PAGE_DOWN
1281 #define NS_VK_END nsIDOMKeyEvent::DOM_VK_END
1282 #define NS_VK_HOME nsIDOMKeyEvent::DOM_VK_HOME
1283 #define NS_VK_LEFT nsIDOMKeyEvent::DOM_VK_LEFT
1284 #define NS_VK_UP nsIDOMKeyEvent::DOM_VK_UP
1285 #define NS_VK_RIGHT nsIDOMKeyEvent::DOM_VK_RIGHT
1286 #define NS_VK_DOWN nsIDOMKeyEvent::DOM_VK_DOWN
1287 #define NS_VK_PRINTSCREEN nsIDOMKeyEvent::DOM_VK_PRINTSCREEN
1288 #define NS_VK_INSERT nsIDOMKeyEvent::DOM_VK_INSERT
1289 #define NS_VK_DELETE nsIDOMKeyEvent::DOM_VK_DELETE
1291 // NS_VK_0 - NS_VK_9 match their ascii values
1292 #define NS_VK_0 nsIDOMKeyEvent::DOM_VK_0
1293 #define NS_VK_1 nsIDOMKeyEvent::DOM_VK_1
1294 #define NS_VK_2 nsIDOMKeyEvent::DOM_VK_2
1295 #define NS_VK_3 nsIDOMKeyEvent::DOM_VK_3
1296 #define NS_VK_4 nsIDOMKeyEvent::DOM_VK_4
1297 #define NS_VK_5 nsIDOMKeyEvent::DOM_VK_5
1298 #define NS_VK_6 nsIDOMKeyEvent::DOM_VK_6
1299 #define NS_VK_7 nsIDOMKeyEvent::DOM_VK_7
1300 #define NS_VK_8 nsIDOMKeyEvent::DOM_VK_8
1301 #define NS_VK_9 nsIDOMKeyEvent::DOM_VK_9
1303 #define NS_VK_SEMICOLON nsIDOMKeyEvent::DOM_VK_SEMICOLON
1304 #define NS_VK_EQUALS nsIDOMKeyEvent::DOM_VK_EQUALS
1306 // NS_VK_A - NS_VK_Z match their ascii values
1307 #define NS_VK_A nsIDOMKeyEvent::DOM_VK_A
1308 #define NS_VK_B nsIDOMKeyEvent::DOM_VK_B
1309 #define NS_VK_C nsIDOMKeyEvent::DOM_VK_C
1310 #define NS_VK_D nsIDOMKeyEvent::DOM_VK_D
1311 #define NS_VK_E nsIDOMKeyEvent::DOM_VK_E
1312 #define NS_VK_F nsIDOMKeyEvent::DOM_VK_F
1313 #define NS_VK_G nsIDOMKeyEvent::DOM_VK_G
1314 #define NS_VK_H nsIDOMKeyEvent::DOM_VK_H
1315 #define NS_VK_I nsIDOMKeyEvent::DOM_VK_I
1316 #define NS_VK_J nsIDOMKeyEvent::DOM_VK_J
1317 #define NS_VK_K nsIDOMKeyEvent::DOM_VK_K
1318 #define NS_VK_L nsIDOMKeyEvent::DOM_VK_L
1319 #define NS_VK_M nsIDOMKeyEvent::DOM_VK_M
1320 #define NS_VK_N nsIDOMKeyEvent::DOM_VK_N
1321 #define NS_VK_O nsIDOMKeyEvent::DOM_VK_O
1322 #define NS_VK_P nsIDOMKeyEvent::DOM_VK_P
1323 #define NS_VK_Q nsIDOMKeyEvent::DOM_VK_Q
1324 #define NS_VK_R nsIDOMKeyEvent::DOM_VK_R
1325 #define NS_VK_S nsIDOMKeyEvent::DOM_VK_S
1326 #define NS_VK_T nsIDOMKeyEvent::DOM_VK_T
1327 #define NS_VK_U nsIDOMKeyEvent::DOM_VK_U
1328 #define NS_VK_V nsIDOMKeyEvent::DOM_VK_V
1329 #define NS_VK_W nsIDOMKeyEvent::DOM_VK_W
1330 #define NS_VK_X nsIDOMKeyEvent::DOM_VK_X
1331 #define NS_VK_Y nsIDOMKeyEvent::DOM_VK_Y
1332 #define NS_VK_Z nsIDOMKeyEvent::DOM_VK_Z
1334 #define NS_VK_CONTEXT_MENU nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU
1336 #define NS_VK_NUMPAD0 nsIDOMKeyEvent::DOM_VK_NUMPAD0
1337 #define NS_VK_NUMPAD1 nsIDOMKeyEvent::DOM_VK_NUMPAD1
1338 #define NS_VK_NUMPAD2 nsIDOMKeyEvent::DOM_VK_NUMPAD2
1339 #define NS_VK_NUMPAD3 nsIDOMKeyEvent::DOM_VK_NUMPAD3
1340 #define NS_VK_NUMPAD4 nsIDOMKeyEvent::DOM_VK_NUMPAD4
1341 #define NS_VK_NUMPAD5 nsIDOMKeyEvent::DOM_VK_NUMPAD5
1342 #define NS_VK_NUMPAD6 nsIDOMKeyEvent::DOM_VK_NUMPAD6
1343 #define NS_VK_NUMPAD7 nsIDOMKeyEvent::DOM_VK_NUMPAD7
1344 #define NS_VK_NUMPAD8 nsIDOMKeyEvent::DOM_VK_NUMPAD8
1345 #define NS_VK_NUMPAD9 nsIDOMKeyEvent::DOM_VK_NUMPAD9
1346 #define NS_VK_MULTIPLY nsIDOMKeyEvent::DOM_VK_MULTIPLY
1347 #define NS_VK_ADD nsIDOMKeyEvent::DOM_VK_ADD
1348 #define NS_VK_SEPARATOR nsIDOMKeyEvent::DOM_VK_SEPARATOR
1349 #define NS_VK_SUBTRACT nsIDOMKeyEvent::DOM_VK_SUBTRACT
1350 #define NS_VK_DECIMAL nsIDOMKeyEvent::DOM_VK_DECIMAL
1351 #define NS_VK_DIVIDE nsIDOMKeyEvent::DOM_VK_DIVIDE
1352 #define NS_VK_F1 nsIDOMKeyEvent::DOM_VK_F1
1353 #define NS_VK_F2 nsIDOMKeyEvent::DOM_VK_F2
1354 #define NS_VK_F3 nsIDOMKeyEvent::DOM_VK_F3
1355 #define NS_VK_F4 nsIDOMKeyEvent::DOM_VK_F4
1356 #define NS_VK_F5 nsIDOMKeyEvent::DOM_VK_F5
1357 #define NS_VK_F6 nsIDOMKeyEvent::DOM_VK_F6
1358 #define NS_VK_F7 nsIDOMKeyEvent::DOM_VK_F7
1359 #define NS_VK_F8 nsIDOMKeyEvent::DOM_VK_F8
1360 #define NS_VK_F9 nsIDOMKeyEvent::DOM_VK_F9
1361 #define NS_VK_F10 nsIDOMKeyEvent::DOM_VK_F10
1362 #define NS_VK_F11 nsIDOMKeyEvent::DOM_VK_F11
1363 #define NS_VK_F12 nsIDOMKeyEvent::DOM_VK_F12
1364 #define NS_VK_F13 nsIDOMKeyEvent::DOM_VK_F13
1365 #define NS_VK_F14 nsIDOMKeyEvent::DOM_VK_F14
1366 #define NS_VK_F15 nsIDOMKeyEvent::DOM_VK_F15
1367 #define NS_VK_F16 nsIDOMKeyEvent::DOM_VK_F16
1368 #define NS_VK_F17 nsIDOMKeyEvent::DOM_VK_F17
1369 #define NS_VK_F18 nsIDOMKeyEvent::DOM_VK_F18
1370 #define NS_VK_F19 nsIDOMKeyEvent::DOM_VK_F19
1371 #define NS_VK_F20 nsIDOMKeyEvent::DOM_VK_F20
1372 #define NS_VK_F21 nsIDOMKeyEvent::DOM_VK_F21
1373 #define NS_VK_F22 nsIDOMKeyEvent::DOM_VK_F22
1374 #define NS_VK_F23 nsIDOMKeyEvent::DOM_VK_F23
1375 #define NS_VK_F24 nsIDOMKeyEvent::DOM_VK_F24
1377 #define NS_VK_NUM_LOCK nsIDOMKeyEvent::DOM_VK_NUM_LOCK
1378 #define NS_VK_SCROLL_LOCK nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK
1380 #define NS_VK_COMMA nsIDOMKeyEvent::DOM_VK_COMMA
1381 #define NS_VK_PERIOD nsIDOMKeyEvent::DOM_VK_PERIOD
1382 #define NS_VK_SLASH nsIDOMKeyEvent::DOM_VK_SLASH
1383 #define NS_VK_BACK_QUOTE nsIDOMKeyEvent::DOM_VK_BACK_QUOTE
1384 #define NS_VK_OPEN_BRACKET nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET
1385 #define NS_VK_BACK_SLASH nsIDOMKeyEvent::DOM_VK_BACK_SLASH
1386 #define NS_VK_CLOSE_BRACKET nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET
1387 #define NS_VK_QUOTE nsIDOMKeyEvent::DOM_VK_QUOTE
1389 #define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
1391 // IME Constants -- keep in synch with nsIPrivateTextRange.h
1392 #define NS_TEXTRANGE_CARETPOSITION 0x01
1393 #define NS_TEXTRANGE_RAWINPUT 0x02
1394 #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1395 #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1396 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1398 inline PRBool NS_TargetUnfocusedEventToLastFocusedContent(nsEvent* aEvent)
1400 #if defined(MOZ_X11) || defined(XP_MACOSX)
1401 // bug 52416 (MOZ_X11)
1402 // Lookup region (candidate window) of UNIX IME grabs
1403 // input focus from Mozilla but wants to send IME event
1404 // to redraw pre-edit (composed) string
1405 // If Mozilla does not have input focus and event is IME,
1406 // sends IME event to pre-focused element
1408 // bug 417315 (XP_MACOSX)
1409 // The commit event when the window is deactivating is sent after
1410 // the next focused widget getting the focus.
1411 // We need to send the commit event to last focused content.
1413 return NS_IS_IME_EVENT(aEvent);
1414 #elif defined(XP_WIN)
1415 // bug 292263 (XP_WIN)
1416 // If software keyboard has focus, it may send the key messages and
1417 // the IME messages to pre-focused window. Therefore, if Mozilla
1418 // doesn't have focus and event is key event or IME event, we should
1419 // send the events to pre-focused element.
1421 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) ||
1422 NS_IS_PLUGIN_EVENT(aEvent);
1423 #else
1424 return PR_FALSE;
1425 #endif
1428 #endif // nsGUIEvent_h__