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
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.
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>
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.
40 * ***** END LICENSE BLOCK ***** */
42 #ifndef nsGUIEvent_h__
43 #define nsGUIEvent_h__
49 #include "nsStringGlue.h"
52 #include "nsIDOMKeyEvent.h"
53 #include "nsIDOMDataTransfer.h"
54 #include "nsWeakPtr.h"
55 #include "nsIWidget.h"
57 #include "nsTraceRefcnt.h"
58 #include "nsITransferable.h"
59 #include "nsIVariant.h"
61 class nsIRenderingContext
;
73 #define NS_GUI_EVENT 2
74 #define NS_SIZE_EVENT 3
75 #define NS_SIZEMODE_EVENT 4
76 #define NS_ZLEVEL_EVENT 5
77 #define NS_PAINT_EVENT 6
78 #define NS_SCROLLBAR_EVENT 7
79 #define NS_INPUT_EVENT 8
80 #define NS_KEY_EVENT 9
81 #define NS_MOUSE_EVENT 10
82 #define NS_MENU_EVENT 11
83 #define NS_SCRIPT_ERROR_EVENT 12
84 #define NS_TEXT_EVENT 13
85 #define NS_COMPOSITION_EVENT 14
86 #define NS_MOUSE_SCROLL_EVENT 16
87 #define NS_SCROLLPORT_EVENT 18
88 #define NS_MUTATION_EVENT 19 // |nsMutationEvent| in content
89 #define NS_ACCESSIBLE_EVENT 20
90 #define NS_FORM_EVENT 21
91 #define NS_FOCUS_EVENT 22
92 #define NS_POPUP_EVENT 23
93 #define NS_COMMAND_EVENT 24
94 #define NS_SCROLLAREA_EVENT 25
95 #define NS_TRANSITION_EVENT 26
97 #define NS_UI_EVENT 27
99 #define NS_SVG_EVENT 30
100 #define NS_SVGZOOM_EVENT 31
103 #define NS_QUERY_CONTENT_EVENT 33
105 #define NS_MEDIA_EVENT 34
107 #define NS_DRAG_EVENT 35
108 #define NS_NOTIFYPAINT_EVENT 36
109 #define NS_SIMPLE_GESTURE_EVENT 37
110 #define NS_SELECTION_EVENT 38
111 #define NS_CONTENT_COMMAND_EVENT 39
112 #define NS_GESTURENOTIFY_EVENT 40
114 // These flags are sort of a mess. They're sort of shared between event
115 // listener flags and event flags, but only some of them. You've been
117 #define NS_EVENT_FLAG_NONE 0x0000
118 #define NS_EVENT_FLAG_TRUSTED 0x0001
119 #define NS_EVENT_FLAG_BUBBLE 0x0002
120 #define NS_EVENT_FLAG_CAPTURE 0x0004
121 #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
122 #define NS_EVENT_FLAG_NO_DEFAULT 0x0010
123 #define NS_EVENT_FLAG_CANT_CANCEL 0x0020
124 #define NS_EVENT_FLAG_CANT_BUBBLE 0x0040
125 #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
126 #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
127 #define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
128 // Event has been dispatched at least once
129 #define NS_EVENT_DISPATCHED 0x0400
130 #define NS_EVENT_FLAG_DISPATCHING 0x0800
131 // When an event is synthesized for testing, this flag will be set.
132 // Note that this is currently used only with mouse events, because this
133 // flag is not needed on other events now. It could be added to other
135 #define NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT 0x1000
137 // Use this flag if the event should be dispatched only to chrome.
138 #define NS_EVENT_FLAG_ONLY_CHROME_DISPATCH 0x2000
140 // A flag for drag&drop handling.
141 #define NS_EVENT_FLAG_NO_DEFAULT_CALLED_IN_CONTENT 0x4000
143 #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
145 #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
146 #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
148 #define NS_EVENT_TYPE_NULL 0
154 #define NS_EVENT_NULL 0
157 #define NS_WINDOW_START 100
159 // Widget is being created
160 #define NS_CREATE (NS_WINDOW_START)
161 // Widget may be destroyed
162 #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
163 // Widget is being destroyed
164 #define NS_DESTROY (NS_WINDOW_START + 2)
165 // Widget was resized
166 #define NS_SIZE (NS_WINDOW_START + 3)
167 // Widget size mode was changed
168 #define NS_SIZEMODE (NS_WINDOW_START + 4)
169 // Widget got activated
170 #define NS_ACTIVATE (NS_WINDOW_START + 7)
171 // Widget got deactivated
172 #define NS_DEACTIVATE (NS_WINDOW_START + 8)
173 // top-level window z-level change request
174 #define NS_SETZLEVEL (NS_WINDOW_START + 9)
175 // Widget will need to be painted
176 #define NS_WILL_PAINT (NS_WINDOW_START + 29)
177 // Widget needs to be repainted
178 #define NS_PAINT (NS_WINDOW_START + 30)
179 // Key is pressed within a window
180 #define NS_KEY_PRESS (NS_WINDOW_START + 31)
181 // Key is released within a window
182 #define NS_KEY_UP (NS_WINDOW_START + 32)
183 // Key is pressed within a window
184 #define NS_KEY_DOWN (NS_WINDOW_START + 33)
185 // Window has been moved to a new location.
186 // The events point contains the x, y location in screen coordinates
187 #define NS_MOVE (NS_WINDOW_START + 34)
189 // Tab control's selected tab has changed
190 #define NS_TABCHANGE (NS_WINDOW_START + 35)
192 #define NS_OS_TOOLBAR (NS_WINDOW_START + 36)
194 // Menu item selected
195 #define NS_MENU_SELECTED (NS_WINDOW_START + 38)
197 // Form control changed: currently == combo box selection changed
198 // but could be expanded to mean textbox, checkbox changed, etc.
199 // This is a GUI specific event that does not necessarily correspond
200 // directly to a mouse click or a key press.
201 #define NS_CONTROL_CHANGE (NS_WINDOW_START + 39)
203 // Indicates the display has changed depth
204 #define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
206 // Indicates a theme change has occurred
207 #define NS_THEMECHANGED (NS_WINDOW_START + 41)
209 // Indicates a System color has changed. It is the platform
210 // toolkits responsibility to invalidate the window to
211 // ensure that it is drawn using the current system colors.
212 #define NS_SYSCOLORCHANGED (NS_WINDOW_START + 42)
214 #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
215 #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
217 #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
219 #define NS_OFFLINE (NS_WINDOW_START + 63)
220 #define NS_ONLINE (NS_WINDOW_START + 64)
222 #define NS_MOUSE_MESSAGE_START 300
223 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
224 #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
225 #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
226 #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
227 #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
228 #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
229 #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
230 #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
231 #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
232 #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
234 #define NS_CONTEXTMENU_MESSAGE_START 500
235 #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
237 #define NS_SCROLLBAR_MESSAGE_START 1000
238 #define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
239 #define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
240 #define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
241 #define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
242 #define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
244 #define NS_STREAM_EVENT_START 1100
245 #define NS_LOAD (NS_STREAM_EVENT_START)
246 #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
247 #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
248 #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
249 #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
250 #define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
251 #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
252 #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
254 #define NS_FORM_EVENT_START 1200
255 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
256 #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
257 #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
258 #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
259 #define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
261 //Need separate focus/blur notifications for non-native widgets
262 #define NS_FOCUS_EVENT_START 1300
263 #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
264 #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
266 #define NS_DRAGDROP_EVENT_START 1400
267 #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
268 #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
269 #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
270 #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
271 #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
272 #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
273 #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
274 #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
275 #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
276 #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
277 #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
278 #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
281 #define NS_XUL_EVENT_START 1500
282 #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
283 #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
284 #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
285 #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
286 // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
287 #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
288 #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
292 #define NS_MOUSE_SCROLL_START 1600
293 #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
294 #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
296 #define NS_SCROLLPORT_START 1700
297 #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
298 #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
299 #define NS_SCROLLPORT_OVERFLOWCHANGED (NS_SCROLLPORT_START+2)
301 // Mutation events defined elsewhere starting at 1800
304 #define NS_ACCESSIBLE_START 1900
305 #define NS_GETACCESSIBLE (NS_ACCESSIBLE_START)
307 #define NS_USER_DEFINED_EVENT 2000
309 // composition events
310 #define NS_COMPOSITION_EVENT_START 2200
311 #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
312 #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
315 #define NS_TEXT_START 2400
316 #define NS_TEXT_TEXT (NS_TEXT_START)
319 #define NS_UI_EVENT_START 2500
320 // this is not to be confused with NS_ACTIVATE!
321 #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
322 #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
323 #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
325 // pagetransition events
326 #define NS_PAGETRANSITION_START 2700
327 #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
328 #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
332 #define NS_SVG_EVENT_START 2800
333 #define NS_SVG_LOAD (NS_SVG_EVENT_START)
334 #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
335 #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
336 #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
337 #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
338 #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
341 #define NS_SVGZOOM_EVENT_START 2900
342 #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
345 // XUL command events
346 #define NS_XULCOMMAND_EVENT_START 3000
347 #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
349 // Cut, copy, paste events
350 #define NS_CUTCOPYPASTE_EVENT_START 3100
351 #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
352 #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
353 #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
355 // Query the content information
356 #define NS_QUERY_CONTENT_EVENT_START 3200
357 // Query for the selected text information, it return the selection offset,
358 // selection length and selected text.
359 #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
360 // Query for the text content of specified range, it returns actual lengh (if
361 // the specified range is too long) and the text of the specified range.
362 // Returns the entire text if requested length > actual length.
363 #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
364 // Query for the caret rect of nth insertion point. The offset of the result is
365 // relative position from the top level widget.
366 #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
367 // Query for the bounding rect of a range of characters. This works on any
368 // valid character range given offset and length. Result is relative to top
369 // level widget coordinates
370 #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
371 // Query for the bounding rect of the current focused frame. Result is relative
372 // to top level widget coordinates
373 #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
374 // Query for the current state of the content. The particular members of
375 // mReply that are set for each query content event will be valid on success.
376 #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
377 // Query for the selection in the form of a nsITransferable.
378 #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
379 // Query for character at a point. This returns the character offset and its
380 // rect. The point is specified by nsEvent::refPoint.
381 #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
385 #define NS_MEDIA_EVENT_START 3300
386 #define NS_LOADSTART (NS_MEDIA_EVENT_START)
387 #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
388 #define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
389 #define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
390 #define NS_STALLED (NS_MEDIA_EVENT_START+4)
391 #define NS_PLAY (NS_MEDIA_EVENT_START+5)
392 #define NS_PAUSE (NS_MEDIA_EVENT_START+6)
393 #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
394 #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
395 #define NS_WAITING (NS_MEDIA_EVENT_START+9)
396 #define NS_PLAYING (NS_MEDIA_EVENT_START+10)
397 #define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
398 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
399 #define NS_SEEKING (NS_MEDIA_EVENT_START+13)
400 #define NS_SEEKED (NS_MEDIA_EVENT_START+14)
401 #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
402 #define NS_ENDED (NS_MEDIA_EVENT_START+16)
403 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
404 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
405 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
406 #define NS_MEDIA_ABORT (NS_MEDIA_EVENT_START+20)
407 #define NS_MEDIA_ERROR (NS_MEDIA_EVENT_START+21)
410 // paint notification events
411 #define NS_NOTIFYPAINT_START 3400
412 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
414 // Simple gesture events
415 #define NS_SIMPLE_GESTURE_EVENT_START 3500
416 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
417 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
418 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
419 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
420 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
421 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
422 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
423 #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
424 #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
426 // Plug-in event. This is used when a plug-in has focus and when the native
427 // event needs to be passed to the focused plug-in directly.
428 #define NS_PLUGIN_EVENT_START 3600
429 #define NS_PLUGIN_EVENT (NS_PLUGIN_EVENT_START)
431 // Events to manipulate selection (nsSelectionEvent)
432 #define NS_SELECTION_EVENT_START 3700
433 // Clear any previous selection and set the given range as the selection
434 #define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
436 // Events of commands for the contents
437 #define NS_CONTENT_COMMAND_EVENT_START 3800
438 #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
439 #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
440 #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
441 #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
442 #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
443 #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
444 #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
446 // Event to gesture notification
447 #define NS_GESTURENOTIFY_EVENT_START 3900
449 #define NS_ORIENTATION_EVENT 4000
451 #define NS_SCROLLAREA_EVENT_START 4100
452 #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
454 #define NS_TRANSITION_EVENT_START 4200
455 #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
458 * Return status for event processors, nsEventStatus, is defined in
463 * different types of (top-level) window z-level positioning
466 nsWindowZTop
= 0, // on top
467 nsWindowZBottom
, // on bottom
468 nsWindowZRelative
// just below some specified widget
478 nsEvent(PRBool isTrusted
, PRUint32 msg
, PRUint8 structType
)
479 : eventStructType(structType
),
483 flags(isTrusted
? NS_EVENT_FLAG_TRUSTED
: NS_EVENT_FLAG_NONE
),
486 MOZ_COUNT_CTOR(nsEvent
);
490 nsEvent(PRBool isTrusted
, PRUint32 msg
)
491 : eventStructType(NS_EVENT
),
495 flags(isTrusted
? NS_EVENT_FLAG_TRUSTED
: NS_EVENT_FLAG_NONE
),
498 MOZ_COUNT_CTOR(nsEvent
);
503 MOZ_COUNT_DTOR(nsEvent
);
506 // See event struct types
507 PRUint8 eventStructType
;
510 // In widget relative coordinates, not modified by layout code.
512 // Elapsed time, in milliseconds, from a platform-specific zero time
513 // to the time the message was created
515 // Flags to hold event flow stage and capture/bubble cancellation
516 // status. This is used also to indicate whether the event is trusted.
518 // Additional type info for user defined events
519 nsCOMPtr
<nsIAtom
> userType
;
520 // Event targets, needed by DOM Events
521 // Using nsISupports, not nsIDOMEventTarget because in some cases
522 // nsIDOMEventTarget is implemented as a tearoff.
523 nsCOMPtr
<nsISupports
> target
;
524 nsCOMPtr
<nsISupports
> currentTarget
;
525 nsCOMPtr
<nsISupports
> originalTarget
;
529 * General graphic user interface event
532 class nsGUIEvent
: public nsEvent
535 nsGUIEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
, PRUint8 structType
)
536 : nsEvent(isTrusted
, msg
, structType
),
537 widget(w
), pluginEvent(nsnull
)
542 nsGUIEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
543 : nsEvent(isTrusted
, msg
, NS_GUI_EVENT
),
544 widget(w
), pluginEvent(nsnull
)
548 /// Originator of the event
549 nsCOMPtr
<nsIWidget
> widget
;
551 /// Event for NPAPI plugin
559 class nsScriptErrorEvent
: public nsEvent
562 nsScriptErrorEvent(PRBool isTrusted
, PRUint32 msg
)
563 : nsEvent(isTrusted
, msg
, NS_SCRIPT_ERROR_EVENT
),
564 lineNr(0), errorMsg(nsnull
), fileName(nsnull
)
569 const PRUnichar
* errorMsg
;
570 const PRUnichar
* fileName
;
574 * Window resize event
577 class nsSizeEvent
: public nsGUIEvent
580 nsSizeEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
581 : nsGUIEvent(isTrusted
, msg
, w
, NS_SIZE_EVENT
),
582 windowSize(nsnull
), mWinWidth(0), mWinHeight(0)
586 /// x,y width, height in pixels (client area)
587 nsIntRect
*windowSize
;
588 /// width of entire window (in pixels)
590 /// height of entire window (in pixels)
595 * Window size mode event
598 class nsSizeModeEvent
: public nsGUIEvent
601 nsSizeModeEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
602 : nsGUIEvent(isTrusted
, msg
, w
, NS_SIZEMODE_EVENT
),
603 mSizeMode(nsSizeMode_Normal
)
607 nsSizeMode mSizeMode
;
611 * Window z-level event
614 class nsZLevelEvent
: public nsGUIEvent
617 nsZLevelEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
618 : nsGUIEvent(isTrusted
, msg
, w
, NS_ZLEVEL_EVENT
),
619 mPlacement(nsWindowZTop
), mReqBelow(nsnull
), mActualBelow(nsnull
),
620 mImmediate(PR_FALSE
), mAdjusted(PR_FALSE
)
624 nsWindowZ mPlacement
;
625 nsIWidget
*mReqBelow
, // widget we request being below, if any
626 *mActualBelow
; // widget to be below, returned by handler
627 PRBool mImmediate
, // handler should make changes immediately
628 mAdjusted
; // handler changed placement
632 * Window repaint event
635 class nsPaintEvent
: public nsGUIEvent
638 nsPaintEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
639 : nsGUIEvent(isTrusted
, msg
, w
, NS_PAINT_EVENT
),
640 renderingContext(nsnull
), region(nsnull
), rect(nsnull
)
644 /// Context to paint in.
645 nsIRenderingContext
*renderingContext
;
646 /// area to paint (should be used instead of rect)
648 /// x,y, width, height in pixels of area to paint
656 class nsScrollbarEvent
: public nsGUIEvent
659 nsScrollbarEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
660 : nsGUIEvent(isTrusted
, msg
, w
, NS_SCROLLBAR_EVENT
),
665 /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
669 class nsScrollPortEvent
: public nsGUIEvent
678 nsScrollPortEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
679 : nsGUIEvent(isTrusted
, msg
, w
, NS_SCROLLPORT_EVENT
),
687 class nsScrollAreaEvent
: public nsGUIEvent
690 nsScrollAreaEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
691 : nsGUIEvent(isTrusted
, msg
, w
, NS_SCROLLAREA_EVENT
)
698 class nsInputEvent
: public nsGUIEvent
701 nsInputEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
,
703 : nsGUIEvent(isTrusted
, msg
, w
, structType
),
704 isShift(PR_FALSE
), isControl(PR_FALSE
), isAlt(PR_FALSE
), isMeta(PR_FALSE
)
709 nsInputEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
710 : nsGUIEvent(isTrusted
, msg
, w
, NS_INPUT_EVENT
),
711 isShift(PR_FALSE
), isControl(PR_FALSE
), isAlt(PR_FALSE
), isMeta(PR_FALSE
)
715 /// PR_TRUE indicates the shift key is down
717 /// PR_TRUE indicates the control key is down
719 /// PR_TRUE indicates the alt key is down
721 /// PR_TRUE indicates the meta key is down (or, on Mac, the Command key)
729 class nsMouseEvent_base
: public nsInputEvent
732 nsMouseEvent_base(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
, PRUint8 type
)
733 : nsInputEvent(isTrusted
, msg
, w
, type
), button(0), pressure(0) {}
735 /// The possible related target
736 nsCOMPtr
<nsISupports
> relatedTarget
;
740 // Finger or touch pressure of event
741 // ranges between 0.0 and 1.0
745 class nsMouseEvent
: public nsMouseEvent_base
748 enum buttonType
{ eLeftButton
= 0, eMiddleButton
= 1, eRightButton
= 2 };
749 enum reasonType
{ eReal
, eSynthesized
};
750 enum contextType
{ eNormal
, eContextMenuKey
};
751 enum exitType
{ eChild
, eTopLevel
};
754 nsMouseEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
,
755 PRUint8 structType
, reasonType aReason
)
756 : nsMouseEvent_base(isTrusted
, msg
, w
, structType
),
757 acceptActivation(PR_FALSE
), ignoreRootScrollFrame(PR_FALSE
),
758 reason(aReason
), context(eNormal
), exit(eChild
), clickCount(0)
760 if (msg
== NS_MOUSE_MOVE
) {
761 flags
|= NS_EVENT_FLAG_CANT_CANCEL
;
767 nsMouseEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
,
768 reasonType aReason
, contextType aContext
= eNormal
)
769 : nsMouseEvent_base(isTrusted
, msg
, w
, NS_MOUSE_EVENT
),
770 acceptActivation(PR_FALSE
), ignoreRootScrollFrame(PR_FALSE
),
771 reason(aReason
), context(aContext
), exit(eChild
), clickCount(0)
773 if (msg
== NS_MOUSE_MOVE
) {
774 flags
|= NS_EVENT_FLAG_CANT_CANCEL
;
775 } else if (msg
== NS_CONTEXTMENU
) {
776 button
= (context
== eNormal
) ? eRightButton
: eLeftButton
;
781 NS_WARN_IF_FALSE(message
!= NS_CONTEXTMENU
||
783 ((context
== eNormal
) ? eRightButton
: eLeftButton
),
784 "Wrong button set to NS_CONTEXTMENU event?");
788 /// Special return code for MOUSE_ACTIVATE to signal
789 /// if the target accepts activation (1), or denies it (0)
790 PRPackedBool acceptActivation
;
791 // Whether the event should ignore scroll frame bounds
793 PRPackedBool ignoreRootScrollFrame
;
795 reasonType reason
: 4;
796 contextType context
: 4;
799 /// The number of mouse clicks
807 class nsDragEvent
: public nsMouseEvent
810 nsDragEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
811 : nsMouseEvent(isTrusted
, msg
, w
, NS_DRAG_EVENT
, eReal
),
812 userCancelled(PR_FALSE
)
814 if (msg
== NS_DRAGDROP_EXIT_SYNTH
||
815 msg
== NS_DRAGDROP_LEAVE_SYNTH
||
816 msg
== NS_DRAGDROP_END
) {
817 flags
|= NS_EVENT_FLAG_CANT_CANCEL
;
821 nsCOMPtr
<nsIDOMDataTransfer
> dataTransfer
;
822 PRPackedBool userCancelled
;
829 class nsAccessibleEvent
: public nsInputEvent
832 nsAccessibleEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
833 : nsInputEvent(isTrusted
, msg
, w
, NS_ACCESSIBLE_EVENT
),
838 nsIAccessible
* accessible
;
845 struct nsAlternativeCharCode
{
846 nsAlternativeCharCode(PRUint32 aUnshiftedCharCode
,
847 PRUint32 aShiftedCharCode
) :
848 mUnshiftedCharCode(aUnshiftedCharCode
), mShiftedCharCode(aShiftedCharCode
)
851 PRUint32 mUnshiftedCharCode
;
852 PRUint32 mShiftedCharCode
;
855 class nsKeyEvent
: public nsInputEvent
858 nsKeyEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
859 : nsInputEvent(isTrusted
, msg
, w
, NS_KEY_EVENT
),
860 keyCode(0), charCode(0), isChar(0)
866 /// OS translated Unicode char
868 // OS translated Unicode chars which are used for accesskey and accelkey
869 // handling. The handlers will try from first character to last character.
870 nsTArray
<nsAlternativeCharCode
> alternativeCharCodes
;
871 // indicates whether the event signifies a printable character
879 struct nsTextRangeStyle
884 LINESTYLE_DOTTED
= 2,
885 LINESTYLE_DASHED
= 3,
886 LINESTYLE_DOUBLE
= 4,
892 DEFINED_LINESTYLE
= 0x01,
893 DEFINED_FOREGROUND_COLOR
= 0x02,
894 DEFINED_BACKGROUND_COLOR
= 0x04,
895 DEFINED_UNDERLINE_COLOR
= 0x08
898 // Initialize all members, because nsTextRange instances may be compared by
907 mDefinedStyles
= DEFINED_NONE
;
908 mLineStyle
= LINESTYLE_NONE
;
909 mIsBoldLine
= PR_FALSE
;
910 mForegroundColor
= mBackgroundColor
= mUnderlineColor
= NS_RGBA(0, 0, 0, 0);
913 PRBool
IsDefined() const { return mDefinedStyles
!= DEFINED_NONE
; }
915 PRBool
IsLineStyleDefined() const
917 return (mDefinedStyles
& DEFINED_LINESTYLE
) != 0;
920 PRBool
IsForegroundColorDefined() const
922 return (mDefinedStyles
& DEFINED_FOREGROUND_COLOR
) != 0;
925 PRBool
IsBackgroundColorDefined() const
927 return (mDefinedStyles
& DEFINED_BACKGROUND_COLOR
) != 0;
930 PRBool
IsUnderlineColorDefined() const
932 return (mDefinedStyles
& DEFINED_UNDERLINE_COLOR
) != 0;
935 PRBool
IsNoChangeStyle() const
937 return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
938 IsLineStyleDefined() && mLineStyle
== LINESTYLE_NONE
;
941 PRBool
Equals(const nsTextRangeStyle
& aOther
)
943 if (mDefinedStyles
!= aOther
.mDefinedStyles
)
945 if (IsLineStyleDefined() && (mLineStyle
!= aOther
.mLineStyle
||
946 !mIsBoldLine
!= !aOther
.mIsBoldLine
))
948 if (IsForegroundColorDefined() &&
949 (mForegroundColor
!= aOther
.mForegroundColor
))
951 if (IsBackgroundColorDefined() &&
952 (mBackgroundColor
!= aOther
.mBackgroundColor
))
954 if (IsUnderlineColorDefined() &&
955 (mUnderlineColor
!= aOther
.mUnderlineColor
))
960 PRBool
operator !=(const nsTextRangeStyle
&aOther
)
962 return !Equals(aOther
);
965 PRBool
operator ==(const nsTextRangeStyle
&aOther
)
967 return Equals(aOther
);
970 PRUint8 mDefinedStyles
;
971 PRUint8 mLineStyle
; // DEFINED_LINESTYLE
973 PRPackedBool mIsBoldLine
; // DEFINED_LINESTYLE
975 nscolor mForegroundColor
; // DEFINED_FOREGROUND_COLOR
976 nscolor mBackgroundColor
; // DEFINED_BACKGROUND_COLOR
977 nscolor mUnderlineColor
; // DEFINED_UNDERLINE_COLOR
983 : mStartOffset(0), mEndOffset(0), mRangeType(0)
987 PRUint32 mStartOffset
;
991 nsTextRangeStyle mRangeStyle
;
994 typedef nsTextRange
* nsTextRangeArray
;
996 // XXX We should drop this struct because the results are provided by query
997 // content events now, so, this struct finished the role.
998 struct nsTextEventReply
1001 : mCursorIsCollapsed(PR_FALSE
), mReferenceWidget(nsnull
)
1005 nsIntRect mCursorPosition
;
1006 PRBool mCursorIsCollapsed
;
1007 nsIWidget
* mReferenceWidget
;
1010 typedef struct nsTextEventReply nsTextEventReply
;
1012 class nsTextEvent
: public nsInputEvent
1015 nsTextEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
1016 : nsInputEvent(isTrusted
, msg
, w
, NS_TEXT_EVENT
),
1017 rangeCount(0), rangeArray(nsnull
), isChar(PR_FALSE
)
1022 nsTextEventReply theReply
; // OBSOLETE
1023 PRUint32 rangeCount
;
1024 // Note that the range array may not specify a caret position; in that
1025 // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
1027 nsTextRangeArray rangeArray
;
1031 class nsCompositionEvent
: public nsInputEvent
1034 nsCompositionEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
1035 : nsInputEvent(isTrusted
, msg
, w
, NS_COMPOSITION_EVENT
)
1039 nsTextEventReply theReply
; // OBSOLETE
1042 /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
1044 * There are two common event flows:
1045 * (1) Normal line scrolling:
1046 * 1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
1047 * 2. A DOMMouseScroll event is sent into the DOM.
1048 * 3. A MozMousePixelScroll event is sent into the DOM.
1049 * 4. If neither event has been consumed, the default handling of the
1050 * NS_MOUSE_SCROLL event is executed.
1052 * (2) Pixel scrolling:
1053 * 1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
1054 * 2. A DOMMouseScroll event is sent into the DOM.
1055 * 3. No scrolling takes place in the default handler.
1056 * 4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
1057 * 5. A MozMousePixelScroll event is sent into the DOM.
1058 * 6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
1059 * NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
1060 * 7. Steps 4.-6. are repeated for every pixel scroll that belongs to
1061 * the announced line scroll. Once enough pixels have been sent to
1062 * complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
1064 * If a DOMMouseScroll event has been preventDefaulted, the associated
1065 * following MozMousePixelScroll events are still sent - they just don't result
1066 * in any scrolling (their default handler isn't executed).
1068 * How many pixel scrolls make up one line scroll is decided in the widget layer
1069 * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
1071 * This event flow model satisfies several requirements:
1072 * - DOMMouseScroll handlers don't need to be aware of the existence of pixel
1074 * - preventDefault on a DOMMouseScroll event results in no scrolling.
1075 * - DOMMouseScroll events aren't polluted with a kHasPixels flag.
1076 * - You can make use of pixel scroll DOM events (MozMousePixelScroll).
1079 class nsMouseScrollEvent
: public nsMouseEvent_base
1082 enum nsMouseScrollFlags
{
1083 kIsFullPage
= 1 << 0,
1084 kIsVertical
= 1 << 1,
1085 kIsHorizontal
= 1 << 2,
1086 kHasPixels
= 1 << 3, // Marks line scroll events that are provided as
1087 // a fallback for pixel scroll events.
1088 // These scroll events are used by things that can't
1089 // be scrolled pixel-wise, like trees. You should
1090 // ignore them when processing pixel scroll events
1091 // to avoid double-processing the same scroll gesture.
1092 // When kHasPixels is set, the event is guaranteed to
1093 // be followed up by an event that contains pixel
1094 // scrolling information.
1095 kNoLines
= 1 << 4, // Marks pixel scroll events that will not be
1096 // followed by a line scroll events. EventStateManager
1097 // will compute the appropriate height/width based on
1098 // view lineHeight and generate line scroll events
1100 kNoDefer
= 1 << 5 // For scrollable views, indicates scroll should not
1101 // occur asynchronously.
1104 nsMouseScrollEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
1105 : nsMouseEvent_base(isTrusted
, msg
, w
, NS_MOUSE_SCROLL_EVENT
),
1106 scrollFlags(0), delta(0), scrollOverflow(0)
1110 PRInt32 scrollFlags
;
1112 PRInt32 scrollOverflow
;
1116 * Gesture Notify Event:
1118 * This event is the first event generated when the user touches
1119 * the screen with a finger, and it's meant to decide what kind
1120 * of action we'll use for that touch interaction.
1122 * The event is dispatched to the layout and based on what is underneath
1123 * the initial contact point it's then decided if we should pan
1124 * (finger scrolling) or drag the target element.
1126 class nsGestureNotifyEvent
: public nsGUIEvent
1129 enum ePanDirection
{
1136 ePanDirection panDirection
;
1137 PRPackedBool displayPanFeedback
;
1139 nsGestureNotifyEvent(PRBool aIsTrusted
, PRUint32 aMsg
, nsIWidget
*aWidget
):
1140 nsGUIEvent(aIsTrusted
, aMsg
, aWidget
, NS_GESTURENOTIFY_EVENT
),
1141 panDirection(ePanNone
),
1142 displayPanFeedback(PR_FALSE
)
1147 class nsQueryContentEvent
: public nsGUIEvent
1150 nsQueryContentEvent(PRBool aIsTrusted
, PRUint32 aMsg
, nsIWidget
*aWidget
) :
1151 nsGUIEvent(aIsTrusted
, aMsg
, aWidget
, NS_QUERY_CONTENT_EVENT
),
1152 mSucceeded(PR_FALSE
)
1156 void InitForQueryTextContent(PRUint32 aOffset
, PRUint32 aLength
)
1158 NS_ASSERTION(message
== NS_QUERY_TEXT_CONTENT
,
1159 "wrong initializer is called");
1160 mInput
.mOffset
= aOffset
;
1161 mInput
.mLength
= aLength
;
1164 void InitForQueryCaretRect(PRUint32 aOffset
)
1166 NS_ASSERTION(message
== NS_QUERY_CARET_RECT
,
1167 "wrong initializer is called");
1168 mInput
.mOffset
= aOffset
;
1171 void InitForQueryTextRect(PRUint32 aOffset
, PRUint32 aLength
)
1173 NS_ASSERTION(message
== NS_QUERY_TEXT_RECT
,
1174 "wrong initializer is called");
1175 mInput
.mOffset
= aOffset
;
1176 mInput
.mLength
= aLength
;
1185 void* mContentsRoot
;
1188 nsIntRect mRect
; // Finally, the coordinates is system coordinates.
1189 // The return widget has the caret. This is set at all query events.
1190 nsIWidget
* mFocusedWidget
;
1191 PRPackedBool mReversed
; // true if selection is reversed (end < start)
1192 PRPackedBool mHasSelection
; // true if the selection exists
1193 // used by NS_QUERY_SELECTION_AS_TRANSFERABLE
1194 nsCOMPtr
<nsITransferable
> mTransferable
;
1198 NOT_FOUND
= PR_UINT32_MAX
1202 class nsFocusEvent
: public nsEvent
1205 nsFocusEvent(PRBool isTrusted
, PRUint32 msg
)
1206 : nsEvent(isTrusted
, msg
, NS_FOCUS_EVENT
),
1211 PRPackedBool fromRaise
;
1214 class nsSelectionEvent
: public nsGUIEvent
1217 nsSelectionEvent(PRBool aIsTrusted
, PRUint32 aMsg
, nsIWidget
*aWidget
) :
1218 nsGUIEvent(aIsTrusted
, aMsg
, aWidget
, NS_SELECTION_EVENT
),
1219 mSucceeded(PR_FALSE
)
1223 PRUint32 mOffset
; // start offset of selection
1224 PRUint32 mLength
; // length of selection
1225 PRPackedBool mReversed
; // selection "anchor" should be in front
1226 PRPackedBool mSucceeded
;
1229 class nsContentCommandEvent
: public nsGUIEvent
1232 nsContentCommandEvent(PRBool aIsTrusted
, PRUint32 aMsg
, nsIWidget
*aWidget
,
1233 PRBool aOnlyEnabledCheck
= PR_FALSE
) :
1234 nsGUIEvent(aIsTrusted
, aMsg
, aWidget
, NS_CONTENT_COMMAND_EVENT
),
1235 mOnlyEnabledCheck(PRPackedBool(aOnlyEnabledCheck
)),
1236 mSucceeded(PR_FALSE
), mIsEnabled(PR_FALSE
)
1240 nsCOMPtr
<nsITransferable
> mTransferable
; // [in]
1241 PRPackedBool mOnlyEnabledCheck
; // [in]
1243 PRPackedBool mSucceeded
; // [out]
1244 PRPackedBool mIsEnabled
; // [out]
1250 * When this event occurs the widget field in nsGUIEvent holds the "target"
1254 class nsMenuEvent
: public nsGUIEvent
1257 nsMenuEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
*w
)
1258 : nsGUIEvent(isTrusted
, msg
, w
, NS_MENU_EVENT
),
1259 mMenuItem(nsnull
), mCommand(0)
1263 nsIMenuItem
* mMenuItem
;
1270 * We hold the originating form control for form submit and reset events.
1271 * originator is a weak pointer (does not hold a strong reference).
1274 class nsFormEvent
: public nsEvent
1277 nsFormEvent(PRBool isTrusted
, PRUint32 msg
)
1278 : nsEvent(isTrusted
, msg
, NS_FORM_EVENT
),
1283 nsIContent
*originator
;
1289 * Custom commands for example from the operating system.
1292 class nsCommandEvent
: public nsGUIEvent
1295 nsCommandEvent(PRBool isTrusted
, nsIAtom
* aEventType
,
1296 nsIAtom
* aCommand
, nsIWidget
* w
)
1297 : nsGUIEvent(isTrusted
, NS_USER_DEFINED_EVENT
, w
, NS_COMMAND_EVENT
)
1299 userType
= aEventType
;
1303 nsCOMPtr
<nsIAtom
> command
;
1309 class nsUIEvent
: public nsEvent
1312 nsUIEvent(PRBool isTrusted
, PRUint32 msg
, PRInt32 d
)
1313 : nsEvent(isTrusted
, msg
, NS_UI_EVENT
),
1322 * Simple gesture event
1324 class nsSimpleGestureEvent
: public nsMouseEvent_base
1327 nsSimpleGestureEvent(PRBool isTrusted
, PRUint32 msg
, nsIWidget
* w
,
1328 PRUint32 directionArg
, PRFloat64 deltaArg
)
1329 : nsMouseEvent_base(isTrusted
, msg
, w
, NS_SIMPLE_GESTURE_EVENT
),
1330 direction(directionArg
), delta(deltaArg
)
1334 PRUint32 direction
; // See nsIDOMSimpleGestureEvent for values
1335 PRFloat64 delta
; // Delta for magnify and rotate events
1338 class nsTransitionEvent
: public nsEvent
1341 nsTransitionEvent(PRBool isTrusted
, PRUint32 msg
,
1342 const nsString
&propertyNameArg
, float elapsedTimeArg
)
1343 : nsEvent(isTrusted
, msg
, NS_TRANSITION_EVENT
),
1344 propertyName(propertyNameArg
), elapsedTime(elapsedTimeArg
)
1348 nsString propertyName
;
1354 * Event status for D&D Event
1356 enum nsDragDropEventStatus
{
1357 /// The event is a enter
1358 nsDragDropEventStatus_eDragEntered
,
1359 /// The event is exit
1360 nsDragDropEventStatus_eDragExited
,
1361 /// The event is drop
1362 nsDragDropEventStatus_eDrop
1366 #define NS_IS_MOUSE_EVENT(evnt) \
1367 (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1368 ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1369 ((evnt)->message == NS_MOUSE_CLICK) || \
1370 ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1371 ((evnt)->message == NS_MOUSE_ENTER) || \
1372 ((evnt)->message == NS_MOUSE_EXIT) || \
1373 ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1374 ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1375 ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1376 ((evnt)->message == NS_MOUSE_MOVE))
1378 #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1379 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1380 (evnt)->message == NS_MOUSE_CLICK && \
1381 static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1383 #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1384 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1385 (evnt)->message == NS_CONTEXTMENU && \
1386 static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1388 #define NS_IS_DRAG_EVENT(evnt) \
1389 (((evnt)->message == NS_DRAGDROP_ENTER) || \
1390 ((evnt)->message == NS_DRAGDROP_OVER) || \
1391 ((evnt)->message == NS_DRAGDROP_EXIT) || \
1392 ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1393 ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1394 ((evnt)->message == NS_DRAGDROP_DRAG) || \
1395 ((evnt)->message == NS_DRAGDROP_END) || \
1396 ((evnt)->message == NS_DRAGDROP_START) || \
1397 ((evnt)->message == NS_DRAGDROP_DROP) || \
1398 ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1400 #define NS_IS_KEY_EVENT(evnt) \
1401 (((evnt)->message == NS_KEY_DOWN) || \
1402 ((evnt)->message == NS_KEY_PRESS) || \
1403 ((evnt)->message == NS_KEY_UP))
1405 #define NS_IS_IME_EVENT(evnt) \
1406 (((evnt)->message == NS_TEXT_TEXT) || \
1407 ((evnt)->message == NS_COMPOSITION_START) || \
1408 ((evnt)->message == NS_COMPOSITION_END))
1410 #define NS_IS_ACTIVATION_EVENT(evnt) \
1411 (((evnt)->message == NS_ACTIVATE) || \
1412 ((evnt)->message == NS_DEACTIVATE) || \
1413 ((evnt)->message == NS_PLUGIN_ACTIVATE))
1415 #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1416 (((evnt)->message == NS_QUERY_SELECTED_TEXT) || \
1417 ((evnt)->message == NS_QUERY_TEXT_CONTENT) || \
1418 ((evnt)->message == NS_QUERY_CARET_RECT) || \
1419 ((evnt)->message == NS_QUERY_TEXT_RECT) || \
1420 ((evnt)->message == NS_QUERY_EDITOR_RECT) || \
1421 ((evnt)->message == NS_QUERY_CONTENT_STATE) || \
1422 ((evnt)->message == NS_QUERY_SELECTION_AS_TRANSFERABLE) || \
1423 ((evnt)->message == NS_QUERY_CHARACTER_AT_POINT))
1425 #define NS_IS_SELECTION_EVENT(evnt) \
1426 (((evnt)->message == NS_SELECTION_SET))
1428 #define NS_IS_CONTENT_COMMAND_EVENT(evnt) \
1429 (((evnt)->message == NS_CONTENT_COMMAND_CUT) || \
1430 ((evnt)->message == NS_CONTENT_COMMAND_COPY) || \
1431 ((evnt)->message == NS_CONTENT_COMMAND_PASTE) || \
1432 ((evnt)->message == NS_CONTENT_COMMAND_DELETE) || \
1433 ((evnt)->message == NS_CONTENT_COMMAND_UNDO) || \
1434 ((evnt)->message == NS_CONTENT_COMMAND_REDO))
1436 #define NS_IS_PLUGIN_EVENT(evnt) \
1437 (((evnt)->message == NS_PLUGIN_EVENT))
1439 #define NS_IS_TRUSTED_EVENT(event) \
1440 (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1442 // Mark an event as being dispatching.
1443 #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1444 (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1446 #define NS_IS_EVENT_IN_DISPATCH(event) \
1447 (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1449 // Mark an event as being done dispatching.
1450 #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1451 NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1452 "Event never got marked for dispatch!"); \
1453 (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1454 (event)->flags |= NS_EVENT_DISPATCHED;
1456 // Be aware the query content events and the selection events are a part of IME
1457 // processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
1458 // cases, you should use NS_IS_IME_RELATED_EVENT instead.
1459 #define NS_IS_IME_RELATED_EVENT(evnt) \
1460 (NS_IS_IME_EVENT(evnt) || \
1461 NS_IS_QUERY_CONTENT_EVENT(evnt) || \
1462 NS_IS_SELECTION_EVENT(evnt))
1465 * Virtual key bindings for keyboard events.
1466 * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1467 * Really, it would be better if we phased out the NS_VK symbols altogether
1468 * in favor of the DOM ones, but at least this way they'll be in sync.
1471 #define NS_VK_CANCEL nsIDOMKeyEvent::DOM_VK_CANCEL
1472 #define NS_VK_HELP nsIDOMKeyEvent::DOM_VK_HELP
1473 #define NS_VK_BACK nsIDOMKeyEvent::DOM_VK_BACK_SPACE
1474 #define NS_VK_TAB nsIDOMKeyEvent::DOM_VK_TAB
1475 #define NS_VK_CLEAR nsIDOMKeyEvent::DOM_VK_CLEAR
1476 #define NS_VK_RETURN nsIDOMKeyEvent::DOM_VK_RETURN
1477 #define NS_VK_ENTER nsIDOMKeyEvent::DOM_VK_ENTER
1478 #define NS_VK_SHIFT nsIDOMKeyEvent::DOM_VK_SHIFT
1479 #define NS_VK_CONTROL nsIDOMKeyEvent::DOM_VK_CONTROL
1480 #define NS_VK_ALT nsIDOMKeyEvent::DOM_VK_ALT
1481 #define NS_VK_PAUSE nsIDOMKeyEvent::DOM_VK_PAUSE
1482 #define NS_VK_CAPS_LOCK nsIDOMKeyEvent::DOM_VK_CAPS_LOCK
1483 #define NS_VK_ESCAPE nsIDOMKeyEvent::DOM_VK_ESCAPE
1484 #define NS_VK_SPACE nsIDOMKeyEvent::DOM_VK_SPACE
1485 #define NS_VK_PAGE_UP nsIDOMKeyEvent::DOM_VK_PAGE_UP
1486 #define NS_VK_PAGE_DOWN nsIDOMKeyEvent::DOM_VK_PAGE_DOWN
1487 #define NS_VK_END nsIDOMKeyEvent::DOM_VK_END
1488 #define NS_VK_HOME nsIDOMKeyEvent::DOM_VK_HOME
1489 #define NS_VK_LEFT nsIDOMKeyEvent::DOM_VK_LEFT
1490 #define NS_VK_UP nsIDOMKeyEvent::DOM_VK_UP
1491 #define NS_VK_RIGHT nsIDOMKeyEvent::DOM_VK_RIGHT
1492 #define NS_VK_DOWN nsIDOMKeyEvent::DOM_VK_DOWN
1493 #define NS_VK_PRINTSCREEN nsIDOMKeyEvent::DOM_VK_PRINTSCREEN
1494 #define NS_VK_INSERT nsIDOMKeyEvent::DOM_VK_INSERT
1495 #define NS_VK_DELETE nsIDOMKeyEvent::DOM_VK_DELETE
1497 // NS_VK_0 - NS_VK_9 match their ascii values
1498 #define NS_VK_0 nsIDOMKeyEvent::DOM_VK_0
1499 #define NS_VK_1 nsIDOMKeyEvent::DOM_VK_1
1500 #define NS_VK_2 nsIDOMKeyEvent::DOM_VK_2
1501 #define NS_VK_3 nsIDOMKeyEvent::DOM_VK_3
1502 #define NS_VK_4 nsIDOMKeyEvent::DOM_VK_4
1503 #define NS_VK_5 nsIDOMKeyEvent::DOM_VK_5
1504 #define NS_VK_6 nsIDOMKeyEvent::DOM_VK_6
1505 #define NS_VK_7 nsIDOMKeyEvent::DOM_VK_7
1506 #define NS_VK_8 nsIDOMKeyEvent::DOM_VK_8
1507 #define NS_VK_9 nsIDOMKeyEvent::DOM_VK_9
1509 #define NS_VK_SEMICOLON nsIDOMKeyEvent::DOM_VK_SEMICOLON
1510 #define NS_VK_EQUALS nsIDOMKeyEvent::DOM_VK_EQUALS
1512 // NS_VK_A - NS_VK_Z match their ascii values
1513 #define NS_VK_A nsIDOMKeyEvent::DOM_VK_A
1514 #define NS_VK_B nsIDOMKeyEvent::DOM_VK_B
1515 #define NS_VK_C nsIDOMKeyEvent::DOM_VK_C
1516 #define NS_VK_D nsIDOMKeyEvent::DOM_VK_D
1517 #define NS_VK_E nsIDOMKeyEvent::DOM_VK_E
1518 #define NS_VK_F nsIDOMKeyEvent::DOM_VK_F
1519 #define NS_VK_G nsIDOMKeyEvent::DOM_VK_G
1520 #define NS_VK_H nsIDOMKeyEvent::DOM_VK_H
1521 #define NS_VK_I nsIDOMKeyEvent::DOM_VK_I
1522 #define NS_VK_J nsIDOMKeyEvent::DOM_VK_J
1523 #define NS_VK_K nsIDOMKeyEvent::DOM_VK_K
1524 #define NS_VK_L nsIDOMKeyEvent::DOM_VK_L
1525 #define NS_VK_M nsIDOMKeyEvent::DOM_VK_M
1526 #define NS_VK_N nsIDOMKeyEvent::DOM_VK_N
1527 #define NS_VK_O nsIDOMKeyEvent::DOM_VK_O
1528 #define NS_VK_P nsIDOMKeyEvent::DOM_VK_P
1529 #define NS_VK_Q nsIDOMKeyEvent::DOM_VK_Q
1530 #define NS_VK_R nsIDOMKeyEvent::DOM_VK_R
1531 #define NS_VK_S nsIDOMKeyEvent::DOM_VK_S
1532 #define NS_VK_T nsIDOMKeyEvent::DOM_VK_T
1533 #define NS_VK_U nsIDOMKeyEvent::DOM_VK_U
1534 #define NS_VK_V nsIDOMKeyEvent::DOM_VK_V
1535 #define NS_VK_W nsIDOMKeyEvent::DOM_VK_W
1536 #define NS_VK_X nsIDOMKeyEvent::DOM_VK_X
1537 #define NS_VK_Y nsIDOMKeyEvent::DOM_VK_Y
1538 #define NS_VK_Z nsIDOMKeyEvent::DOM_VK_Z
1540 #define NS_VK_CONTEXT_MENU nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU
1542 #define NS_VK_NUMPAD0 nsIDOMKeyEvent::DOM_VK_NUMPAD0
1543 #define NS_VK_NUMPAD1 nsIDOMKeyEvent::DOM_VK_NUMPAD1
1544 #define NS_VK_NUMPAD2 nsIDOMKeyEvent::DOM_VK_NUMPAD2
1545 #define NS_VK_NUMPAD3 nsIDOMKeyEvent::DOM_VK_NUMPAD3
1546 #define NS_VK_NUMPAD4 nsIDOMKeyEvent::DOM_VK_NUMPAD4
1547 #define NS_VK_NUMPAD5 nsIDOMKeyEvent::DOM_VK_NUMPAD5
1548 #define NS_VK_NUMPAD6 nsIDOMKeyEvent::DOM_VK_NUMPAD6
1549 #define NS_VK_NUMPAD7 nsIDOMKeyEvent::DOM_VK_NUMPAD7
1550 #define NS_VK_NUMPAD8 nsIDOMKeyEvent::DOM_VK_NUMPAD8
1551 #define NS_VK_NUMPAD9 nsIDOMKeyEvent::DOM_VK_NUMPAD9
1552 #define NS_VK_MULTIPLY nsIDOMKeyEvent::DOM_VK_MULTIPLY
1553 #define NS_VK_ADD nsIDOMKeyEvent::DOM_VK_ADD
1554 #define NS_VK_SEPARATOR nsIDOMKeyEvent::DOM_VK_SEPARATOR
1555 #define NS_VK_SUBTRACT nsIDOMKeyEvent::DOM_VK_SUBTRACT
1556 #define NS_VK_DECIMAL nsIDOMKeyEvent::DOM_VK_DECIMAL
1557 #define NS_VK_DIVIDE nsIDOMKeyEvent::DOM_VK_DIVIDE
1558 #define NS_VK_F1 nsIDOMKeyEvent::DOM_VK_F1
1559 #define NS_VK_F2 nsIDOMKeyEvent::DOM_VK_F2
1560 #define NS_VK_F3 nsIDOMKeyEvent::DOM_VK_F3
1561 #define NS_VK_F4 nsIDOMKeyEvent::DOM_VK_F4
1562 #define NS_VK_F5 nsIDOMKeyEvent::DOM_VK_F5
1563 #define NS_VK_F6 nsIDOMKeyEvent::DOM_VK_F6
1564 #define NS_VK_F7 nsIDOMKeyEvent::DOM_VK_F7
1565 #define NS_VK_F8 nsIDOMKeyEvent::DOM_VK_F8
1566 #define NS_VK_F9 nsIDOMKeyEvent::DOM_VK_F9
1567 #define NS_VK_F10 nsIDOMKeyEvent::DOM_VK_F10
1568 #define NS_VK_F11 nsIDOMKeyEvent::DOM_VK_F11
1569 #define NS_VK_F12 nsIDOMKeyEvent::DOM_VK_F12
1570 #define NS_VK_F13 nsIDOMKeyEvent::DOM_VK_F13
1571 #define NS_VK_F14 nsIDOMKeyEvent::DOM_VK_F14
1572 #define NS_VK_F15 nsIDOMKeyEvent::DOM_VK_F15
1573 #define NS_VK_F16 nsIDOMKeyEvent::DOM_VK_F16
1574 #define NS_VK_F17 nsIDOMKeyEvent::DOM_VK_F17
1575 #define NS_VK_F18 nsIDOMKeyEvent::DOM_VK_F18
1576 #define NS_VK_F19 nsIDOMKeyEvent::DOM_VK_F19
1577 #define NS_VK_F20 nsIDOMKeyEvent::DOM_VK_F20
1578 #define NS_VK_F21 nsIDOMKeyEvent::DOM_VK_F21
1579 #define NS_VK_F22 nsIDOMKeyEvent::DOM_VK_F22
1580 #define NS_VK_F23 nsIDOMKeyEvent::DOM_VK_F23
1581 #define NS_VK_F24 nsIDOMKeyEvent::DOM_VK_F24
1583 #define NS_VK_NUM_LOCK nsIDOMKeyEvent::DOM_VK_NUM_LOCK
1584 #define NS_VK_SCROLL_LOCK nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK
1586 #define NS_VK_COMMA nsIDOMKeyEvent::DOM_VK_COMMA
1587 #define NS_VK_PERIOD nsIDOMKeyEvent::DOM_VK_PERIOD
1588 #define NS_VK_SLASH nsIDOMKeyEvent::DOM_VK_SLASH
1589 #define NS_VK_BACK_QUOTE nsIDOMKeyEvent::DOM_VK_BACK_QUOTE
1590 #define NS_VK_OPEN_BRACKET nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET
1591 #define NS_VK_BACK_SLASH nsIDOMKeyEvent::DOM_VK_BACK_SLASH
1592 #define NS_VK_CLOSE_BRACKET nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET
1593 #define NS_VK_QUOTE nsIDOMKeyEvent::DOM_VK_QUOTE
1595 #define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
1597 // IME Constants -- keep in synch with nsIPrivateTextRange.h
1598 #define NS_TEXTRANGE_CARETPOSITION 0x01
1599 #define NS_TEXTRANGE_RAWINPUT 0x02
1600 #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1601 #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1602 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1604 inline PRBool
NS_TargetUnfocusedEventToLastFocusedContent(nsEvent
* aEvent
)
1606 #if defined(MOZ_X11) || defined(XP_MACOSX)
1607 // bug 52416 (MOZ_X11)
1608 // Lookup region (candidate window) of UNIX IME grabs
1609 // input focus from Mozilla but wants to send IME event
1610 // to redraw pre-edit (composed) string
1611 // If Mozilla does not have input focus and event is IME,
1612 // sends IME event to pre-focused element
1614 // bug 417315 (XP_MACOSX)
1615 // The commit event when the window is deactivating is sent after
1616 // the next focused widget getting the focus.
1617 // We need to send the commit event to last focused content.
1619 return NS_IS_IME_RELATED_EVENT(aEvent
);
1620 #elif defined(XP_WIN)
1621 // bug 292263 (XP_WIN)
1622 // If software keyboard has focus, it may send the key messages and
1623 // the IME messages to pre-focused window. Therefore, if Mozilla
1624 // doesn't have focus and event is key event or IME event, we should
1625 // send the events to pre-focused element.
1627 return NS_IS_KEY_EVENT(aEvent
) || NS_IS_IME_RELATED_EVENT(aEvent
) ||
1628 NS_IS_PLUGIN_EVENT(aEvent
) || NS_IS_CONTENT_COMMAND_EVENT(aEvent
);
1635 * Whether the event should be handled by the frame of the mouse cursor
1636 * position or not. When it should be handled there (e.g., the mouse events),
1637 * this returns TRUE.
1639 inline PRBool
NS_IsEventUsingCoordinates(nsEvent
* aEvent
)
1641 return !NS_IS_KEY_EVENT(aEvent
) && !NS_IS_IME_RELATED_EVENT(aEvent
) &&
1642 !NS_IS_CONTEXT_MENU_KEY(aEvent
) && !NS_IS_ACTIVATION_EVENT(aEvent
) &&
1643 !NS_IS_PLUGIN_EVENT(aEvent
) && !NS_IS_CONTENT_COMMAND_EVENT(aEvent
) &&
1644 aEvent
->eventStructType
!= NS_ACCESSIBLE_EVENT
;
1648 * Whether the event should be handled by the focused DOM window in the
1649 * same top level window's or not. E.g., key events, IME related events
1650 * (including the query content events, they are used in IME transaction)
1651 * should be handled by the (last) focused window rather than the dispatched
1654 * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
1655 * application level active DOM window which is on another top level window.
1656 * So, when the event is fired on a deactive window, the event is going to be
1657 * handled by the last focused DOM window in the last focused window.
1659 inline PRBool
NS_IsEventTargetedAtFocusedWindow(nsEvent
* aEvent
)
1661 return NS_IS_KEY_EVENT(aEvent
) || NS_IS_IME_RELATED_EVENT(aEvent
) ||
1662 NS_IS_CONTEXT_MENU_KEY(aEvent
) || NS_IS_CONTENT_COMMAND_EVENT(aEvent
);
1665 #endif // nsGUIEvent_h__