CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / public / nsGUIEvent.h
blobfe245c0218b414d54e203942137263841979bd7c
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)
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__
45 #include "nsPoint.h"
46 #include "nsRect.h"
47 #include "nsRegion.h"
48 #include "nsEvent.h"
49 #include "nsStringGlue.h"
50 #include "nsCOMPtr.h"
51 #include "nsIAtom.h"
52 #include "nsIDOMKeyEvent.h"
53 #include "nsIDOMNSMouseEvent.h"
54 #include "nsIDOMDataTransfer.h"
55 #include "nsPIDOMEventTarget.h"
56 #include "nsWeakPtr.h"
57 #include "nsIWidget.h"
58 #include "nsTArray.h"
59 #include "nsTraceRefcnt.h"
60 #include "nsITransferable.h"
61 #include "nsIVariant.h"
63 #ifdef MOZ_IPC
64 namespace mozilla {
65 namespace dom {
66 class PBrowserParent;
67 class PBrowserChild;
70 #endif // MOZ_IPC
72 #ifdef ACCESSIBILITY
73 class nsAccessible;
74 #endif
75 class nsIRenderingContext;
76 class nsIMenuItem;
77 class nsIContent;
78 class nsIURI;
79 class nsHashKey;
81 /**
82 * Event Struct Types
84 #define NS_EVENT 1
85 #define NS_GUI_EVENT 2
86 #define NS_SIZE_EVENT 3
87 #define NS_SIZEMODE_EVENT 4
88 #define NS_ZLEVEL_EVENT 5
89 #define NS_PAINT_EVENT 6
90 #define NS_SCROLLBAR_EVENT 7
91 #define NS_INPUT_EVENT 8
92 #define NS_KEY_EVENT 9
93 #define NS_MOUSE_EVENT 10
94 #define NS_SCRIPT_ERROR_EVENT 12
95 #define NS_TEXT_EVENT 13
96 #define NS_COMPOSITION_EVENT 14
97 #define NS_MOUSE_SCROLL_EVENT 16
98 #define NS_SCROLLPORT_EVENT 18
99 #define NS_MUTATION_EVENT 19 // |nsMutationEvent| in content
100 #define NS_ACCESSIBLE_EVENT 20
101 #define NS_FORM_EVENT 21
102 #define NS_FOCUS_EVENT 22
103 #define NS_POPUP_EVENT 23
104 #define NS_COMMAND_EVENT 24
105 #define NS_SCROLLAREA_EVENT 25
106 #define NS_TRANSITION_EVENT 26
108 #define NS_UI_EVENT 27
109 #ifdef MOZ_SVG
110 #define NS_SVG_EVENT 30
111 #define NS_SVGZOOM_EVENT 31
112 #endif // MOZ_SVG
113 #ifdef MOZ_SMIL
114 #define NS_SMIL_TIME_EVENT 32
115 #endif // MOZ_SMIL
117 #define NS_QUERY_CONTENT_EVENT 33
119 #define NS_DRAG_EVENT 35
120 #define NS_NOTIFYPAINT_EVENT 36
121 #define NS_SIMPLE_GESTURE_EVENT 37
122 #define NS_SELECTION_EVENT 38
123 #define NS_CONTENT_COMMAND_EVENT 39
124 #define NS_GESTURENOTIFY_EVENT 40
125 #define NS_UISTATECHANGE_EVENT 41
126 #define NS_MOZTOUCH_EVENT 42
128 // These flags are sort of a mess. They're sort of shared between event
129 // listener flags and event flags, but only some of them. You've been
130 // warned!
131 #define NS_EVENT_FLAG_NONE 0x0000
132 #define NS_EVENT_FLAG_TRUSTED 0x0001
133 #define NS_EVENT_FLAG_BUBBLE 0x0002
134 #define NS_EVENT_FLAG_CAPTURE 0x0004
135 #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
136 #define NS_EVENT_FLAG_NO_DEFAULT 0x0010
137 #define NS_EVENT_FLAG_CANT_CANCEL 0x0020
138 #define NS_EVENT_FLAG_CANT_BUBBLE 0x0040
139 #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
140 #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
141 #define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
142 // Event has been dispatched at least once
143 #define NS_EVENT_DISPATCHED 0x0400
144 #define NS_EVENT_FLAG_DISPATCHING 0x0800
145 // When an event is synthesized for testing, this flag will be set.
146 // Note that this is currently used only with mouse events, because this
147 // flag is not needed on other events now. It could be added to other
148 // events.
149 #define NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT 0x1000
151 // Use this flag if the event should be dispatched only to chrome.
152 #define NS_EVENT_FLAG_ONLY_CHROME_DISPATCH 0x2000
154 // A flag for drag&drop handling.
155 #define NS_EVENT_FLAG_NO_DEFAULT_CALLED_IN_CONTENT 0x4000
157 #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
159 #define NS_EVENT_FLAG_EXCEPTION_THROWN 0x10000
161 #define NS_EVENT_FLAG_PREVENT_ANCHOR_ACTIONS 0x20000
163 #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
164 #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
166 #define NS_EVENT_TYPE_NULL 0
169 * GUI MESSAGES
171 //@{
172 #define NS_EVENT_NULL 0
175 #define NS_WINDOW_START 100
177 // Widget is being created
178 #define NS_CREATE (NS_WINDOW_START)
179 // Widget may be destroyed
180 #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
181 // Widget is being destroyed
182 #define NS_DESTROY (NS_WINDOW_START + 2)
183 // Widget was resized
184 #define NS_SIZE (NS_WINDOW_START + 3)
185 // Widget size mode was changed
186 #define NS_SIZEMODE (NS_WINDOW_START + 4)
187 // Widget got activated
188 #define NS_ACTIVATE (NS_WINDOW_START + 7)
189 // Widget got deactivated
190 #define NS_DEACTIVATE (NS_WINDOW_START + 8)
191 // top-level window z-level change request
192 #define NS_SETZLEVEL (NS_WINDOW_START + 9)
193 // Widget was repainted (dispatched when it's safe to move widgets, but
194 // only on some platforms (including GTK2 and Windows))
195 #define NS_DID_PAINT (NS_WINDOW_START + 28)
196 // Widget will need to be painted
197 #define NS_WILL_PAINT (NS_WINDOW_START + 29)
198 // Widget needs to be repainted
199 #define NS_PAINT (NS_WINDOW_START + 30)
200 // Key is pressed within a window
201 #define NS_KEY_PRESS (NS_WINDOW_START + 31)
202 // Key is released within a window
203 #define NS_KEY_UP (NS_WINDOW_START + 32)
204 // Key is pressed within a window
205 #define NS_KEY_DOWN (NS_WINDOW_START + 33)
206 // Window has been moved to a new location.
207 // The events point contains the x, y location in screen coordinates
208 #define NS_MOVE (NS_WINDOW_START + 34)
210 // Tab control's selected tab has changed
211 #define NS_TABCHANGE (NS_WINDOW_START + 35)
213 #define NS_OS_TOOLBAR (NS_WINDOW_START + 36)
215 // Indicates the display has changed depth
216 #define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
218 // Indicates a theme change has occurred
219 #define NS_THEMECHANGED (NS_WINDOW_START + 41)
221 // Indicates a System color has changed. It is the platform
222 // toolkits responsibility to invalidate the window to
223 // ensure that it is drawn using the current system colors.
224 #define NS_SYSCOLORCHANGED (NS_WINDOW_START + 42)
226 // Indicates that the ui state such as whether to show focus or
227 // keyboard accelerator indicators has changed.
228 #define NS_UISTATECHANGED (NS_WINDOW_START + 43)
230 #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
231 #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
233 // A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be
234 // used when the window is not active. NS_PLUGIN_FOCUS should be used when
235 // the window is active. In the latter case, the dispatcher of the event
236 // is expected to ensure that the plugin's widget is focused beforehand.
237 #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
238 #define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63)
240 #define NS_OFFLINE (NS_WINDOW_START + 64)
241 #define NS_ONLINE (NS_WINDOW_START + 65)
243 // Indicates a resize will occur
244 #define NS_BEFORERESIZE_EVENT (NS_WINDOW_START + 66)
246 #define NS_MOUSE_MESSAGE_START 300
247 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
248 #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
249 #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
250 #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
251 #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
252 #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
253 #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
254 #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
255 #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
256 #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
257 #define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
259 #define NS_CONTEXTMENU_MESSAGE_START 500
260 #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
262 #define NS_SCROLLBAR_MESSAGE_START 1000
263 #define NS_SCROLLBAR_POS (NS_SCROLLBAR_MESSAGE_START)
264 #define NS_SCROLLBAR_PAGE_NEXT (NS_SCROLLBAR_MESSAGE_START + 1)
265 #define NS_SCROLLBAR_PAGE_PREV (NS_SCROLLBAR_MESSAGE_START + 2)
266 #define NS_SCROLLBAR_LINE_NEXT (NS_SCROLLBAR_MESSAGE_START + 3)
267 #define NS_SCROLLBAR_LINE_PREV (NS_SCROLLBAR_MESSAGE_START + 4)
269 #define NS_STREAM_EVENT_START 1100
270 #define NS_LOAD (NS_STREAM_EVENT_START)
271 #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
272 #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
273 #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
274 #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
275 #define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
276 #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
277 #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
278 #define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8)
280 #define NS_FORM_EVENT_START 1200
281 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
282 #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
283 #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
284 #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
285 #define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
286 #define NS_FORM_INVALID (NS_FORM_EVENT_START + 5)
288 //Need separate focus/blur notifications for non-native widgets
289 #define NS_FOCUS_EVENT_START 1300
290 #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
291 #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
293 #define NS_DRAGDROP_EVENT_START 1400
294 #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
295 #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
296 #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
297 #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
298 #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
299 #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
300 #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
301 #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
302 #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
303 #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
304 #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
305 #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
307 // Events for popups
308 #define NS_XUL_EVENT_START 1500
309 #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
310 #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
311 #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
312 #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
313 // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
314 #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
315 #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
316 //@}
318 // Scroll events
319 #define NS_MOUSE_SCROLL_START 1600
320 #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
321 #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
323 #define NS_SCROLLPORT_START 1700
324 #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
325 #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
326 #define NS_SCROLLPORT_OVERFLOWCHANGED (NS_SCROLLPORT_START+2)
328 // Mutation events defined elsewhere starting at 1800
330 // accessible events
331 #define NS_ACCESSIBLE_START 1900
332 #define NS_GETACCESSIBLE (NS_ACCESSIBLE_START)
334 #define NS_USER_DEFINED_EVENT 2000
336 // composition events
337 #define NS_COMPOSITION_EVENT_START 2200
338 #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
339 #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
341 // text events
342 #define NS_TEXT_START 2400
343 #define NS_TEXT_TEXT (NS_TEXT_START)
345 // UI events
346 #define NS_UI_EVENT_START 2500
347 // this is not to be confused with NS_ACTIVATE!
348 #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
349 #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
350 #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
352 // pagetransition events
353 #define NS_PAGETRANSITION_START 2700
354 #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
355 #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
357 #ifdef MOZ_SVG
358 // SVG events
359 #define NS_SVG_EVENT_START 2800
360 #define NS_SVG_LOAD (NS_SVG_EVENT_START)
361 #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
362 #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
363 #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
364 #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
365 #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
367 // SVG Zoom events
368 #define NS_SVGZOOM_EVENT_START 2900
369 #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
370 #endif // MOZ_SVG
372 // XUL command events
373 #define NS_XULCOMMAND_EVENT_START 3000
374 #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
376 // Cut, copy, paste events
377 #define NS_CUTCOPYPASTE_EVENT_START 3100
378 #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
379 #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
380 #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
382 // Query the content information
383 #define NS_QUERY_CONTENT_EVENT_START 3200
384 // Query for the selected text information, it return the selection offset,
385 // selection length and selected text.
386 #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
387 // Query for the text content of specified range, it returns actual lengh (if
388 // the specified range is too long) and the text of the specified range.
389 // Returns the entire text if requested length > actual length.
390 #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
391 // Query for the caret rect of nth insertion point. The offset of the result is
392 // relative position from the top level widget.
393 #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
394 // Query for the bounding rect of a range of characters. This works on any
395 // valid character range given offset and length. Result is relative to top
396 // level widget coordinates
397 #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
398 // Query for the bounding rect of the current focused frame. Result is relative
399 // to top level widget coordinates
400 #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
401 // Query for the current state of the content. The particular members of
402 // mReply that are set for each query content event will be valid on success.
403 #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
404 // Query for the selection in the form of a nsITransferable.
405 #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
406 // Query for character at a point. This returns the character offset and its
407 // rect. The point is specified by nsEvent::refPoint.
408 #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
410 // Video events
411 #ifdef MOZ_MEDIA
412 #define NS_MEDIA_EVENT_START 3300
413 #define NS_LOADSTART (NS_MEDIA_EVENT_START)
414 #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
415 #define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
416 #define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
417 #define NS_STALLED (NS_MEDIA_EVENT_START+4)
418 #define NS_PLAY (NS_MEDIA_EVENT_START+5)
419 #define NS_PAUSE (NS_MEDIA_EVENT_START+6)
420 #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
421 #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
422 #define NS_WAITING (NS_MEDIA_EVENT_START+9)
423 #define NS_PLAYING (NS_MEDIA_EVENT_START+10)
424 #define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
425 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
426 #define NS_SEEKING (NS_MEDIA_EVENT_START+13)
427 #define NS_SEEKED (NS_MEDIA_EVENT_START+14)
428 #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
429 #define NS_ENDED (NS_MEDIA_EVENT_START+16)
430 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
431 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
432 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
433 #define NS_MOZAUDIOAVAILABLE (NS_MEDIA_EVENT_START+20)
434 #endif // MOZ_MEDIA
436 // paint notification events
437 #define NS_NOTIFYPAINT_START 3400
438 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
439 #define NS_BEFOREPAINT (NS_NOTIFYPAINT_START+1)
441 // Simple gesture events
442 #define NS_SIMPLE_GESTURE_EVENT_START 3500
443 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
444 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
445 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
446 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
447 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
448 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
449 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
450 #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
451 #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
453 // These are used to send events to plugins.
454 #define NS_PLUGIN_EVENT_START 3600
455 #define NS_PLUGIN_EVENT (NS_PLUGIN_EVENT_START)
456 #define NS_NON_RETARGETED_PLUGIN_EVENT (NS_PLUGIN_EVENT_START+1)
458 // Events to manipulate selection (nsSelectionEvent)
459 #define NS_SELECTION_EVENT_START 3700
460 // Clear any previous selection and set the given range as the selection
461 #define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
463 // Events of commands for the contents
464 #define NS_CONTENT_COMMAND_EVENT_START 3800
465 #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
466 #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
467 #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
468 #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
469 #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
470 #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
471 #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
472 // NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the
473 // currently focused content or latest DOM selection. This would normally be
474 // the same element scrolled by keyboard scroll commands, except that this event
475 // will scroll an element scrollable in either direction. I.e., if the nearest
476 // scrollable ancestor element can only be scrolled vertically, and horizontal
477 // scrolling is requested using this event, no scrolling will occur.
478 #define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7)
480 // Event to gesture notification
481 #define NS_GESTURENOTIFY_EVENT_START 3900
483 #define NS_ORIENTATION_EVENT 4000
485 #define NS_SCROLLAREA_EVENT_START 4100
486 #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
488 #define NS_TRANSITION_EVENT_START 4200
489 #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
491 #ifdef MOZ_SMIL
492 #define NS_SMIL_TIME_EVENT_START 4300
493 #define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START)
494 #define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1)
495 #define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
496 #endif // MOZ_SMIL
498 #define NS_MOZTOUCH_EVENT_START 4400
499 #define NS_MOZTOUCH_DOWN (NS_MOZTOUCH_EVENT_START)
500 #define NS_MOZTOUCH_MOVE (NS_MOZTOUCH_EVENT_START+1)
501 #define NS_MOZTOUCH_UP (NS_MOZTOUCH_EVENT_START+2)
503 // script notification events
504 #define NS_NOTIFYSCRIPT_START 4500
505 #define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
506 #define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1)
509 * Return status for event processors, nsEventStatus, is defined in
510 * nsEvent.h.
514 * different types of (top-level) window z-level positioning
516 enum nsWindowZ {
517 nsWindowZTop = 0, // on top
518 nsWindowZBottom, // on bottom
519 nsWindowZRelative // just below some specified widget
523 * General event
526 class nsEvent
528 protected:
529 nsEvent(PRBool isTrusted, PRUint32 msg, PRUint8 structType)
530 : eventStructType(structType),
531 message(msg),
532 refPoint(0, 0),
533 time(0),
534 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
535 userType(0)
537 MOZ_COUNT_CTOR(nsEvent);
540 #ifdef MOZ_IPC
541 nsEvent()
544 #endif // MOZ_IPC
546 public:
547 nsEvent(PRBool isTrusted, PRUint32 msg)
548 : eventStructType(NS_EVENT),
549 message(msg),
550 refPoint(0, 0),
551 time(0),
552 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
553 userType(0)
555 MOZ_COUNT_CTOR(nsEvent);
558 ~nsEvent()
560 MOZ_COUNT_DTOR(nsEvent);
563 // See event struct types
564 PRUint8 eventStructType;
565 // See GUI MESSAGES,
566 PRUint32 message;
567 // Relative to the widget of the event, or if there is no widget then it is
568 // in screen coordinates. Not modified by layout code.
569 nsIntPoint refPoint;
570 // Elapsed time, in milliseconds, from a platform-specific zero time
571 // to the time the message was created
572 PRUint64 time;
573 // Flags to hold event flow stage and capture/bubble cancellation
574 // status. This is used also to indicate whether the event is trusted.
575 PRUint32 flags;
576 // Additional type info for user defined events
577 nsCOMPtr<nsIAtom> userType;
578 // Event targets, needed by DOM Events
579 nsCOMPtr<nsPIDOMEventTarget> target;
580 nsCOMPtr<nsPIDOMEventTarget> currentTarget;
581 nsCOMPtr<nsPIDOMEventTarget> originalTarget;
585 * General graphic user interface event
588 class nsGUIEvent : public nsEvent
590 protected:
591 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
592 : nsEvent(isTrusted, msg, structType),
593 widget(w), pluginEvent(nsnull)
597 #ifdef MOZ_IPC
598 nsGUIEvent()
599 : pluginEvent(nsnull)
602 #endif // MOZ_IPC
604 public:
605 nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
606 : nsEvent(isTrusted, msg, NS_GUI_EVENT),
607 widget(w), pluginEvent(nsnull)
611 /// Originator of the event
612 nsCOMPtr<nsIWidget> widget;
614 /// Event for NPAPI plugin
615 void* pluginEvent;
619 * Script error event
622 class nsScriptErrorEvent : public nsEvent
624 public:
625 nsScriptErrorEvent(PRBool isTrusted, PRUint32 msg)
626 : nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
627 lineNr(0), errorMsg(nsnull), fileName(nsnull)
631 PRInt32 lineNr;
632 const PRUnichar* errorMsg;
633 const PRUnichar* fileName;
637 * Window resize event
640 class nsSizeEvent : public nsGUIEvent
642 public:
643 nsSizeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
644 : nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
645 windowSize(nsnull), mWinWidth(0), mWinHeight(0)
649 /// x,y width, height in pixels (client area)
650 nsIntRect *windowSize;
651 /// width of entire window (in pixels)
652 PRInt32 mWinWidth;
653 /// height of entire window (in pixels)
654 PRInt32 mWinHeight;
658 * Window size mode event
661 class nsSizeModeEvent : public nsGUIEvent
663 public:
664 nsSizeModeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
665 : nsGUIEvent(isTrusted, msg, w, NS_SIZEMODE_EVENT),
666 mSizeMode(nsSizeMode_Normal)
670 nsSizeMode mSizeMode;
674 * Window z-level event
677 class nsZLevelEvent : public nsGUIEvent
679 public:
680 nsZLevelEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
681 : nsGUIEvent(isTrusted, msg, w, NS_ZLEVEL_EVENT),
682 mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull),
683 mImmediate(PR_FALSE), mAdjusted(PR_FALSE)
687 nsWindowZ mPlacement;
688 nsIWidget *mReqBelow, // widget we request being below, if any
689 *mActualBelow; // widget to be below, returned by handler
690 PRBool mImmediate, // handler should make changes immediately
691 mAdjusted; // handler changed placement
695 * Window repaint event
698 class nsPaintEvent : public nsGUIEvent
700 public:
701 nsPaintEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
702 : nsGUIEvent(isTrusted, msg, w, NS_PAINT_EVENT),
703 willSendDidPaint(PR_FALSE)
707 // area that needs repainting
708 nsIntRegion region;
709 PRPackedBool willSendDidPaint;
713 * Scrollbar event
716 class nsScrollbarEvent : public nsGUIEvent
718 public:
719 nsScrollbarEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
720 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
721 position(0)
725 /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
726 PRUint32 position;
729 class nsScrollPortEvent : public nsGUIEvent
731 public:
732 enum orientType {
733 vertical = 0,
734 horizontal = 1,
735 both = 2
738 nsScrollPortEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
739 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
740 orient(vertical)
744 orientType orient;
747 class nsScrollAreaEvent : public nsGUIEvent
749 public:
750 nsScrollAreaEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
751 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLAREA_EVENT)
755 nsRect mArea;
758 class nsInputEvent : public nsGUIEvent
760 protected:
761 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
762 PRUint8 structType)
763 : nsGUIEvent(isTrusted, msg, w, structType),
764 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
768 #ifdef MOZ_IPC
769 nsInputEvent()
772 #endif // MOZ_IPC
774 public:
775 nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
776 : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
777 isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
781 /// PR_TRUE indicates the shift key is down
782 PRBool isShift;
783 /// PR_TRUE indicates the control key is down
784 PRBool isControl;
785 /// PR_TRUE indicates the alt key is down
786 PRBool isAlt;
787 /// PR_TRUE indicates the meta key is down (or, on Mac, the Command key)
788 PRBool isMeta;
792 * Mouse event
795 class nsMouseEvent_base : public nsInputEvent
797 public:
798 nsMouseEvent_base(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 type)
799 : nsInputEvent(isTrusted, msg, w, type), button(0), pressure(0),
800 inputSource(nsIDOMNSMouseEvent::MOZ_SOURCE_MOUSE) {}
802 /// The possible related target
803 nsCOMPtr<nsISupports> relatedTarget;
805 PRInt16 button;
807 // Finger or touch pressure of event
808 // ranges between 0.0 and 1.0
809 float pressure;
811 // Possible values at nsIDOMNSMouseEvent
812 PRUint16 inputSource;
815 class nsMouseEvent : public nsMouseEvent_base
817 public:
818 enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
819 enum reasonType { eReal, eSynthesized };
820 enum contextType { eNormal, eContextMenuKey };
821 enum exitType { eChild, eTopLevel };
823 protected:
824 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
825 PRUint8 structType, reasonType aReason)
826 : nsMouseEvent_base(isTrusted, msg, w, structType),
827 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
828 reason(aReason), context(eNormal), exit(eChild), clickCount(0)
830 if (msg == NS_MOUSE_MOVE) {
831 flags |= NS_EVENT_FLAG_CANT_CANCEL;
835 public:
837 nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
838 reasonType aReason, contextType aContext = eNormal)
839 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
840 acceptActivation(PR_FALSE), ignoreRootScrollFrame(PR_FALSE),
841 reason(aReason), context(aContext), exit(eChild), clickCount(0)
843 if (msg == NS_MOUSE_MOVE) {
844 flags |= NS_EVENT_FLAG_CANT_CANCEL;
845 } else if (msg == NS_CONTEXTMENU) {
846 button = (context == eNormal) ? eRightButton : eLeftButton;
849 #ifdef NS_DEBUG
850 ~nsMouseEvent() {
851 NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
852 button ==
853 ((context == eNormal) ? eRightButton : eLeftButton),
854 "Wrong button set to NS_CONTEXTMENU event?");
856 #endif
858 /// Special return code for MOUSE_ACTIVATE to signal
859 /// if the target accepts activation (1), or denies it (0)
860 PRPackedBool acceptActivation;
861 // Whether the event should ignore scroll frame bounds
862 // during dispatch.
863 PRPackedBool ignoreRootScrollFrame;
865 reasonType reason : 4;
866 contextType context : 4;
867 exitType exit;
869 /// The number of mouse clicks
870 PRUint32 clickCount;
874 * Drag event
877 class nsDragEvent : public nsMouseEvent
879 public:
880 nsDragEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
881 : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
882 userCancelled(PR_FALSE)
884 if (msg == NS_DRAGDROP_EXIT_SYNTH ||
885 msg == NS_DRAGDROP_LEAVE_SYNTH ||
886 msg == NS_DRAGDROP_END) {
887 flags |= NS_EVENT_FLAG_CANT_CANCEL;
891 nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
892 PRPackedBool userCancelled;
895 #ifdef ACCESSIBILITY
897 * Accessible event
900 class nsAccessibleEvent : public nsInputEvent
902 public:
903 nsAccessibleEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
904 : nsInputEvent(isTrusted, msg, w, NS_ACCESSIBLE_EVENT),
905 mAccessible(nsnull)
909 nsAccessible *mAccessible;
911 #endif
914 * Keyboard event
917 struct nsAlternativeCharCode {
918 nsAlternativeCharCode(PRUint32 aUnshiftedCharCode,
919 PRUint32 aShiftedCharCode) :
920 mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
923 PRUint32 mUnshiftedCharCode;
924 PRUint32 mShiftedCharCode;
927 class nsKeyEvent : public nsInputEvent
929 public:
930 nsKeyEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
931 : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
932 keyCode(0), charCode(0), isChar(0)
936 /// see NS_VK codes
937 PRUint32 keyCode;
938 /// OS translated Unicode char
939 PRUint32 charCode;
940 // OS translated Unicode chars which are used for accesskey and accelkey
941 // handling. The handlers will try from first character to last character.
942 nsTArray<nsAlternativeCharCode> alternativeCharCodes;
943 // indicates whether the event signifies a printable character
944 PRBool isChar;
948 * IME Related Events
951 struct nsTextRangeStyle
953 enum {
954 LINESTYLE_NONE = 0,
955 LINESTYLE_SOLID = 1,
956 LINESTYLE_DOTTED = 2,
957 LINESTYLE_DASHED = 3,
958 LINESTYLE_DOUBLE = 4,
959 LINESTYLE_WAVY = 5
962 enum {
963 DEFINED_NONE = 0x00,
964 DEFINED_LINESTYLE = 0x01,
965 DEFINED_FOREGROUND_COLOR = 0x02,
966 DEFINED_BACKGROUND_COLOR = 0x04,
967 DEFINED_UNDERLINE_COLOR = 0x08
970 // Initialize all members, because nsTextRange instances may be compared by
971 // memcomp.
972 nsTextRangeStyle()
974 Clear();
977 void Clear()
979 mDefinedStyles = DEFINED_NONE;
980 mLineStyle = LINESTYLE_NONE;
981 mIsBoldLine = PR_FALSE;
982 mForegroundColor = mBackgroundColor = mUnderlineColor = NS_RGBA(0, 0, 0, 0);
985 PRBool IsDefined() const { return mDefinedStyles != DEFINED_NONE; }
987 PRBool IsLineStyleDefined() const
989 return (mDefinedStyles & DEFINED_LINESTYLE) != 0;
992 PRBool IsForegroundColorDefined() const
994 return (mDefinedStyles & DEFINED_FOREGROUND_COLOR) != 0;
997 PRBool IsBackgroundColorDefined() const
999 return (mDefinedStyles & DEFINED_BACKGROUND_COLOR) != 0;
1002 PRBool IsUnderlineColorDefined() const
1004 return (mDefinedStyles & DEFINED_UNDERLINE_COLOR) != 0;
1007 PRBool IsNoChangeStyle() const
1009 return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
1010 IsLineStyleDefined() && mLineStyle == LINESTYLE_NONE;
1013 PRBool Equals(const nsTextRangeStyle& aOther)
1015 if (mDefinedStyles != aOther.mDefinedStyles)
1016 return PR_FALSE;
1017 if (IsLineStyleDefined() && (mLineStyle != aOther.mLineStyle ||
1018 !mIsBoldLine != !aOther.mIsBoldLine))
1019 return PR_FALSE;
1020 if (IsForegroundColorDefined() &&
1021 (mForegroundColor != aOther.mForegroundColor))
1022 return PR_FALSE;
1023 if (IsBackgroundColorDefined() &&
1024 (mBackgroundColor != aOther.mBackgroundColor))
1025 return PR_FALSE;
1026 if (IsUnderlineColorDefined() &&
1027 (mUnderlineColor != aOther.mUnderlineColor))
1028 return PR_FALSE;
1029 return PR_TRUE;
1032 PRBool operator !=(const nsTextRangeStyle &aOther)
1034 return !Equals(aOther);
1037 PRBool operator ==(const nsTextRangeStyle &aOther)
1039 return Equals(aOther);
1042 PRUint8 mDefinedStyles;
1043 PRUint8 mLineStyle; // DEFINED_LINESTYLE
1045 PRPackedBool mIsBoldLine; // DEFINED_LINESTYLE
1047 nscolor mForegroundColor; // DEFINED_FOREGROUND_COLOR
1048 nscolor mBackgroundColor; // DEFINED_BACKGROUND_COLOR
1049 nscolor mUnderlineColor; // DEFINED_UNDERLINE_COLOR
1052 struct nsTextRange
1054 nsTextRange()
1055 : mStartOffset(0), mEndOffset(0), mRangeType(0)
1059 PRUint32 mStartOffset;
1060 PRUint32 mEndOffset;
1061 PRUint32 mRangeType;
1063 nsTextRangeStyle mRangeStyle;
1066 typedef nsTextRange* nsTextRangeArray;
1068 class nsTextEvent : public nsInputEvent
1070 #ifdef MOZ_IPC
1071 private:
1072 friend class mozilla::dom::PBrowserParent;
1073 friend class mozilla::dom::PBrowserChild;
1075 nsTextEvent()
1079 public:
1080 PRUint32 seqno;
1081 #endif // MOZ_IPC
1083 public:
1084 nsTextEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1085 : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
1086 rangeCount(0), rangeArray(nsnull), isChar(PR_FALSE)
1090 nsString theText;
1091 PRUint32 rangeCount;
1092 // Note that the range array may not specify a caret position; in that
1093 // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
1094 // array.
1095 nsTextRangeArray rangeArray;
1096 PRBool isChar;
1099 class nsCompositionEvent : public nsInputEvent
1101 #ifdef MOZ_IPC
1102 private:
1103 friend class mozilla::dom::PBrowserParent;
1104 friend class mozilla::dom::PBrowserChild;
1106 nsCompositionEvent()
1110 public:
1111 PRUint32 seqno;
1112 #endif // MOZ_IPC
1114 public:
1115 nsCompositionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1116 : nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
1121 /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
1123 * There are two common event flows:
1124 * (1) Normal line scrolling:
1125 * 1. An NS_MOUSE_SCROLL event without kHasPixels is dispatched to Gecko.
1126 * 2. A DOMMouseScroll event is sent into the DOM.
1127 * 3. A MozMousePixelScroll event is sent into the DOM.
1128 * 4. If neither event has been consumed, the default handling of the
1129 * NS_MOUSE_SCROLL event is executed.
1131 * (2) Pixel scrolling:
1132 * 1. An NS_MOUSE_SCROLL event with kHasPixels is dispatched to Gecko.
1133 * 2. A DOMMouseScroll event is sent into the DOM.
1134 * 3. No scrolling takes place in the default handler.
1135 * 4. An NS_MOUSE_PIXEL_SCROLL event is dispatched to Gecko.
1136 * 5. A MozMousePixelScroll event is sent into the DOM.
1137 * 6. If neither the NS_MOUSE_PIXELSCROLL event nor the preceding
1138 * NS_MOUSE_SCROLL event have been consumed, the default handler scrolls.
1139 * 7. Steps 4.-6. are repeated for every pixel scroll that belongs to
1140 * the announced line scroll. Once enough pixels have been sent to
1141 * complete a line, a new NS_MOUSE_SCROLL event is sent (goto step 1.).
1143 * If a DOMMouseScroll event has been preventDefaulted, the associated
1144 * following MozMousePixelScroll events are still sent - they just don't result
1145 * in any scrolling (their default handler isn't executed).
1147 * How many pixel scrolls make up one line scroll is decided in the widget layer
1148 * where the NS_MOUSE(_PIXEL)_SCROLL events are created.
1150 * This event flow model satisfies several requirements:
1151 * - DOMMouseScroll handlers don't need to be aware of the existence of pixel
1152 * scrolling.
1153 * - preventDefault on a DOMMouseScroll event results in no scrolling.
1154 * - DOMMouseScroll events aren't polluted with a kHasPixels flag.
1155 * - You can make use of pixel scroll DOM events (MozMousePixelScroll).
1158 class nsMouseScrollEvent : public nsMouseEvent_base
1160 public:
1161 enum nsMouseScrollFlags {
1162 kIsFullPage = 1 << 0,
1163 kIsVertical = 1 << 1,
1164 kIsHorizontal = 1 << 2,
1165 kHasPixels = 1 << 3, // Marks line scroll events that are provided as
1166 // a fallback for pixel scroll events.
1167 // These scroll events are used by things that can't
1168 // be scrolled pixel-wise, like trees. You should
1169 // ignore them when processing pixel scroll events
1170 // to avoid double-processing the same scroll gesture.
1171 // When kHasPixels is set, the event is guaranteed to
1172 // be followed up by an event that contains pixel
1173 // scrolling information.
1174 kNoLines = 1 << 4, // Marks pixel scroll events that will not be
1175 // followed by a line scroll events. EventStateManager
1176 // will compute the appropriate height/width based on
1177 // view lineHeight and generate line scroll events
1178 // as needed.
1179 kNoDefer = 1 << 5, // For scrollable views, indicates scroll should not
1180 // occur asynchronously.
1181 kIsMomentum = 1 << 6 // Marks scroll events that aren't controlled by the
1182 // user but fire automatically as the result of a
1183 // "momentum" scroll.
1186 nsMouseScrollEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
1187 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
1188 scrollFlags(0), delta(0), scrollOverflow(0)
1192 PRInt32 scrollFlags;
1193 PRInt32 delta;
1194 PRInt32 scrollOverflow;
1198 * Gesture Notify Event:
1200 * This event is the first event generated when the user touches
1201 * the screen with a finger, and it's meant to decide what kind
1202 * of action we'll use for that touch interaction.
1204 * The event is dispatched to the layout and based on what is underneath
1205 * the initial contact point it's then decided if we should pan
1206 * (finger scrolling) or drag the target element.
1208 class nsGestureNotifyEvent : public nsGUIEvent
1210 public:
1211 enum ePanDirection {
1212 ePanNone,
1213 ePanVertical,
1214 ePanHorizontal,
1215 ePanBoth
1218 ePanDirection panDirection;
1219 PRPackedBool displayPanFeedback;
1221 nsGestureNotifyEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget):
1222 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_GESTURENOTIFY_EVENT),
1223 panDirection(ePanNone),
1224 displayPanFeedback(PR_FALSE)
1229 class nsQueryContentEvent : public nsGUIEvent
1231 #ifdef MOZ_IPC
1232 private:
1233 friend class mozilla::dom::PBrowserParent;
1234 friend class mozilla::dom::PBrowserChild;
1236 nsQueryContentEvent()
1238 mReply.mContentsRoot = nsnull;
1239 mReply.mFocusedWidget = nsnull;
1241 #endif // MOZ_IPC
1243 public:
1244 nsQueryContentEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
1245 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
1246 mSucceeded(PR_FALSE), mWasAsync(PR_FALSE)
1250 void InitForQueryTextContent(PRUint32 aOffset, PRUint32 aLength)
1252 NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
1253 "wrong initializer is called");
1254 mInput.mOffset = aOffset;
1255 mInput.mLength = aLength;
1258 void InitForQueryCaretRect(PRUint32 aOffset)
1260 NS_ASSERTION(message == NS_QUERY_CARET_RECT,
1261 "wrong initializer is called");
1262 mInput.mOffset = aOffset;
1265 void InitForQueryTextRect(PRUint32 aOffset, PRUint32 aLength)
1267 NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
1268 "wrong initializer is called");
1269 mInput.mOffset = aOffset;
1270 mInput.mLength = aLength;
1273 PRUint32 GetSelectionStart(void) const
1275 NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1276 "not querying selection");
1277 return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
1280 PRUint32 GetSelectionEnd(void) const
1282 NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1283 "not querying selection");
1284 return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
1287 PRBool mSucceeded;
1288 PRPackedBool mWasAsync;
1289 struct {
1290 PRUint32 mOffset;
1291 PRUint32 mLength;
1292 } mInput;
1293 struct {
1294 void* mContentsRoot;
1295 PRUint32 mOffset;
1296 nsString mString;
1297 nsIntRect mRect; // Finally, the coordinates is system coordinates.
1298 // The return widget has the caret. This is set at all query events.
1299 nsIWidget* mFocusedWidget;
1300 PRPackedBool mReversed; // true if selection is reversed (end < start)
1301 PRPackedBool mHasSelection; // true if the selection exists
1302 // used by NS_QUERY_SELECTION_AS_TRANSFERABLE
1303 nsCOMPtr<nsITransferable> mTransferable;
1304 } mReply;
1306 enum {
1307 NOT_FOUND = PR_UINT32_MAX
1311 class nsFocusEvent : public nsEvent
1313 public:
1314 nsFocusEvent(PRBool isTrusted, PRUint32 msg)
1315 : nsEvent(isTrusted, msg, NS_FOCUS_EVENT),
1316 fromRaise(PR_FALSE),
1317 isRefocus(PR_FALSE)
1321 PRPackedBool fromRaise;
1322 PRPackedBool isRefocus;
1325 class nsSelectionEvent : public nsGUIEvent
1327 #ifdef MOZ_IPC
1328 private:
1329 friend class mozilla::dom::PBrowserParent;
1330 friend class mozilla::dom::PBrowserChild;
1332 nsSelectionEvent()
1336 public:
1337 PRUint32 seqno;
1338 #endif // MOZ_IPC
1340 public:
1341 nsSelectionEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
1342 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_SELECTION_EVENT),
1343 mExpandToClusterBoundary(PR_TRUE), mSucceeded(PR_FALSE)
1347 PRUint32 mOffset; // start offset of selection
1348 PRUint32 mLength; // length of selection
1349 PRPackedBool mReversed; // selection "anchor" should be in front
1350 PRPackedBool mExpandToClusterBoundary; // cluster-based or character-based
1351 PRPackedBool mSucceeded;
1354 class nsContentCommandEvent : public nsGUIEvent
1356 public:
1357 nsContentCommandEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget,
1358 PRBool aOnlyEnabledCheck = PR_FALSE) :
1359 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
1360 mOnlyEnabledCheck(PRPackedBool(aOnlyEnabledCheck)),
1361 mSucceeded(PR_FALSE), mIsEnabled(PR_FALSE)
1365 // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
1366 nsCOMPtr<nsITransferable> mTransferable; // [in]
1368 // NS_CONTENT_COMMAND_SCROLL
1369 // for mScroll.mUnit
1370 enum {
1371 eCmdScrollUnit_Line,
1372 eCmdScrollUnit_Page,
1373 eCmdScrollUnit_Whole
1376 struct ScrollInfo {
1377 ScrollInfo() :
1378 mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(PR_FALSE)
1382 PRInt32 mAmount; // [in]
1383 PRUint8 mUnit; // [in]
1384 PRPackedBool mIsHorizontal; // [in]
1385 } mScroll;
1387 PRPackedBool mOnlyEnabledCheck; // [in]
1389 PRPackedBool mSucceeded; // [out]
1390 PRPackedBool mIsEnabled; // [out]
1393 class nsMozTouchEvent : public nsMouseEvent_base
1395 public:
1396 nsMozTouchEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w,
1397 PRUint32 streamIdArg)
1398 : nsMouseEvent_base(isTrusted, msg, w, NS_MOZTOUCH_EVENT),
1399 streamId(streamIdArg)
1403 PRUint32 streamId;
1407 * Form event
1409 * We hold the originating form control for form submit and reset events.
1410 * originator is a weak pointer (does not hold a strong reference).
1413 class nsFormEvent : public nsEvent
1415 public:
1416 nsFormEvent(PRBool isTrusted, PRUint32 msg)
1417 : nsEvent(isTrusted, msg, NS_FORM_EVENT),
1418 originator(nsnull)
1422 nsIContent *originator;
1426 * Command event
1428 * Custom commands for example from the operating system.
1431 class nsCommandEvent : public nsGUIEvent
1433 public:
1434 nsCommandEvent(PRBool isTrusted, nsIAtom* aEventType,
1435 nsIAtom* aCommand, nsIWidget* w)
1436 : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
1438 userType = aEventType;
1439 command = aCommand;
1442 nsCOMPtr<nsIAtom> command;
1446 * DOM UIEvent
1448 class nsUIEvent : public nsEvent
1450 public:
1451 nsUIEvent(PRBool isTrusted, PRUint32 msg, PRInt32 d)
1452 : nsEvent(isTrusted, msg, NS_UI_EVENT),
1453 detail(d)
1457 PRInt32 detail;
1461 * Simple gesture event
1463 class nsSimpleGestureEvent : public nsMouseEvent_base
1465 public:
1466 nsSimpleGestureEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w,
1467 PRUint32 directionArg, PRFloat64 deltaArg)
1468 : nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
1469 direction(directionArg), delta(deltaArg)
1473 PRUint32 direction; // See nsIDOMSimpleGestureEvent for values
1474 PRFloat64 delta; // Delta for magnify and rotate events
1477 class nsTransitionEvent : public nsEvent
1479 public:
1480 nsTransitionEvent(PRBool isTrusted, PRUint32 msg,
1481 const nsString &propertyNameArg, float elapsedTimeArg)
1482 : nsEvent(isTrusted, msg, NS_TRANSITION_EVENT),
1483 propertyName(propertyNameArg), elapsedTime(elapsedTimeArg)
1487 nsString propertyName;
1488 float elapsedTime;
1492 class nsUIStateChangeEvent : public nsGUIEvent
1494 public:
1495 nsUIStateChangeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget* w)
1496 : nsGUIEvent(isTrusted, msg, w, NS_UISTATECHANGE_EVENT),
1497 showAccelerators(UIStateChangeType_NoChange),
1498 showFocusRings(UIStateChangeType_NoChange)
1502 UIStateChangeType showAccelerators;
1503 UIStateChangeType showFocusRings;
1507 * Event status for D&D Event
1509 enum nsDragDropEventStatus {
1510 /// The event is a enter
1511 nsDragDropEventStatus_eDragEntered,
1512 /// The event is exit
1513 nsDragDropEventStatus_eDragExited,
1514 /// The event is drop
1515 nsDragDropEventStatus_eDrop
1519 #define NS_IS_MOUSE_EVENT(evnt) \
1520 (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1521 ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1522 ((evnt)->message == NS_MOUSE_CLICK) || \
1523 ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1524 ((evnt)->message == NS_MOUSE_ENTER) || \
1525 ((evnt)->message == NS_MOUSE_EXIT) || \
1526 ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1527 ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1528 ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1529 ((evnt)->message == NS_MOUSE_MOZHITTEST) || \
1530 ((evnt)->message == NS_MOUSE_MOVE))
1532 #define NS_IS_MOUSE_EVENT_STRUCT(evnt) \
1533 ((evnt)->eventStructType == NS_MOUSE_EVENT || \
1534 (evnt)->eventStructType == NS_DRAG_EVENT)
1536 #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1537 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1538 (evnt)->message == NS_MOUSE_CLICK && \
1539 static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1541 #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1542 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1543 (evnt)->message == NS_CONTEXTMENU && \
1544 static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1546 #define NS_IS_DRAG_EVENT(evnt) \
1547 (((evnt)->message == NS_DRAGDROP_ENTER) || \
1548 ((evnt)->message == NS_DRAGDROP_OVER) || \
1549 ((evnt)->message == NS_DRAGDROP_EXIT) || \
1550 ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1551 ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1552 ((evnt)->message == NS_DRAGDROP_DRAG) || \
1553 ((evnt)->message == NS_DRAGDROP_END) || \
1554 ((evnt)->message == NS_DRAGDROP_START) || \
1555 ((evnt)->message == NS_DRAGDROP_DROP) || \
1556 ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1558 #define NS_IS_KEY_EVENT(evnt) \
1559 (((evnt)->message == NS_KEY_DOWN) || \
1560 ((evnt)->message == NS_KEY_PRESS) || \
1561 ((evnt)->message == NS_KEY_UP))
1563 #define NS_IS_IME_EVENT(evnt) \
1564 (((evnt)->message == NS_TEXT_TEXT) || \
1565 ((evnt)->message == NS_COMPOSITION_START) || \
1566 ((evnt)->message == NS_COMPOSITION_END))
1568 #define NS_IS_ACTIVATION_EVENT(evnt) \
1569 (((evnt)->message == NS_ACTIVATE) || \
1570 ((evnt)->message == NS_DEACTIVATE) || \
1571 ((evnt)->message == NS_PLUGIN_ACTIVATE) || \
1572 ((evnt)->message == NS_PLUGIN_FOCUS))
1574 #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1575 (((evnt)->message == NS_QUERY_SELECTED_TEXT) || \
1576 ((evnt)->message == NS_QUERY_TEXT_CONTENT) || \
1577 ((evnt)->message == NS_QUERY_CARET_RECT) || \
1578 ((evnt)->message == NS_QUERY_TEXT_RECT) || \
1579 ((evnt)->message == NS_QUERY_EDITOR_RECT) || \
1580 ((evnt)->message == NS_QUERY_CONTENT_STATE) || \
1581 ((evnt)->message == NS_QUERY_SELECTION_AS_TRANSFERABLE) || \
1582 ((evnt)->message == NS_QUERY_CHARACTER_AT_POINT))
1584 #define NS_IS_SELECTION_EVENT(evnt) \
1585 (((evnt)->message == NS_SELECTION_SET))
1587 #define NS_IS_CONTENT_COMMAND_EVENT(evnt) \
1588 ((evnt)->eventStructType == NS_CONTENT_COMMAND_EVENT)
1590 #define NS_IS_PLUGIN_EVENT(evnt) \
1591 (((evnt)->message == NS_PLUGIN_EVENT))
1593 #define NS_IS_NON_RETARGETED_PLUGIN_EVENT(evnt) \
1594 (((evnt)->message == NS_NON_RETARGETED_PLUGIN_EVENT))
1596 #define NS_IS_TRUSTED_EVENT(event) \
1597 (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1599 // Mark an event as being dispatching.
1600 #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1601 (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1603 #define NS_IS_EVENT_IN_DISPATCH(event) \
1604 (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1606 // Mark an event as being done dispatching.
1607 #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1608 NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1609 "Event never got marked for dispatch!"); \
1610 (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1611 (event)->flags |= NS_EVENT_DISPATCHED;
1613 // Be aware the query content events and the selection events are a part of IME
1614 // processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
1615 // cases, you should use NS_IS_IME_RELATED_EVENT instead.
1616 #define NS_IS_IME_RELATED_EVENT(evnt) \
1617 (NS_IS_IME_EVENT(evnt) || \
1618 NS_IS_QUERY_CONTENT_EVENT(evnt) || \
1619 NS_IS_SELECTION_EVENT(evnt))
1622 * Virtual key bindings for keyboard events.
1623 * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1624 * Really, it would be better if we phased out the NS_VK symbols altogether
1625 * in favor of the DOM ones, but at least this way they'll be in sync.
1628 #define NS_VK_CANCEL nsIDOMKeyEvent::DOM_VK_CANCEL
1629 #define NS_VK_HELP nsIDOMKeyEvent::DOM_VK_HELP
1630 #define NS_VK_BACK nsIDOMKeyEvent::DOM_VK_BACK_SPACE
1631 #define NS_VK_TAB nsIDOMKeyEvent::DOM_VK_TAB
1632 #define NS_VK_CLEAR nsIDOMKeyEvent::DOM_VK_CLEAR
1633 #define NS_VK_RETURN nsIDOMKeyEvent::DOM_VK_RETURN
1634 #define NS_VK_ENTER nsIDOMKeyEvent::DOM_VK_ENTER
1635 #define NS_VK_SHIFT nsIDOMKeyEvent::DOM_VK_SHIFT
1636 #define NS_VK_CONTROL nsIDOMKeyEvent::DOM_VK_CONTROL
1637 #define NS_VK_ALT nsIDOMKeyEvent::DOM_VK_ALT
1638 #define NS_VK_PAUSE nsIDOMKeyEvent::DOM_VK_PAUSE
1639 #define NS_VK_CAPS_LOCK nsIDOMKeyEvent::DOM_VK_CAPS_LOCK
1640 #define NS_VK_KANA nsIDOMKeyEvent::DOM_VK_KANA
1641 #define NS_VK_HANGUL nsIDOMKeyEvent::DOM_VK_HANGUL
1642 #define NS_VK_JUNJA nsIDOMKeyEvent::DOM_VK_JUNJA
1643 #define NS_VK_FINAL nsIDOMKeyEvent::DOM_VK_FINAL
1644 #define NS_VK_HANJA nsIDOMKeyEvent::DOM_VK_HANJA
1645 #define NS_VK_KANJI nsIDOMKeyEvent::DOM_VK_KANJI
1646 #define NS_VK_ESCAPE nsIDOMKeyEvent::DOM_VK_ESCAPE
1647 #define NS_VK_CONVERT nsIDOMKeyEvent::DOM_VK_CONVERT
1648 #define NS_VK_NONCONVERT nsIDOMKeyEvent::DOM_VK_NONCONVERT
1649 #define NS_VK_ACCEPT nsIDOMKeyEvent::DOM_VK_ACCEPT
1650 #define NS_VK_MODECHANGE nsIDOMKeyEvent::DOM_VK_MODECHANGE
1651 #define NS_VK_SPACE nsIDOMKeyEvent::DOM_VK_SPACE
1652 #define NS_VK_PAGE_UP nsIDOMKeyEvent::DOM_VK_PAGE_UP
1653 #define NS_VK_PAGE_DOWN nsIDOMKeyEvent::DOM_VK_PAGE_DOWN
1654 #define NS_VK_END nsIDOMKeyEvent::DOM_VK_END
1655 #define NS_VK_HOME nsIDOMKeyEvent::DOM_VK_HOME
1656 #define NS_VK_LEFT nsIDOMKeyEvent::DOM_VK_LEFT
1657 #define NS_VK_UP nsIDOMKeyEvent::DOM_VK_UP
1658 #define NS_VK_RIGHT nsIDOMKeyEvent::DOM_VK_RIGHT
1659 #define NS_VK_DOWN nsIDOMKeyEvent::DOM_VK_DOWN
1660 #define NS_VK_SELECT nsIDOMKeyEvent::DOM_VK_SELECT
1661 #define NS_VK_PRINT nsIDOMKeyEvent::DOM_VK_PRINT
1662 #define NS_VK_EXECUTE nsIDOMKeyEvent::DOM_VK_EXECUTE
1663 #define NS_VK_PRINTSCREEN nsIDOMKeyEvent::DOM_VK_PRINTSCREEN
1664 #define NS_VK_INSERT nsIDOMKeyEvent::DOM_VK_INSERT
1665 #define NS_VK_DELETE nsIDOMKeyEvent::DOM_VK_DELETE
1667 // NS_VK_0 - NS_VK_9 match their ascii values
1668 #define NS_VK_0 nsIDOMKeyEvent::DOM_VK_0
1669 #define NS_VK_1 nsIDOMKeyEvent::DOM_VK_1
1670 #define NS_VK_2 nsIDOMKeyEvent::DOM_VK_2
1671 #define NS_VK_3 nsIDOMKeyEvent::DOM_VK_3
1672 #define NS_VK_4 nsIDOMKeyEvent::DOM_VK_4
1673 #define NS_VK_5 nsIDOMKeyEvent::DOM_VK_5
1674 #define NS_VK_6 nsIDOMKeyEvent::DOM_VK_6
1675 #define NS_VK_7 nsIDOMKeyEvent::DOM_VK_7
1676 #define NS_VK_8 nsIDOMKeyEvent::DOM_VK_8
1677 #define NS_VK_9 nsIDOMKeyEvent::DOM_VK_9
1679 #define NS_VK_SEMICOLON nsIDOMKeyEvent::DOM_VK_SEMICOLON
1680 #define NS_VK_EQUALS nsIDOMKeyEvent::DOM_VK_EQUALS
1682 // NS_VK_A - NS_VK_Z match their ascii values
1683 #define NS_VK_A nsIDOMKeyEvent::DOM_VK_A
1684 #define NS_VK_B nsIDOMKeyEvent::DOM_VK_B
1685 #define NS_VK_C nsIDOMKeyEvent::DOM_VK_C
1686 #define NS_VK_D nsIDOMKeyEvent::DOM_VK_D
1687 #define NS_VK_E nsIDOMKeyEvent::DOM_VK_E
1688 #define NS_VK_F nsIDOMKeyEvent::DOM_VK_F
1689 #define NS_VK_G nsIDOMKeyEvent::DOM_VK_G
1690 #define NS_VK_H nsIDOMKeyEvent::DOM_VK_H
1691 #define NS_VK_I nsIDOMKeyEvent::DOM_VK_I
1692 #define NS_VK_J nsIDOMKeyEvent::DOM_VK_J
1693 #define NS_VK_K nsIDOMKeyEvent::DOM_VK_K
1694 #define NS_VK_L nsIDOMKeyEvent::DOM_VK_L
1695 #define NS_VK_M nsIDOMKeyEvent::DOM_VK_M
1696 #define NS_VK_N nsIDOMKeyEvent::DOM_VK_N
1697 #define NS_VK_O nsIDOMKeyEvent::DOM_VK_O
1698 #define NS_VK_P nsIDOMKeyEvent::DOM_VK_P
1699 #define NS_VK_Q nsIDOMKeyEvent::DOM_VK_Q
1700 #define NS_VK_R nsIDOMKeyEvent::DOM_VK_R
1701 #define NS_VK_S nsIDOMKeyEvent::DOM_VK_S
1702 #define NS_VK_T nsIDOMKeyEvent::DOM_VK_T
1703 #define NS_VK_U nsIDOMKeyEvent::DOM_VK_U
1704 #define NS_VK_V nsIDOMKeyEvent::DOM_VK_V
1705 #define NS_VK_W nsIDOMKeyEvent::DOM_VK_W
1706 #define NS_VK_X nsIDOMKeyEvent::DOM_VK_X
1707 #define NS_VK_Y nsIDOMKeyEvent::DOM_VK_Y
1708 #define NS_VK_Z nsIDOMKeyEvent::DOM_VK_Z
1710 #define NS_VK_CONTEXT_MENU nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU
1711 #define NS_VK_SLEEP nsIDOMKeyEvent::DOM_VK_SLEEP
1713 #define NS_VK_NUMPAD0 nsIDOMKeyEvent::DOM_VK_NUMPAD0
1714 #define NS_VK_NUMPAD1 nsIDOMKeyEvent::DOM_VK_NUMPAD1
1715 #define NS_VK_NUMPAD2 nsIDOMKeyEvent::DOM_VK_NUMPAD2
1716 #define NS_VK_NUMPAD3 nsIDOMKeyEvent::DOM_VK_NUMPAD3
1717 #define NS_VK_NUMPAD4 nsIDOMKeyEvent::DOM_VK_NUMPAD4
1718 #define NS_VK_NUMPAD5 nsIDOMKeyEvent::DOM_VK_NUMPAD5
1719 #define NS_VK_NUMPAD6 nsIDOMKeyEvent::DOM_VK_NUMPAD6
1720 #define NS_VK_NUMPAD7 nsIDOMKeyEvent::DOM_VK_NUMPAD7
1721 #define NS_VK_NUMPAD8 nsIDOMKeyEvent::DOM_VK_NUMPAD8
1722 #define NS_VK_NUMPAD9 nsIDOMKeyEvent::DOM_VK_NUMPAD9
1723 #define NS_VK_MULTIPLY nsIDOMKeyEvent::DOM_VK_MULTIPLY
1724 #define NS_VK_ADD nsIDOMKeyEvent::DOM_VK_ADD
1725 #define NS_VK_SEPARATOR nsIDOMKeyEvent::DOM_VK_SEPARATOR
1726 #define NS_VK_SUBTRACT nsIDOMKeyEvent::DOM_VK_SUBTRACT
1727 #define NS_VK_DECIMAL nsIDOMKeyEvent::DOM_VK_DECIMAL
1728 #define NS_VK_DIVIDE nsIDOMKeyEvent::DOM_VK_DIVIDE
1729 #define NS_VK_F1 nsIDOMKeyEvent::DOM_VK_F1
1730 #define NS_VK_F2 nsIDOMKeyEvent::DOM_VK_F2
1731 #define NS_VK_F3 nsIDOMKeyEvent::DOM_VK_F3
1732 #define NS_VK_F4 nsIDOMKeyEvent::DOM_VK_F4
1733 #define NS_VK_F5 nsIDOMKeyEvent::DOM_VK_F5
1734 #define NS_VK_F6 nsIDOMKeyEvent::DOM_VK_F6
1735 #define NS_VK_F7 nsIDOMKeyEvent::DOM_VK_F7
1736 #define NS_VK_F8 nsIDOMKeyEvent::DOM_VK_F8
1737 #define NS_VK_F9 nsIDOMKeyEvent::DOM_VK_F9
1738 #define NS_VK_F10 nsIDOMKeyEvent::DOM_VK_F10
1739 #define NS_VK_F11 nsIDOMKeyEvent::DOM_VK_F11
1740 #define NS_VK_F12 nsIDOMKeyEvent::DOM_VK_F12
1741 #define NS_VK_F13 nsIDOMKeyEvent::DOM_VK_F13
1742 #define NS_VK_F14 nsIDOMKeyEvent::DOM_VK_F14
1743 #define NS_VK_F15 nsIDOMKeyEvent::DOM_VK_F15
1744 #define NS_VK_F16 nsIDOMKeyEvent::DOM_VK_F16
1745 #define NS_VK_F17 nsIDOMKeyEvent::DOM_VK_F17
1746 #define NS_VK_F18 nsIDOMKeyEvent::DOM_VK_F18
1747 #define NS_VK_F19 nsIDOMKeyEvent::DOM_VK_F19
1748 #define NS_VK_F20 nsIDOMKeyEvent::DOM_VK_F20
1749 #define NS_VK_F21 nsIDOMKeyEvent::DOM_VK_F21
1750 #define NS_VK_F22 nsIDOMKeyEvent::DOM_VK_F22
1751 #define NS_VK_F23 nsIDOMKeyEvent::DOM_VK_F23
1752 #define NS_VK_F24 nsIDOMKeyEvent::DOM_VK_F24
1754 #define NS_VK_NUM_LOCK nsIDOMKeyEvent::DOM_VK_NUM_LOCK
1755 #define NS_VK_SCROLL_LOCK nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK
1757 #define NS_VK_COMMA nsIDOMKeyEvent::DOM_VK_COMMA
1758 #define NS_VK_PERIOD nsIDOMKeyEvent::DOM_VK_PERIOD
1759 #define NS_VK_SLASH nsIDOMKeyEvent::DOM_VK_SLASH
1760 #define NS_VK_BACK_QUOTE nsIDOMKeyEvent::DOM_VK_BACK_QUOTE
1761 #define NS_VK_OPEN_BRACKET nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET
1762 #define NS_VK_BACK_SLASH nsIDOMKeyEvent::DOM_VK_BACK_SLASH
1763 #define NS_VK_CLOSE_BRACKET nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET
1764 #define NS_VK_QUOTE nsIDOMKeyEvent::DOM_VK_QUOTE
1766 #define NS_VK_META nsIDOMKeyEvent::DOM_VK_META
1768 // IME Constants -- keep in synch with nsIPrivateTextRange.h
1769 #define NS_TEXTRANGE_CARETPOSITION 0x01
1770 #define NS_TEXTRANGE_RAWINPUT 0x02
1771 #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1772 #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1773 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1776 * Whether the event should be handled by the frame of the mouse cursor
1777 * position or not. When it should be handled there (e.g., the mouse events),
1778 * this returns TRUE.
1780 inline PRBool NS_IsEventUsingCoordinates(nsEvent* aEvent)
1782 return !NS_IS_KEY_EVENT(aEvent) && !NS_IS_IME_RELATED_EVENT(aEvent) &&
1783 !NS_IS_CONTEXT_MENU_KEY(aEvent) && !NS_IS_ACTIVATION_EVENT(aEvent) &&
1784 !NS_IS_PLUGIN_EVENT(aEvent) && !NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) &&
1785 !NS_IS_CONTENT_COMMAND_EVENT(aEvent) &&
1786 aEvent->eventStructType != NS_ACCESSIBLE_EVENT;
1790 * Whether the event should be handled by the focused DOM window in the
1791 * same top level window's or not. E.g., key events, IME related events
1792 * (including the query content events, they are used in IME transaction)
1793 * should be handled by the (last) focused window rather than the dispatched
1794 * window.
1796 * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
1797 * application level active DOM window which is on another top level window.
1798 * So, when the event is fired on a deactive window, the event is going to be
1799 * handled by the last focused DOM window in the last focused window.
1801 inline PRBool NS_IsEventTargetedAtFocusedWindow(nsEvent* aEvent)
1803 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
1804 NS_IS_CONTEXT_MENU_KEY(aEvent) || NS_IS_CONTENT_COMMAND_EVENT(aEvent);
1808 * Whether the event should be handled by the focused content or not. E.g.,
1809 * key events, IME related events and other input events which are not handled
1810 * by the frame of the mouse cursor position.
1812 * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
1813 * application level active DOM window which is on another top level window.
1814 * So, when the event is fired on a deactive window, the event is going to be
1815 * handled by the last focused DOM element of the last focused DOM window in
1816 * the last focused window.
1818 inline PRBool NS_IsEventTargetedAtFocusedContent(nsEvent* aEvent)
1820 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
1821 NS_IS_CONTEXT_MENU_KEY(aEvent) || NS_IS_PLUGIN_EVENT(aEvent);
1824 #endif // nsGUIEvent_h__