Bug 796038 - Default browser prompt shows even after setting defaults for Firefox...
[gecko.git] / widget / nsGUIEvent.h
blobad09db94ffaf3e7c74a814ddb6d68535f63f785c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsGUIEvent_h__
7 #define nsGUIEvent_h__
9 #include "nsCOMArray.h"
10 #include "nsPoint.h"
11 #include "nsRect.h"
12 #include "nsRegion.h"
13 #include "nsEvent.h"
14 #include "nsStringGlue.h"
15 #include "nsCOMPtr.h"
16 #include "nsIAtom.h"
17 #include "nsIDOMKeyEvent.h"
18 #include "nsIDOMMouseEvent.h"
19 #include "nsIDOMWheelEvent.h"
20 #include "nsIDOMDataTransfer.h"
21 #include "nsIDOMEventTarget.h"
22 #include "nsIDOMTouchEvent.h"
23 #include "nsWeakPtr.h"
24 #include "nsIWidget.h"
25 #include "nsTArray.h"
26 #include "nsTraceRefcnt.h"
27 #include "nsITransferable.h"
28 #include "nsIVariant.h"
29 #include "nsStyleConsts.h"
30 #include "nsAutoPtr.h"
32 namespace mozilla {
33 namespace dom {
34 class PBrowserParent;
35 class PBrowserChild;
37 namespace plugins {
38 class PPluginInstanceChild;
42 class nsRenderingContext;
43 class nsIMenuItem;
44 class nsIContent;
45 class nsIURI;
46 class nsHashKey;
48 /**
49 * Event Struct Types
51 #define NS_EVENT 1
52 #define NS_GUI_EVENT 2
53 #define NS_SIZE_EVENT 3
54 #define NS_SIZEMODE_EVENT 4
55 #define NS_ZLEVEL_EVENT 5
56 #define NS_PAINT_EVENT 6
57 #define NS_SCROLLBAR_EVENT 7
58 #define NS_INPUT_EVENT 8
59 #define NS_KEY_EVENT 9
60 #define NS_MOUSE_EVENT 10
61 #define NS_SCRIPT_ERROR_EVENT 12
62 #define NS_TEXT_EVENT 13
63 #define NS_COMPOSITION_EVENT 14
64 #define NS_MOUSE_SCROLL_EVENT 16
65 #define NS_SCROLLPORT_EVENT 18
66 #define NS_MUTATION_EVENT 19 // |nsMutationEvent| in content
67 #define NS_FORM_EVENT 21
68 #define NS_FOCUS_EVENT 22
69 #define NS_POPUP_EVENT 23
70 #define NS_COMMAND_EVENT 24
71 #define NS_SCROLLAREA_EVENT 25
72 #define NS_TRANSITION_EVENT 26
73 #define NS_ANIMATION_EVENT 27
75 #define NS_UI_EVENT 28
76 #define NS_SVG_EVENT 30
77 #define NS_SVGZOOM_EVENT 31
78 #define NS_SMIL_TIME_EVENT 32
80 #define NS_QUERY_CONTENT_EVENT 33
82 #define NS_DRAG_EVENT 35
83 #define NS_NOTIFYPAINT_EVENT 36
84 #define NS_SIMPLE_GESTURE_EVENT 37
85 #define NS_SELECTION_EVENT 38
86 #define NS_CONTENT_COMMAND_EVENT 39
87 #define NS_GESTURENOTIFY_EVENT 40
88 #define NS_PLUGIN_EVENT 43
89 #define NS_TOUCH_EVENT 44
90 #define NS_WHEEL_EVENT 45
92 // These flags are sort of a mess. They're sort of shared between event
93 // listener flags and event flags, but only some of them. You've been
94 // warned!
95 #define NS_EVENT_FLAG_NONE 0x0000
96 #define NS_EVENT_FLAG_TRUSTED 0x0001
97 #define NS_EVENT_FLAG_BUBBLE 0x0002
98 #define NS_EVENT_FLAG_CAPTURE 0x0004
99 #define NS_EVENT_FLAG_STOP_DISPATCH 0x0008
100 #define NS_EVENT_FLAG_NO_DEFAULT 0x0010
101 #define NS_EVENT_FLAG_CANT_CANCEL 0x0020
102 #define NS_EVENT_FLAG_CANT_BUBBLE 0x0040
103 #define NS_PRIV_EVENT_FLAG_SCRIPT 0x0080
104 #define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
105 #define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
106 // Event has been dispatched at least once
107 #define NS_EVENT_DISPATCHED 0x0400
108 #define NS_EVENT_FLAG_DISPATCHING 0x0800
109 // When an event is synthesized for testing, this flag will be set.
110 // Note that this is currently used only with mouse events, because this
111 // flag is not needed on other events now. It could be added to other
112 // events.
113 #define NS_EVENT_FLAG_SYNTHETIC_TEST_EVENT 0x1000
115 // Use this flag if the event should be dispatched only to chrome.
116 #define NS_EVENT_FLAG_ONLY_CHROME_DISPATCH 0x2000
118 // A flag for drag&drop handling.
119 #define NS_EVENT_FLAG_NO_DEFAULT_CALLED_IN_CONTENT 0x4000
121 #define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x8000
123 #define NS_EVENT_FLAG_EXCEPTION_THROWN 0x10000
125 #define NS_EVENT_FLAG_PREVENT_MULTIPLE_ACTIONS 0x20000
127 #define NS_EVENT_RETARGET_TO_NON_NATIVE_ANONYMOUS 0x40000
129 #define NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY 0x80000
131 #define NS_EVENT_FLAG_DONT_FORWARD_CROSS_PROCESS 0x100000
133 #define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
134 #define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
136 #define NS_EVENT_TYPE_NULL 0
139 * GUI MESSAGES
141 //@{
142 #define NS_EVENT_NULL 0
145 #define NS_WINDOW_START 100
147 // Widget may be destroyed
148 #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
149 // Key is pressed within a window
150 #define NS_KEY_PRESS (NS_WINDOW_START + 31)
151 // Key is released within a window
152 #define NS_KEY_UP (NS_WINDOW_START + 32)
153 // Key is pressed within a window
154 #define NS_KEY_DOWN (NS_WINDOW_START + 33)
156 #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
157 #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
159 // A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be
160 // used when the window is not active. NS_PLUGIN_FOCUS should be used when
161 // the window is active. In the latter case, the dispatcher of the event
162 // is expected to ensure that the plugin's widget is focused beforehand.
163 #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
164 #define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63)
166 #define NS_OFFLINE (NS_WINDOW_START + 64)
167 #define NS_ONLINE (NS_WINDOW_START + 65)
169 // Indicates a resize will occur
170 #define NS_BEFORERESIZE_EVENT (NS_WINDOW_START + 66)
172 // Indicates that the user is either idle or active
173 #define NS_MOZ_USER_IDLE (NS_WINDOW_START + 67)
174 #define NS_MOZ_USER_ACTIVE (NS_WINDOW_START + 68)
176 #define NS_MOUSE_MESSAGE_START 300
177 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
178 #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
179 #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
180 #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
181 #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
182 #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
183 #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
184 #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
185 #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
186 #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
187 #define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
188 #define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34)
189 #define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35)
191 #define NS_CONTEXTMENU_MESSAGE_START 500
192 #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
194 #define NS_STREAM_EVENT_START 1100
195 #define NS_LOAD (NS_STREAM_EVENT_START)
196 #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
197 #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
198 #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
199 #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
200 #define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
201 #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
202 #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
203 #define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8)
205 #define NS_FORM_EVENT_START 1200
206 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
207 #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
208 #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
209 #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
210 #define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
211 #define NS_FORM_INVALID (NS_FORM_EVENT_START + 5)
213 //Need separate focus/blur notifications for non-native widgets
214 #define NS_FOCUS_EVENT_START 1300
215 #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
216 #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
218 #define NS_DRAGDROP_EVENT_START 1400
219 #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
220 #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
221 #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
222 #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
223 #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
224 #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
225 #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
226 #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
227 #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
228 #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
229 #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
230 #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
232 // Events for popups
233 #define NS_XUL_EVENT_START 1500
234 #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
235 #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
236 #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
237 #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
238 // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
239 #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
240 #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
241 //@}
243 // Scroll events
244 #define NS_MOUSE_SCROLL_START 1600
245 #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
246 #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
248 #define NS_SCROLLPORT_START 1700
249 #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
250 #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
252 // Mutation events defined elsewhere starting at 1800
254 #define NS_USER_DEFINED_EVENT 2000
256 // composition events
257 #define NS_COMPOSITION_EVENT_START 2200
258 #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
259 #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
260 #define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2)
262 // text events
263 #define NS_TEXT_START 2400
264 #define NS_TEXT_TEXT (NS_TEXT_START)
266 // UI events
267 #define NS_UI_EVENT_START 2500
268 // this is not to be confused with NS_ACTIVATE!
269 #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
270 #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
271 #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
273 // pagetransition events
274 #define NS_PAGETRANSITION_START 2700
275 #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
276 #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
278 // SVG events
279 #define NS_SVG_EVENT_START 2800
280 #define NS_SVG_LOAD (NS_SVG_EVENT_START)
281 #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
282 #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
283 #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
284 #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
285 #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
287 // SVG Zoom events
288 #define NS_SVGZOOM_EVENT_START 2900
289 #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
291 // XUL command events
292 #define NS_XULCOMMAND_EVENT_START 3000
293 #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
295 // Cut, copy, paste events
296 #define NS_CUTCOPYPASTE_EVENT_START 3100
297 #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
298 #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
299 #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
301 // Query the content information
302 #define NS_QUERY_CONTENT_EVENT_START 3200
303 // Query for the selected text information, it return the selection offset,
304 // selection length and selected text.
305 #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
306 // Query for the text content of specified range, it returns actual lengh (if
307 // the specified range is too long) and the text of the specified range.
308 // Returns the entire text if requested length > actual length.
309 #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
310 // Query for the caret rect of nth insertion point. The offset of the result is
311 // relative position from the top level widget.
312 #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
313 // Query for the bounding rect of a range of characters. This works on any
314 // valid character range given offset and length. Result is relative to top
315 // level widget coordinates
316 #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
317 // Query for the bounding rect of the current focused frame. Result is relative
318 // to top level widget coordinates
319 #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
320 // Query for the current state of the content. The particular members of
321 // mReply that are set for each query content event will be valid on success.
322 #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
323 // Query for the selection in the form of a nsITransferable.
324 #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
325 // Query for character at a point. This returns the character offset and its
326 // rect. The point is specified by nsEvent::refPoint.
327 #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
328 // Query if the DOM element under nsEvent::refPoint belongs to our widget
329 // or not.
330 #define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9)
332 // Video events
333 #define NS_MEDIA_EVENT_START 3300
334 #define NS_LOADSTART (NS_MEDIA_EVENT_START)
335 #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
336 #define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
337 #define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
338 #define NS_STALLED (NS_MEDIA_EVENT_START+4)
339 #define NS_PLAY (NS_MEDIA_EVENT_START+5)
340 #define NS_PAUSE (NS_MEDIA_EVENT_START+6)
341 #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
342 #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
343 #define NS_WAITING (NS_MEDIA_EVENT_START+9)
344 #define NS_PLAYING (NS_MEDIA_EVENT_START+10)
345 #define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
346 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
347 #define NS_SEEKING (NS_MEDIA_EVENT_START+13)
348 #define NS_SEEKED (NS_MEDIA_EVENT_START+14)
349 #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
350 #define NS_ENDED (NS_MEDIA_EVENT_START+16)
351 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
352 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
353 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
354 #define NS_MOZAUDIOAVAILABLE (NS_MEDIA_EVENT_START+20)
356 // paint notification events
357 #define NS_NOTIFYPAINT_START 3400
358 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
360 // Simple gesture events
361 #define NS_SIMPLE_GESTURE_EVENT_START 3500
362 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
363 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
364 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
365 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
366 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
367 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
368 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
369 #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
370 #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
371 #define NS_SIMPLE_GESTURE_EDGEUI (NS_SIMPLE_GESTURE_EVENT_START+9)
373 // These are used to send native events to plugins.
374 #define NS_PLUGIN_EVENT_START 3600
375 #define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START)
376 #define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1)
378 // Events to manipulate selection (nsSelectionEvent)
379 #define NS_SELECTION_EVENT_START 3700
380 // Clear any previous selection and set the given range as the selection
381 #define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
383 // Events of commands for the contents
384 #define NS_CONTENT_COMMAND_EVENT_START 3800
385 #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
386 #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
387 #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
388 #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
389 #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
390 #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
391 #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
392 // NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the
393 // currently focused content or latest DOM selection. This would normally be
394 // the same element scrolled by keyboard scroll commands, except that this event
395 // will scroll an element scrollable in either direction. I.e., if the nearest
396 // scrollable ancestor element can only be scrolled vertically, and horizontal
397 // scrolling is requested using this event, no scrolling will occur.
398 #define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7)
400 // Event to gesture notification
401 #define NS_GESTURENOTIFY_EVENT_START 3900
403 #define NS_ORIENTATION_EVENT 4000
405 #define NS_SCROLLAREA_EVENT_START 4100
406 #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
408 #define NS_TRANSITION_EVENT_START 4200
409 #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
411 #define NS_ANIMATION_EVENT_START 4250
412 #define NS_ANIMATION_START (NS_ANIMATION_EVENT_START)
413 #define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1)
414 #define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2)
416 #define NS_SMIL_TIME_EVENT_START 4300
417 #define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START)
418 #define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1)
419 #define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
421 // script notification events
422 #define NS_NOTIFYSCRIPT_START 4500
423 #define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
424 #define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1)
426 #define NS_PRINT_EVENT_START 4600
427 #define NS_BEFOREPRINT (NS_PRINT_EVENT_START)
428 #define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1)
430 #define NS_MESSAGE_EVENT_START 4700
431 #define NS_MESSAGE (NS_MESSAGE_EVENT_START)
433 // Open and close events
434 #define NS_OPENCLOSE_EVENT_START 4800
435 #define NS_OPEN (NS_OPENCLOSE_EVENT_START)
436 #define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1)
438 // Device motion and orientation
439 #define NS_DEVICE_ORIENTATION_START 4900
440 #define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START)
441 #define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1)
442 #define NS_DEVICE_PROXIMITY (NS_DEVICE_ORIENTATION_START+2)
443 #define NS_USER_PROXIMITY (NS_DEVICE_ORIENTATION_START+3)
444 #define NS_DEVICE_LIGHT (NS_DEVICE_ORIENTATION_START+4)
446 #define NS_SHOW_EVENT 5000
448 // Fullscreen DOM API
449 #define NS_FULL_SCREEN_START 5100
450 #define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START)
451 #define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1)
453 #define NS_TOUCH_EVENT_START 5200
454 #define NS_TOUCH_START (NS_TOUCH_EVENT_START)
455 #define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1)
456 #define NS_TOUCH_END (NS_TOUCH_EVENT_START+2)
457 #define NS_TOUCH_ENTER (NS_TOUCH_EVENT_START+3)
458 #define NS_TOUCH_LEAVE (NS_TOUCH_EVENT_START+4)
459 #define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+5)
461 // Pointerlock DOM API
462 #define NS_POINTERLOCK_START 5300
463 #define NS_POINTERLOCKCHANGE (NS_POINTERLOCK_START)
464 #define NS_POINTERLOCKERROR (NS_POINTERLOCK_START + 1)
466 #define NS_WHEEL_EVENT_START 5400
467 #define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START)
469 //System time is changed
470 #define NS_MOZ_TIME_CHANGE_EVENT 5500
472 // Network packet events.
473 #define NS_NETWORK_EVENT_START 5600
474 #define NS_NETWORK_UPLOAD_EVENT (NS_NETWORK_EVENT_START + 1)
475 #define NS_NETWORK_DOWNLOAD_EVENT (NS_NETWORK_EVENT_START + 2)
478 * Return status for event processors, nsEventStatus, is defined in
479 * nsEvent.h.
483 * different types of (top-level) window z-level positioning
485 enum nsWindowZ {
486 nsWindowZTop = 0, // on top
487 nsWindowZBottom, // on bottom
488 nsWindowZRelative // just below some specified widget
492 * General event
495 class nsEvent
497 protected:
498 nsEvent(bool isTrusted, uint32_t msg, uint8_t structType)
499 : eventStructType(structType),
500 message(msg),
501 refPoint(0, 0),
502 lastRefPoint(0, 0),
503 time(0),
504 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
505 userType(0)
507 MOZ_COUNT_CTOR(nsEvent);
510 nsEvent()
512 MOZ_COUNT_CTOR(nsEvent);
515 public:
516 nsEvent(bool isTrusted, uint32_t msg)
517 : eventStructType(NS_EVENT),
518 message(msg),
519 refPoint(0, 0),
520 lastRefPoint(0, 0),
521 time(0),
522 flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
523 userType(0)
525 MOZ_COUNT_CTOR(nsEvent);
528 ~nsEvent()
530 MOZ_COUNT_DTOR(nsEvent);
533 nsEvent(const nsEvent& aOther)
535 MOZ_COUNT_CTOR(nsEvent);
536 *this = aOther;
539 // See event struct types
540 uint8_t eventStructType;
541 // See GUI MESSAGES,
542 uint32_t message;
543 // Relative to the widget of the event, or if there is no widget then it is
544 // in screen coordinates. Not modified by layout code.
545 nsIntPoint refPoint;
546 // The previous refPoint, if known, used to calculate mouse movement deltas.
547 nsIntPoint lastRefPoint;
548 // Elapsed time, in milliseconds, from a platform-specific zero time
549 // to the time the message was created
550 uint64_t time;
551 // Flags to hold event flow stage and capture/bubble cancellation
552 // status. This is used also to indicate whether the event is trusted.
553 uint32_t flags;
554 // Additional type info for user defined events
555 nsCOMPtr<nsIAtom> userType;
556 // Event targets, needed by DOM Events
557 nsCOMPtr<nsIDOMEventTarget> target;
558 nsCOMPtr<nsIDOMEventTarget> currentTarget;
559 nsCOMPtr<nsIDOMEventTarget> originalTarget;
563 * General graphic user interface event
566 class nsGUIEvent : public nsEvent
568 protected:
569 nsGUIEvent(bool isTrusted, uint32_t msg, nsIWidget *w, uint8_t structType)
570 : nsEvent(isTrusted, msg, structType),
571 widget(w), pluginEvent(nullptr)
575 nsGUIEvent()
576 : pluginEvent(nullptr)
580 public:
581 nsGUIEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
582 : nsEvent(isTrusted, msg, NS_GUI_EVENT),
583 widget(w), pluginEvent(nullptr)
587 /// Originator of the event
588 nsCOMPtr<nsIWidget> widget;
590 /// Event for NPAPI plugin
591 void* pluginEvent;
595 * Script error event
598 class nsScriptErrorEvent : public nsEvent
600 public:
601 nsScriptErrorEvent(bool isTrusted, uint32_t msg)
602 : nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
603 lineNr(0), errorMsg(nullptr), fileName(nullptr)
607 int32_t lineNr;
608 const PRUnichar* errorMsg;
609 const PRUnichar* fileName;
613 * Scrollbar event
616 class nsScrollbarEvent : public nsGUIEvent
618 public:
619 nsScrollbarEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
620 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
621 position(0)
625 /// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
626 uint32_t position;
629 class nsScrollPortEvent : public nsGUIEvent
631 public:
632 enum orientType {
633 vertical = 0,
634 horizontal = 1,
635 both = 2
638 nsScrollPortEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
639 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
640 orient(vertical)
644 orientType orient;
647 class nsScrollAreaEvent : public nsGUIEvent
649 public:
650 nsScrollAreaEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
651 : nsGUIEvent(isTrusted, msg, w, NS_SCROLLAREA_EVENT)
655 nsRect mArea;
658 class nsInputEvent : public nsGUIEvent
660 protected:
661 nsInputEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
662 uint8_t structType)
663 : nsGUIEvent(isTrusted, msg, w, structType),
664 modifiers(0)
668 nsInputEvent()
672 public:
673 nsInputEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
674 : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
675 modifiers(0)
679 // true indicates the shift key is down
680 bool IsShift() const
682 return ((modifiers & mozilla::widget::MODIFIER_SHIFT) != 0);
684 // true indicates the control key is down
685 bool IsControl() const
687 return ((modifiers & mozilla::widget::MODIFIER_CONTROL) != 0);
689 // true indicates the alt key is down
690 bool IsAlt() const
692 return ((modifiers & mozilla::widget::MODIFIER_ALT) != 0);
694 // true indicates the meta key is down (or, on Mac, the Command key)
695 bool IsMeta() const
697 return ((modifiers & mozilla::widget::MODIFIER_META) != 0);
699 // true indicates the win key is down on Windows. Or the Super or Hyper key
700 // is down on Linux.
701 bool IsOS() const
703 return ((modifiers & mozilla::widget::MODIFIER_OS) != 0);
705 // true indicates the alt graph key is down
706 // NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah()
707 // return true.
708 bool IsAltGraph() const
710 return ((modifiers & mozilla::widget::MODIFIER_ALTGRAPH) != 0);
712 // true indeicates the CapLock LED is turn on.
713 bool IsCapsLocked() const
715 return ((modifiers & mozilla::widget::MODIFIER_CAPSLOCK) != 0);
717 // true indeicates the NumLock LED is turn on.
718 bool IsNumLocked() const
720 return ((modifiers & mozilla::widget::MODIFIER_NUMLOCK) != 0);
722 // true indeicates the ScrollLock LED is turn on.
723 bool IsScrollLocked() const
725 return ((modifiers & mozilla::widget::MODIFIER_SCROLLLOCK) != 0);
728 // true indeicates the Fn key is down, but this is not supported by native
729 // key event on any platform.
730 bool IsFn() const
732 return ((modifiers & mozilla::widget::MODIFIER_FN) != 0);
734 // true indeicates the ScrollLock LED is turn on.
735 bool IsSymbolLocked() const
737 return ((modifiers & mozilla::widget::MODIFIER_SYMBOLLOCK) != 0);
740 void InitBasicModifiers(bool aCtrlKey,
741 bool aAltKey,
742 bool aShiftKey,
743 bool aMetaKey)
745 modifiers = 0;
746 if (aCtrlKey) {
747 modifiers |= mozilla::widget::MODIFIER_CONTROL;
749 if (aAltKey) {
750 modifiers |= mozilla::widget::MODIFIER_ALT;
752 if (aShiftKey) {
753 modifiers |= mozilla::widget::MODIFIER_SHIFT;
755 if (aMetaKey) {
756 modifiers |= mozilla::widget::MODIFIER_META;
760 mozilla::widget::Modifiers modifiers;
764 * Mouse event
767 class nsMouseEvent_base : public nsInputEvent
769 private:
770 friend class mozilla::dom::PBrowserParent;
771 friend class mozilla::dom::PBrowserChild;
773 public:
775 nsMouseEvent_base()
779 nsMouseEvent_base(bool isTrusted, uint32_t msg, nsIWidget *w, uint8_t type)
780 : nsInputEvent(isTrusted, msg, w, type), button(0), buttons(0),
781 pressure(0), inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
783 /// The possible related target
784 nsCOMPtr<nsISupports> relatedTarget;
786 int16_t button;
787 int16_t buttons;
789 // Finger or touch pressure of event
790 // ranges between 0.0 and 1.0
791 float pressure;
793 // Possible values at nsIDOMMouseEvent
794 uint16_t inputSource;
797 class nsMouseEvent : public nsMouseEvent_base
799 private:
800 friend class mozilla::dom::PBrowserParent;
801 friend class mozilla::dom::PBrowserChild;
803 public:
804 enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
805 enum buttonsFlag { eLeftButtonFlag = 0x01,
806 eRightButtonFlag = 0x02,
807 eMiddleButtonFlag = 0x04,
808 // typicall, "back" button being left side of 5-button
809 // mice, see "buttons" attribute document of DOM3 Events.
810 e4thButtonFlag = 0x08,
811 // typicall, "forward" button being right side of 5-button
812 // mice, see "buttons" attribute document of DOM3 Events.
813 e5thButtonFlag = 0x10 };
814 enum reasonType { eReal, eSynthesized };
815 enum contextType { eNormal, eContextMenuKey };
816 enum exitType { eChild, eTopLevel };
818 nsMouseEvent()
822 protected:
823 nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
824 uint8_t structType, reasonType aReason)
825 : nsMouseEvent_base(isTrusted, msg, w, structType),
826 acceptActivation(false), ignoreRootScrollFrame(false),
827 reason(aReason), context(eNormal), exit(eChild), clickCount(0)
829 switch (msg) {
830 case NS_MOUSE_MOVE:
831 flags |= NS_EVENT_FLAG_CANT_CANCEL;
832 break;
833 case NS_MOUSEENTER:
834 case NS_MOUSELEAVE:
835 flags |= (NS_EVENT_FLAG_CANT_CANCEL & NS_EVENT_FLAG_CANT_BUBBLE);
836 break;
837 default:
838 break;
842 public:
844 nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
845 reasonType aReason, contextType aContext = eNormal)
846 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
847 acceptActivation(false), ignoreRootScrollFrame(false),
848 reason(aReason), context(aContext), exit(eChild), clickCount(0)
850 switch (msg) {
851 case NS_MOUSE_MOVE:
852 flags |= NS_EVENT_FLAG_CANT_CANCEL;
853 break;
854 case NS_MOUSEENTER:
855 case NS_MOUSELEAVE:
856 flags |= (NS_EVENT_FLAG_CANT_CANCEL | NS_EVENT_FLAG_CANT_BUBBLE);
857 break;
858 case NS_CONTEXTMENU:
859 button = (context == eNormal) ? eRightButton : eLeftButton;
860 break;
861 default:
862 break;
866 #ifdef DEBUG
867 ~nsMouseEvent() {
868 NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
869 button ==
870 ((context == eNormal) ? eRightButton : eLeftButton),
871 "Wrong button set to NS_CONTEXTMENU event?");
873 #endif
875 /// Special return code for MOUSE_ACTIVATE to signal
876 /// if the target accepts activation (1), or denies it (0)
877 bool acceptActivation;
878 // Whether the event should ignore scroll frame bounds
879 // during dispatch.
880 bool ignoreRootScrollFrame;
882 reasonType reason : 4;
883 contextType context : 4;
884 exitType exit;
886 /// The number of mouse clicks
887 uint32_t clickCount;
891 * Drag event
894 class nsDragEvent : public nsMouseEvent
896 public:
897 nsDragEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
898 : nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
899 userCancelled(false)
901 if (msg == NS_DRAGDROP_EXIT_SYNTH ||
902 msg == NS_DRAGDROP_LEAVE_SYNTH ||
903 msg == NS_DRAGDROP_END) {
904 flags |= NS_EVENT_FLAG_CANT_CANCEL;
908 nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
909 bool userCancelled;
913 * Keyboard event
916 struct nsAlternativeCharCode {
917 nsAlternativeCharCode(uint32_t aUnshiftedCharCode,
918 uint32_t aShiftedCharCode) :
919 mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
922 uint32_t mUnshiftedCharCode;
923 uint32_t mShiftedCharCode;
926 class nsKeyEvent : public nsInputEvent
928 private:
929 friend class mozilla::dom::PBrowserParent;
930 friend class mozilla::dom::PBrowserChild;
932 public:
933 nsKeyEvent()
937 nsKeyEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
938 : nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
939 keyCode(0), charCode(0),
940 location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD), isChar(0)
944 /// see NS_VK codes
945 uint32_t keyCode;
946 /// OS translated Unicode char
947 uint32_t charCode;
948 // One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
949 uint32_t location;
950 // OS translated Unicode chars which are used for accesskey and accelkey
951 // handling. The handlers will try from first character to last character.
952 nsTArray<nsAlternativeCharCode> alternativeCharCodes;
953 // indicates whether the event signifies a printable character
954 bool isChar;
958 * IME Related Events
961 struct nsTextRangeStyle
963 enum {
964 LINESTYLE_NONE = NS_STYLE_TEXT_DECORATION_STYLE_NONE,
965 LINESTYLE_SOLID = NS_STYLE_TEXT_DECORATION_STYLE_SOLID,
966 LINESTYLE_DOTTED = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED,
967 LINESTYLE_DASHED = NS_STYLE_TEXT_DECORATION_STYLE_DASHED,
968 LINESTYLE_DOUBLE = NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE,
969 LINESTYLE_WAVY = NS_STYLE_TEXT_DECORATION_STYLE_WAVY
972 enum {
973 DEFINED_NONE = 0x00,
974 DEFINED_LINESTYLE = 0x01,
975 DEFINED_FOREGROUND_COLOR = 0x02,
976 DEFINED_BACKGROUND_COLOR = 0x04,
977 DEFINED_UNDERLINE_COLOR = 0x08
980 // Initialize all members, because nsTextRange instances may be compared by
981 // memcomp.
982 nsTextRangeStyle()
984 Clear();
987 void Clear()
989 mDefinedStyles = DEFINED_NONE;
990 mLineStyle = LINESTYLE_NONE;
991 mIsBoldLine = false;
992 mForegroundColor = mBackgroundColor = mUnderlineColor = NS_RGBA(0, 0, 0, 0);
995 bool IsDefined() const { return mDefinedStyles != DEFINED_NONE; }
997 bool IsLineStyleDefined() const
999 return (mDefinedStyles & DEFINED_LINESTYLE) != 0;
1002 bool IsForegroundColorDefined() const
1004 return (mDefinedStyles & DEFINED_FOREGROUND_COLOR) != 0;
1007 bool IsBackgroundColorDefined() const
1009 return (mDefinedStyles & DEFINED_BACKGROUND_COLOR) != 0;
1012 bool IsUnderlineColorDefined() const
1014 return (mDefinedStyles & DEFINED_UNDERLINE_COLOR) != 0;
1017 bool IsNoChangeStyle() const
1019 return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
1020 IsLineStyleDefined() && mLineStyle == LINESTYLE_NONE;
1023 bool Equals(const nsTextRangeStyle& aOther)
1025 if (mDefinedStyles != aOther.mDefinedStyles)
1026 return false;
1027 if (IsLineStyleDefined() && (mLineStyle != aOther.mLineStyle ||
1028 !mIsBoldLine != !aOther.mIsBoldLine))
1029 return false;
1030 if (IsForegroundColorDefined() &&
1031 (mForegroundColor != aOther.mForegroundColor))
1032 return false;
1033 if (IsBackgroundColorDefined() &&
1034 (mBackgroundColor != aOther.mBackgroundColor))
1035 return false;
1036 if (IsUnderlineColorDefined() &&
1037 (mUnderlineColor != aOther.mUnderlineColor))
1038 return false;
1039 return true;
1042 bool operator !=(const nsTextRangeStyle &aOther)
1044 return !Equals(aOther);
1047 bool operator ==(const nsTextRangeStyle &aOther)
1049 return Equals(aOther);
1052 uint8_t mDefinedStyles;
1053 uint8_t mLineStyle; // DEFINED_LINESTYLE
1055 bool mIsBoldLine; // DEFINED_LINESTYLE
1057 nscolor mForegroundColor; // DEFINED_FOREGROUND_COLOR
1058 nscolor mBackgroundColor; // DEFINED_BACKGROUND_COLOR
1059 nscolor mUnderlineColor; // DEFINED_UNDERLINE_COLOR
1062 struct nsTextRange
1064 nsTextRange()
1065 : mStartOffset(0), mEndOffset(0), mRangeType(0)
1069 uint32_t mStartOffset;
1070 uint32_t mEndOffset;
1071 uint32_t mRangeType;
1073 nsTextRangeStyle mRangeStyle;
1076 typedef nsTextRange* nsTextRangeArray;
1078 class nsTextEvent : public nsInputEvent
1080 private:
1081 friend class mozilla::dom::PBrowserParent;
1082 friend class mozilla::dom::PBrowserChild;
1083 friend class mozilla::plugins::PPluginInstanceChild;
1085 nsTextEvent()
1089 public:
1090 uint32_t seqno;
1092 public:
1093 nsTextEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
1094 : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
1095 rangeCount(0), rangeArray(nullptr), isChar(false)
1099 nsString theText;
1100 uint32_t rangeCount;
1101 // Note that the range array may not specify a caret position; in that
1102 // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
1103 // array.
1104 nsTextRangeArray rangeArray;
1105 bool isChar;
1108 class nsCompositionEvent : public nsGUIEvent
1110 private:
1111 friend class mozilla::dom::PBrowserParent;
1112 friend class mozilla::dom::PBrowserChild;
1114 nsCompositionEvent()
1118 public:
1119 uint32_t seqno;
1121 public:
1122 nsCompositionEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
1123 : nsGUIEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
1125 // XXX compositionstart is cancelable in draft of DOM3 Events.
1126 // However, it doesn't make sense for us, we cannot cancel composition
1127 // when we send compositionstart event.
1128 flags |= NS_EVENT_FLAG_CANT_CANCEL;
1131 nsString data;
1135 * nsMouseScrollEvent is used for legacy DOM mouse scroll events, i.e.,
1136 * DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
1137 * by ESM even if widget dispatches them. Use new widget::WheelEvent instead.
1140 class nsMouseScrollEvent : public nsMouseEvent_base
1142 private:
1143 nsMouseScrollEvent()
1147 public:
1148 nsMouseScrollEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
1149 : nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
1150 delta(0), isHorizontal(false)
1154 int32_t delta;
1155 bool isHorizontal;
1159 * WheelEvent is used only for DOM Level 3 WheelEvent (dom::DOMWheelEvent).
1162 namespace mozilla {
1163 namespace widget {
1165 class WheelEvent : public nsMouseEvent_base
1167 private:
1168 friend class mozilla::dom::PBrowserParent;
1169 friend class mozilla::dom::PBrowserChild;
1171 WheelEvent()
1175 public:
1176 WheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
1177 nsMouseEvent_base(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
1178 deltaX(0.0), deltaY(0.0), deltaZ(0.0),
1179 deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
1180 customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
1181 lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
1182 overflowDeltaX(0.0), overflowDeltaY(0.0)
1186 // NOTE: deltaX, deltaY and deltaZ may be customized by
1187 // mousewheel.*.delta_multiplier_* prefs which are applied by
1188 // nsEventStateManager. So, after widget dispatches this event,
1189 // these delta values may have different values than before.
1190 double deltaX;
1191 double deltaY;
1192 double deltaZ;
1194 // Should be one of nsIDOMWheelEvent::DOM_DELTA_*
1195 uint32_t deltaMode;
1197 // Following members are for internal use only, not for DOM event.
1199 // If the delta values are computed from prefs, this value is true.
1200 // Otherwise, i.e., they are computed from native events, false.
1201 bool customizedByUserPrefs;
1203 // true if the event is caused by momentum.
1204 bool isMomentum;
1206 // If device event handlers don't know when they should set lineOrPageDeltaX
1207 // and lineOrPageDeltaY, this is true. Otherwise, false.
1208 // If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events
1209 // when accumulated pixel delta values reach a line height.
1210 bool isPixelOnlyDevice;
1212 // If widget sets lineOrPageDelta, nsEventStateManager will dispatch
1213 // NS_MOUSE_SCROLL event for compatibility. Note that the delta value means
1214 // pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines.
1215 int32_t lineOrPageDeltaX;
1216 int32_t lineOrPageDeltaY;
1218 // When the default action for an wheel event is moving history or zooming,
1219 // need to chose a delta value for doing it.
1220 int32_t GetPreferredIntDelta()
1222 if (!lineOrPageDeltaX && !lineOrPageDeltaY) {
1223 return 0;
1225 if (lineOrPageDeltaY && !lineOrPageDeltaX) {
1226 return lineOrPageDeltaY;
1228 if (lineOrPageDeltaX && !lineOrPageDeltaY) {
1229 return lineOrPageDeltaX;
1231 if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
1232 (lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
1233 return 0; // We cannot guess the answer in this case.
1235 return (NS_ABS(lineOrPageDeltaX) > NS_ABS(lineOrPageDeltaY)) ?
1236 lineOrPageDeltaX : lineOrPageDeltaY;
1239 // Scroll type
1240 // The default value is SCROLL_DEFAULT, which means nsEventStateManager will
1241 // select preferred scroll type automatically.
1242 enum ScrollType {
1243 SCROLL_DEFAULT,
1244 SCROLL_SYNCHRONOUSLY,
1245 SCROLL_ASYNCHRONOUSELY,
1246 SCROLL_SMOOTHLY
1248 ScrollType scrollType;
1250 // overflowed delta values for scroll, these values are set by
1251 // nsEventStateManger. If the default action of the wheel event isn't scroll,
1252 // these values always zero. Otherwise, remaning delta values which are
1253 // not used by scroll are set.
1254 // NOTE: deltaX, deltaY and deltaZ may be modified by nsEventStateManager.
1255 // However, overflowDeltaX and overflowDeltaY indicate unused original
1256 // delta values which are not applied the delta_multiplier prefs.
1257 // So, if widget wanted to know the actual direction to be scrolled,
1258 // it would need to check the deltaX and deltaY.
1259 double overflowDeltaX;
1260 double overflowDeltaY;
1263 } // namespace widget
1264 } // namespace mozilla
1267 * Gesture Notify Event:
1269 * This event is the first event generated when the user touches
1270 * the screen with a finger, and it's meant to decide what kind
1271 * of action we'll use for that touch interaction.
1273 * The event is dispatched to the layout and based on what is underneath
1274 * the initial contact point it's then decided if we should pan
1275 * (finger scrolling) or drag the target element.
1277 class nsGestureNotifyEvent : public nsGUIEvent
1279 public:
1280 enum ePanDirection {
1281 ePanNone,
1282 ePanVertical,
1283 ePanHorizontal,
1284 ePanBoth
1287 ePanDirection panDirection;
1288 bool displayPanFeedback;
1290 nsGestureNotifyEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget):
1291 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_GESTURENOTIFY_EVENT),
1292 panDirection(ePanNone),
1293 displayPanFeedback(false)
1298 class nsQueryContentEvent : public nsGUIEvent
1300 private:
1301 friend class mozilla::dom::PBrowserParent;
1302 friend class mozilla::dom::PBrowserChild;
1304 nsQueryContentEvent()
1306 mReply.mContentsRoot = nullptr;
1307 mReply.mFocusedWidget = nullptr;
1310 public:
1311 nsQueryContentEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget) :
1312 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
1313 mSucceeded(false), mWasAsync(false)
1317 void InitForQueryTextContent(uint32_t aOffset, uint32_t aLength)
1319 NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
1320 "wrong initializer is called");
1321 mInput.mOffset = aOffset;
1322 mInput.mLength = aLength;
1325 void InitForQueryCaretRect(uint32_t aOffset)
1327 NS_ASSERTION(message == NS_QUERY_CARET_RECT,
1328 "wrong initializer is called");
1329 mInput.mOffset = aOffset;
1332 void InitForQueryTextRect(uint32_t aOffset, uint32_t aLength)
1334 NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
1335 "wrong initializer is called");
1336 mInput.mOffset = aOffset;
1337 mInput.mLength = aLength;
1340 void InitForQueryDOMWidgetHittest(nsIntPoint& aPoint)
1342 NS_ASSERTION(message == NS_QUERY_DOM_WIDGET_HITTEST,
1343 "wrong initializer is called");
1344 refPoint = aPoint;
1347 uint32_t GetSelectionStart(void) const
1349 NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1350 "not querying selection");
1351 return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
1354 uint32_t GetSelectionEnd(void) const
1356 NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
1357 "not querying selection");
1358 return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
1361 bool mSucceeded;
1362 bool mWasAsync;
1363 struct {
1364 uint32_t mOffset;
1365 uint32_t mLength;
1366 } mInput;
1367 struct {
1368 void* mContentsRoot;
1369 uint32_t mOffset;
1370 nsString mString;
1371 nsIntRect mRect; // Finally, the coordinates is system coordinates.
1372 // The return widget has the caret. This is set at all query events.
1373 nsIWidget* mFocusedWidget;
1374 bool mReversed; // true if selection is reversed (end < start)
1375 bool mHasSelection; // true if the selection exists
1376 bool mWidgetIsHit; // true if DOM element under mouse belongs to widget
1377 // used by NS_QUERY_SELECTION_AS_TRANSFERABLE
1378 nsCOMPtr<nsITransferable> mTransferable;
1379 } mReply;
1381 enum {
1382 NOT_FOUND = UINT32_MAX
1385 // values of mComputedScrollAction
1386 enum {
1387 SCROLL_ACTION_NONE,
1388 SCROLL_ACTION_LINE,
1389 SCROLL_ACTION_PAGE
1393 class nsFocusEvent : public nsEvent
1395 public:
1396 nsFocusEvent(bool isTrusted, uint32_t msg)
1397 : nsEvent(isTrusted, msg, NS_FOCUS_EVENT),
1398 fromRaise(false),
1399 isRefocus(false)
1403 bool fromRaise;
1404 bool isRefocus;
1407 class nsSelectionEvent : public nsGUIEvent
1409 private:
1410 friend class mozilla::dom::PBrowserParent;
1411 friend class mozilla::dom::PBrowserChild;
1413 nsSelectionEvent()
1417 public:
1418 uint32_t seqno;
1420 public:
1421 nsSelectionEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget) :
1422 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_SELECTION_EVENT),
1423 mExpandToClusterBoundary(true), mSucceeded(false)
1427 uint32_t mOffset; // start offset of selection
1428 uint32_t mLength; // length of selection
1429 bool mReversed; // selection "anchor" should be in front
1430 bool mExpandToClusterBoundary; // cluster-based or character-based
1431 bool mSucceeded;
1434 class nsContentCommandEvent : public nsGUIEvent
1436 public:
1437 nsContentCommandEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget,
1438 bool aOnlyEnabledCheck = false) :
1439 nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
1440 mOnlyEnabledCheck(bool(aOnlyEnabledCheck)),
1441 mSucceeded(false), mIsEnabled(false)
1445 // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
1446 nsCOMPtr<nsITransferable> mTransferable; // [in]
1448 // NS_CONTENT_COMMAND_SCROLL
1449 // for mScroll.mUnit
1450 enum {
1451 eCmdScrollUnit_Line,
1452 eCmdScrollUnit_Page,
1453 eCmdScrollUnit_Whole
1456 struct ScrollInfo {
1457 ScrollInfo() :
1458 mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
1462 int32_t mAmount; // [in]
1463 uint8_t mUnit; // [in]
1464 bool mIsHorizontal; // [in]
1465 } mScroll;
1467 bool mOnlyEnabledCheck; // [in]
1469 bool mSucceeded; // [out]
1470 bool mIsEnabled; // [out]
1473 class nsTouchEvent : public nsInputEvent
1475 public:
1476 nsTouchEvent()
1479 nsTouchEvent(bool isTrusted, nsTouchEvent *aEvent)
1480 : nsInputEvent(isTrusted,
1481 aEvent->message,
1482 aEvent->widget,
1483 NS_TOUCH_EVENT)
1485 modifiers = aEvent->modifiers;
1486 time = aEvent->time;
1487 touches.AppendElements(aEvent->touches);
1488 MOZ_COUNT_CTOR(nsTouchEvent);
1490 nsTouchEvent(bool isTrusted, uint32_t msg, nsIWidget* w)
1491 : nsInputEvent(isTrusted, msg, w, NS_TOUCH_EVENT)
1493 MOZ_COUNT_CTOR(nsTouchEvent);
1495 ~nsTouchEvent()
1497 MOZ_COUNT_DTOR(nsTouchEvent);
1500 nsTArray<nsCOMPtr<nsIDOMTouch> > touches;
1504 * Form event
1506 * We hold the originating form control for form submit and reset events.
1507 * originator is a weak pointer (does not hold a strong reference).
1510 class nsFormEvent : public nsEvent
1512 public:
1513 nsFormEvent(bool isTrusted, uint32_t msg)
1514 : nsEvent(isTrusted, msg, NS_FORM_EVENT),
1515 originator(nullptr)
1519 nsIContent *originator;
1523 * Command event
1525 * Custom commands for example from the operating system.
1528 class nsCommandEvent : public nsGUIEvent
1530 public:
1531 nsCommandEvent(bool isTrusted, nsIAtom* aEventType,
1532 nsIAtom* aCommand, nsIWidget* w)
1533 : nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
1535 userType = aEventType;
1536 command = aCommand;
1539 nsCOMPtr<nsIAtom> command;
1543 * DOM UIEvent
1545 class nsUIEvent : public nsEvent
1547 public:
1548 nsUIEvent(bool isTrusted, uint32_t msg, int32_t d)
1549 : nsEvent(isTrusted, msg, NS_UI_EVENT),
1550 detail(d)
1554 int32_t detail;
1558 * Simple gesture event
1560 class nsSimpleGestureEvent : public nsMouseEvent_base
1562 public:
1563 nsSimpleGestureEvent(bool isTrusted, uint32_t msg, nsIWidget* w,
1564 uint32_t directionArg, double deltaArg)
1565 : nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
1566 direction(directionArg), delta(deltaArg), clickCount(0)
1570 nsSimpleGestureEvent(const nsSimpleGestureEvent& other)
1571 : nsMouseEvent_base((other.flags & NS_EVENT_FLAG_TRUSTED) != 0,
1572 other.message, other.widget, NS_SIMPLE_GESTURE_EVENT),
1573 direction(other.direction), delta(other.delta), clickCount(0)
1577 uint32_t direction; // See nsIDOMSimpleGestureEvent for values
1578 double delta; // Delta for magnify and rotate events
1579 uint32_t clickCount; // The number of taps for tap events
1582 class nsTransitionEvent : public nsEvent
1584 public:
1585 nsTransitionEvent(bool isTrusted, uint32_t msg,
1586 const nsString &propertyNameArg, float elapsedTimeArg)
1587 : nsEvent(isTrusted, msg, NS_TRANSITION_EVENT),
1588 propertyName(propertyNameArg), elapsedTime(elapsedTimeArg)
1592 nsString propertyName;
1593 float elapsedTime;
1596 class nsAnimationEvent : public nsEvent
1598 public:
1599 nsAnimationEvent(bool isTrusted, uint32_t msg,
1600 const nsString &animationNameArg, float elapsedTimeArg)
1601 : nsEvent(isTrusted, msg, NS_ANIMATION_EVENT),
1602 animationName(animationNameArg), elapsedTime(elapsedTimeArg)
1606 nsString animationName;
1607 float elapsedTime;
1611 * Native event pluginEvent for plugins.
1614 class nsPluginEvent : public nsGUIEvent
1616 public:
1617 nsPluginEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
1618 : nsGUIEvent(isTrusted, msg, w, NS_PLUGIN_EVENT),
1619 retargetToFocusedDocument(false)
1623 // If TRUE, this event needs to be retargeted to focused document.
1624 // Otherwise, never retargeted.
1625 // Defaults to false.
1626 bool retargetToFocusedDocument;
1630 * Event status for D&D Event
1632 enum nsDragDropEventStatus {
1633 /// The event is a enter
1634 nsDragDropEventStatus_eDragEntered,
1635 /// The event is exit
1636 nsDragDropEventStatus_eDragExited,
1637 /// The event is drop
1638 nsDragDropEventStatus_eDrop
1641 #define NS_IS_INPUT_EVENT(evnt) \
1642 (((evnt)->eventStructType == NS_INPUT_EVENT) || \
1643 ((evnt)->eventStructType == NS_MOUSE_EVENT) || \
1644 ((evnt)->eventStructType == NS_KEY_EVENT) || \
1645 ((evnt)->eventStructType == NS_TEXT_EVENT) || \
1646 ((evnt)->eventStructType == NS_TOUCH_EVENT) || \
1647 ((evnt)->eventStructType == NS_DRAG_EVENT) || \
1648 ((evnt)->eventStructType == NS_MOUSE_SCROLL_EVENT) || \
1649 ((evnt)->eventStructType == NS_SIMPLE_GESTURE_EVENT))
1651 #define NS_IS_MOUSE_EVENT(evnt) \
1652 (((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
1653 ((evnt)->message == NS_MOUSE_BUTTON_UP) || \
1654 ((evnt)->message == NS_MOUSE_CLICK) || \
1655 ((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
1656 ((evnt)->message == NS_MOUSE_ENTER) || \
1657 ((evnt)->message == NS_MOUSE_EXIT) || \
1658 ((evnt)->message == NS_MOUSE_ACTIVATE) || \
1659 ((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
1660 ((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
1661 ((evnt)->message == NS_MOUSE_MOZHITTEST) || \
1662 ((evnt)->message == NS_MOUSE_MOVE))
1664 #define NS_IS_MOUSE_EVENT_STRUCT(evnt) \
1665 ((evnt)->eventStructType == NS_MOUSE_EVENT || \
1666 (evnt)->eventStructType == NS_DRAG_EVENT)
1668 #define NS_IS_MOUSE_LEFT_CLICK(evnt) \
1669 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1670 (evnt)->message == NS_MOUSE_CLICK && \
1671 static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
1673 #define NS_IS_CONTEXT_MENU_KEY(evnt) \
1674 ((evnt)->eventStructType == NS_MOUSE_EVENT && \
1675 (evnt)->message == NS_CONTEXTMENU && \
1676 static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
1678 #define NS_IS_DRAG_EVENT(evnt) \
1679 (((evnt)->message == NS_DRAGDROP_ENTER) || \
1680 ((evnt)->message == NS_DRAGDROP_OVER) || \
1681 ((evnt)->message == NS_DRAGDROP_EXIT) || \
1682 ((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
1683 ((evnt)->message == NS_DRAGDROP_GESTURE) || \
1684 ((evnt)->message == NS_DRAGDROP_DRAG) || \
1685 ((evnt)->message == NS_DRAGDROP_END) || \
1686 ((evnt)->message == NS_DRAGDROP_START) || \
1687 ((evnt)->message == NS_DRAGDROP_DROP) || \
1688 ((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
1690 #define NS_IS_KEY_EVENT(evnt) \
1691 (((evnt)->message == NS_KEY_DOWN) || \
1692 ((evnt)->message == NS_KEY_PRESS) || \
1693 ((evnt)->message == NS_KEY_UP))
1695 #define NS_IS_IME_EVENT(evnt) \
1696 (((evnt)->message == NS_TEXT_TEXT) || \
1697 ((evnt)->message == NS_COMPOSITION_START) || \
1698 ((evnt)->message == NS_COMPOSITION_END) || \
1699 ((evnt)->message == NS_COMPOSITION_UPDATE))
1701 #define NS_IS_ACTIVATION_EVENT(evnt) \
1702 (((evnt)->message == NS_PLUGIN_ACTIVATE) || \
1703 ((evnt)->message == NS_PLUGIN_FOCUS))
1705 #define NS_IS_QUERY_CONTENT_EVENT(evnt) \
1706 ((evnt)->eventStructType == NS_QUERY_CONTENT_EVENT)
1708 #define NS_IS_SELECTION_EVENT(evnt) \
1709 (((evnt)->message == NS_SELECTION_SET))
1711 #define NS_IS_CONTENT_COMMAND_EVENT(evnt) \
1712 ((evnt)->eventStructType == NS_CONTENT_COMMAND_EVENT)
1714 #define NS_IS_PLUGIN_EVENT(evnt) \
1715 (((evnt)->message == NS_PLUGIN_INPUT_EVENT) || \
1716 ((evnt)->message == NS_PLUGIN_FOCUS_EVENT))
1718 #define NS_IS_RETARGETED_PLUGIN_EVENT(evnt) \
1719 (NS_IS_PLUGIN_EVENT(evnt) && \
1720 (static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
1722 #define NS_IS_NON_RETARGETED_PLUGIN_EVENT(evnt) \
1723 (NS_IS_PLUGIN_EVENT(evnt) && \
1724 !(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
1726 #define NS_IS_TRUSTED_EVENT(event) \
1727 (((event)->flags & NS_EVENT_FLAG_TRUSTED) != 0)
1729 // Mark an event as being dispatching.
1730 #define NS_MARK_EVENT_DISPATCH_STARTED(event) \
1731 (event)->flags |= NS_EVENT_FLAG_DISPATCHING;
1733 #define NS_IS_EVENT_IN_DISPATCH(event) \
1734 (((event)->flags & NS_EVENT_FLAG_DISPATCHING) != 0)
1736 // Mark an event as being done dispatching.
1737 #define NS_MARK_EVENT_DISPATCH_DONE(event) \
1738 NS_ASSERTION(NS_IS_EVENT_IN_DISPATCH(event), \
1739 "Event never got marked for dispatch!"); \
1740 (event)->flags &= ~NS_EVENT_FLAG_DISPATCHING; \
1741 (event)->flags |= NS_EVENT_DISPATCHED;
1743 // Be aware the query content events and the selection events are a part of IME
1744 // processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
1745 // cases, you should use NS_IS_IME_RELATED_EVENT instead.
1746 #define NS_IS_IME_RELATED_EVENT(evnt) \
1747 (NS_IS_IME_EVENT(evnt) || \
1748 NS_IS_QUERY_CONTENT_EVENT(evnt) || \
1749 NS_IS_SELECTION_EVENT(evnt))
1752 * Virtual key bindings for keyboard events.
1753 * These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
1754 * Really, it would be better if we phased out the NS_VK symbols altogether
1755 * in favor of the DOM ones, but at least this way they'll be in sync.
1758 enum {
1759 #define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode
1760 #include "nsVKList.h"
1761 #undef NS_DEFINE_VK
1764 // IME Constants -- keep in synch with nsIPrivateTextRange.h
1765 #define NS_TEXTRANGE_CARETPOSITION 0x01
1766 #define NS_TEXTRANGE_RAWINPUT 0x02
1767 #define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
1768 #define NS_TEXTRANGE_CONVERTEDTEXT 0x04
1769 #define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
1772 * Whether the event should be handled by the frame of the mouse cursor
1773 * position or not. When it should be handled there (e.g., the mouse events),
1774 * this returns TRUE.
1776 inline bool NS_IsEventUsingCoordinates(nsEvent* aEvent)
1778 return !NS_IS_KEY_EVENT(aEvent) && !NS_IS_IME_RELATED_EVENT(aEvent) &&
1779 !NS_IS_CONTEXT_MENU_KEY(aEvent) && !NS_IS_ACTIVATION_EVENT(aEvent) &&
1780 !NS_IS_PLUGIN_EVENT(aEvent) &&
1781 !NS_IS_CONTENT_COMMAND_EVENT(aEvent);
1785 * Whether the event should be handled by the focused DOM window in the
1786 * same top level window's or not. E.g., key events, IME related events
1787 * (including the query content events, they are used in IME transaction)
1788 * should be handled by the (last) focused window rather than the dispatched
1789 * window.
1791 * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
1792 * application level active DOM window which is on another top level window.
1793 * So, when the event is fired on a deactive window, the event is going to be
1794 * handled by the last focused DOM window in the last focused window.
1796 inline bool NS_IsEventTargetedAtFocusedWindow(nsEvent* aEvent)
1798 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
1799 NS_IS_CONTEXT_MENU_KEY(aEvent) ||
1800 NS_IS_CONTENT_COMMAND_EVENT(aEvent) ||
1801 NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
1805 * Whether the event should be handled by the focused content or not. E.g.,
1806 * key events, IME related events and other input events which are not handled
1807 * by the frame of the mouse cursor position.
1809 * NOTE: Even if this returns TRUE, the event isn't going to be handled by the
1810 * application level active DOM window which is on another top level window.
1811 * So, when the event is fired on a deactive window, the event is going to be
1812 * handled by the last focused DOM element of the last focused DOM window in
1813 * the last focused window.
1815 inline bool NS_IsEventTargetedAtFocusedContent(nsEvent* aEvent)
1817 return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
1818 NS_IS_CONTEXT_MENU_KEY(aEvent) ||
1819 NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
1823 * Whether the event should cause a DOM event.
1825 inline bool NS_IsAllowedToDispatchDOMEvent(nsEvent* aEvent)
1827 switch (aEvent->eventStructType) {
1828 case NS_MOUSE_EVENT:
1829 // We want synthesized mouse moves to cause mouseover and mouseout
1830 // DOM events (nsEventStateManager::PreHandleEvent), but not mousemove
1831 // DOM events.
1832 // Synthesized button up events also do not cause DOM events because they
1833 // do not have a reliable refPoint.
1834 return static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal;
1836 case NS_WHEEL_EVENT: {
1837 // wheel event whose all delta values are zero by user pref applied, it
1838 // shouldn't cause a DOM event.
1839 mozilla::widget::WheelEvent* wheelEvent =
1840 static_cast<mozilla::widget::WheelEvent*>(aEvent);
1841 return wheelEvent->deltaX != 0.0 || wheelEvent->deltaY != 0.0 ||
1842 wheelEvent->deltaZ != 0.0;
1845 default:
1846 return true;
1850 #endif // nsGUIEvent_h__