Bumping gaia.json for 1 gaia revision(s) a=gaia-bump
[gecko.git] / widget / BasicEvents.h
blobf55ce9bfafdfd47c5d1dfffa6a4e18ae7e994869
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 mozilla_BasicEvents_h__
7 #define mozilla_BasicEvents_h__
9 #include <stdint.h>
11 #include "mozilla/dom/EventTarget.h"
12 #include "mozilla/EventForwards.h"
13 #include "mozilla/TimeStamp.h"
14 #include "nsCOMPtr.h"
15 #include "nsIAtom.h"
16 #include "nsISupportsImpl.h"
17 #include "nsIWidget.h"
18 #include "nsString.h"
19 #include "Units.h"
21 /******************************************************************************
22 * Messages
24 * TODO: Make them enum.
25 ******************************************************************************/
27 #define NS_EVENT_NULL 0
29 // This is a dummy event message for all event listener implementation in
30 // EventListenerManager.
31 #define NS_EVENT_ALL 1
33 #define NS_WINDOW_START 100
35 // Widget may be destroyed
36 #define NS_XUL_CLOSE (NS_WINDOW_START + 1)
37 // Key is pressed within a window
38 #define NS_KEY_PRESS (NS_WINDOW_START + 31)
39 // Key is released within a window
40 #define NS_KEY_UP (NS_WINDOW_START + 32)
41 // Key is pressed within a window
42 #define NS_KEY_DOWN (NS_WINDOW_START + 33)
44 #define NS_KEY_BEFORE_DOWN (NS_WINDOW_START + 34)
45 #define NS_KEY_AFTER_DOWN (NS_WINDOW_START + 35)
46 #define NS_KEY_BEFORE_UP (NS_WINDOW_START + 36)
47 #define NS_KEY_AFTER_UP (NS_WINDOW_START + 37)
49 #define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
50 #define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
52 // A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be
53 // used when the window is not active. NS_PLUGIN_FOCUS should be used when
54 // the window is active. In the latter case, the dispatcher of the event
55 // is expected to ensure that the plugin's widget is focused beforehand.
56 #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
57 #define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63)
59 #define NS_OFFLINE (NS_WINDOW_START + 64)
60 #define NS_ONLINE (NS_WINDOW_START + 65)
62 // NS_BEFORERESIZE_EVENT used to be here (NS_WINDOW_START + 66)
64 // Indicates that the user is either idle or active
65 #define NS_MOZ_USER_IDLE (NS_WINDOW_START + 67)
66 #define NS_MOZ_USER_ACTIVE (NS_WINDOW_START + 68)
68 #define NS_LANGUAGECHANGE (NS_WINDOW_START + 70)
70 #define NS_MOUSE_MESSAGE_START 300
71 #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
72 #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
73 #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
74 #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
75 #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
76 #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
77 #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
78 #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
79 #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
80 #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
81 #define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
82 #define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34)
83 #define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35)
84 #define NS_MOUSE_MOZLONGTAP (NS_MOUSE_MESSAGE_START + 36)
86 // Pointer spec events
87 #define NS_POINTER_EVENT_START 4400
88 #define NS_POINTER_MOVE (NS_POINTER_EVENT_START)
89 #define NS_POINTER_UP (NS_POINTER_EVENT_START + 1)
90 #define NS_POINTER_DOWN (NS_POINTER_EVENT_START + 2)
91 #define NS_POINTER_OVER (NS_POINTER_EVENT_START + 22)
92 #define NS_POINTER_OUT (NS_POINTER_EVENT_START + 23)
93 #define NS_POINTER_ENTER (NS_POINTER_EVENT_START + 24)
94 #define NS_POINTER_LEAVE (NS_POINTER_EVENT_START + 25)
95 #define NS_POINTER_CANCEL (NS_POINTER_EVENT_START + 26)
96 #define NS_POINTER_GOT_CAPTURE (NS_POINTER_EVENT_START + 27)
97 #define NS_POINTER_LOST_CAPTURE (NS_POINTER_EVENT_START + 28)
99 #define NS_CONTEXTMENU_MESSAGE_START 500
100 #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
102 #define NS_STREAM_EVENT_START 1100
103 #define NS_LOAD (NS_STREAM_EVENT_START)
104 #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
105 #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
106 #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
107 #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
108 #define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
109 #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
110 #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
111 #define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8)
113 #define NS_FORM_EVENT_START 1200
114 #define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
115 #define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
116 #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
117 #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
118 #define NS_FORM_INVALID (NS_FORM_EVENT_START + 4)
120 //Need separate focus/blur notifications for non-native widgets
121 #define NS_FOCUS_EVENT_START 1300
122 #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
123 #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
125 #define NS_DRAGDROP_EVENT_START 1400
126 #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
127 #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
128 #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
129 #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
130 #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
131 #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
132 #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
133 #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
134 #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
135 #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
136 #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
137 #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
139 // Events for popups
140 #define NS_XUL_EVENT_START 1500
141 #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
142 #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
143 #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
144 #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
145 // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
146 #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
147 #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
148 //@}
150 // Scroll events
151 #define NS_MOUSE_SCROLL_START 1600
152 #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
153 #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
155 #define NS_SCROLLPORT_START 1700
156 #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
157 #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
159 #define NS_MUTATION_START 1800
160 #define NS_MUTATION_SUBTREEMODIFIED (NS_MUTATION_START)
161 #define NS_MUTATION_NODEINSERTED (NS_MUTATION_START+1)
162 #define NS_MUTATION_NODEREMOVED (NS_MUTATION_START+2)
163 #define NS_MUTATION_NODEREMOVEDFROMDOCUMENT (NS_MUTATION_START+3)
164 #define NS_MUTATION_NODEINSERTEDINTODOCUMENT (NS_MUTATION_START+4)
165 #define NS_MUTATION_ATTRMODIFIED (NS_MUTATION_START+5)
166 #define NS_MUTATION_CHARACTERDATAMODIFIED (NS_MUTATION_START+6)
167 #define NS_MUTATION_END (NS_MUTATION_START+6)
169 #define NS_USER_DEFINED_EVENT 2000
171 // composition events
172 #define NS_COMPOSITION_EVENT_START 2200
173 #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
174 // NS_COMPOSITION_END is the message for DOM compositionend event.
175 // This event should NOT be dispatched from widget if NS_COMPOSITION_COMMIT
176 // is available.
177 #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
178 // NS_COMPOSITION_UPDATE is the message for DOM compositionupdate event.
179 // This event should NOT be dispatched from widget since it will be dispatched
180 // by mozilla::TextComposition automatically if NS_COMPOSITION_CHANGE event
181 // will change composition string.
182 #define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2)
183 // NS_COMPOSITION_CHANGE is the message for representing a change of
184 // composition string. This should be dispatched from widget even if
185 // composition string isn't changed but the ranges are changed. This causes
186 // a DOM "text" event which is a non-standard DOM event.
187 #define NS_COMPOSITION_CHANGE (NS_COMPOSITION_EVENT_START + 3)
188 // NS_COMPOSITION_COMMIT_AS_IS is the message for representing a commit of
189 // composition string. TextComposition will commit composition with the
190 // last data. TextComposition will dispatch this event to the DOM tree as
191 // NS_COMPOSITION_CHANGE without clause information. After that,
192 // NS_COMPOSITION_END will be dispatched automatically.
193 // Its mData and mRanges should be empty and nullptr.
194 #define NS_COMPOSITION_COMMIT_AS_IS (NS_COMPOSITION_EVENT_START + 4)
195 // NS_COMPOSITION_COMMIT is the message for representing a commit of
196 // composition string with its mData value. TextComposition will dispatch this
197 // event to the DOM tree as NS_COMPOSITION_CHANGE without clause information.
198 // After that, NS_COMPOSITION_END will be dispatched automatically.
199 // Its mRanges should be nullptr.
200 #define NS_COMPOSITION_COMMIT (NS_COMPOSITION_EVENT_START + 5)
202 // UI events
203 #define NS_UI_EVENT_START 2500
204 // this is not to be confused with NS_ACTIVATE!
205 #define NS_UI_ACTIVATE (NS_UI_EVENT_START)
206 #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
207 #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
209 // pagetransition events
210 #define NS_PAGETRANSITION_START 2700
211 #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
212 #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
214 // SVG events
215 #define NS_SVG_EVENT_START 2800
216 #define NS_SVG_LOAD (NS_SVG_EVENT_START)
217 #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
218 #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
219 #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
220 #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
221 #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
223 // SVG Zoom events
224 #define NS_SVGZOOM_EVENT_START 2900
225 #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
227 // XUL command events
228 #define NS_XULCOMMAND_EVENT_START 3000
229 #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
231 // Cut, copy, paste events
232 #define NS_CUTCOPYPASTE_EVENT_START 3100
233 #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
234 #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
235 #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
237 // Query the content information
238 #define NS_QUERY_CONTENT_EVENT_START 3200
239 // Query for the selected text information, it return the selection offset,
240 // selection length and selected text.
241 #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
242 // Query for the text content of specified range, it returns actual lengh (if
243 // the specified range is too long) and the text of the specified range.
244 // Returns the entire text if requested length > actual length.
245 #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
246 // Query for the caret rect of nth insertion point. The offset of the result is
247 // relative position from the top level widget.
248 #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
249 // Query for the bounding rect of a range of characters. This works on any
250 // valid character range given offset and length. Result is relative to top
251 // level widget coordinates
252 #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
253 // Query for the bounding rect of the current focused frame. Result is relative
254 // to top level widget coordinates
255 #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
256 // Query for the current state of the content. The particular members of
257 // mReply that are set for each query content event will be valid on success.
258 #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
259 // Query for the selection in the form of a nsITransferable.
260 #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
261 // Query for character at a point. This returns the character offset and its
262 // rect. The point is specified by Event::refPoint.
263 #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
264 // Query if the DOM element under Event::refPoint belongs to our widget
265 // or not.
266 #define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9)
268 // Video events
269 #define NS_MEDIA_EVENT_START 3300
270 #define NS_LOADSTART (NS_MEDIA_EVENT_START)
271 #define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
272 #define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
273 #define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
274 #define NS_STALLED (NS_MEDIA_EVENT_START+4)
275 #define NS_PLAY (NS_MEDIA_EVENT_START+5)
276 #define NS_PAUSE (NS_MEDIA_EVENT_START+6)
277 #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
278 #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
279 #define NS_WAITING (NS_MEDIA_EVENT_START+9)
280 #define NS_PLAYING (NS_MEDIA_EVENT_START+10)
281 #define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
282 #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
283 #define NS_SEEKING (NS_MEDIA_EVENT_START+13)
284 #define NS_SEEKED (NS_MEDIA_EVENT_START+14)
285 #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
286 #define NS_ENDED (NS_MEDIA_EVENT_START+16)
287 #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
288 #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
289 #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
290 #define NS_NEED_KEY (NS_MEDIA_EVENT_START+20)
292 // paint notification events
293 #define NS_NOTIFYPAINT_START 3400
294 #define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
296 // Simple gesture events
297 #define NS_SIMPLE_GESTURE_EVENT_START 3500
298 #define NS_SIMPLE_GESTURE_SWIPE_START (NS_SIMPLE_GESTURE_EVENT_START)
299 #define NS_SIMPLE_GESTURE_SWIPE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+1)
300 #define NS_SIMPLE_GESTURE_SWIPE_END (NS_SIMPLE_GESTURE_EVENT_START+2)
301 #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START+3)
302 #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+4)
303 #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
304 #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+6)
305 #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+7)
306 #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+8)
307 #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+9)
308 #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+10)
309 #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+11)
310 #define NS_SIMPLE_GESTURE_EDGE_STARTED (NS_SIMPLE_GESTURE_EVENT_START+12)
311 #define NS_SIMPLE_GESTURE_EDGE_CANCELED (NS_SIMPLE_GESTURE_EVENT_START+13)
312 #define NS_SIMPLE_GESTURE_EDGE_COMPLETED (NS_SIMPLE_GESTURE_EVENT_START+14)
314 // These are used to send native events to plugins.
315 #define NS_PLUGIN_EVENT_START 3600
316 #define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START)
317 #define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1)
319 // Events to manipulate selection (WidgetSelectionEvent)
320 #define NS_SELECTION_EVENT_START 3700
321 // Clear any previous selection and set the given range as the selection
322 #define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
324 // Events of commands for the contents
325 #define NS_CONTENT_COMMAND_EVENT_START 3800
326 #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
327 #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
328 #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
329 #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
330 #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
331 #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
332 #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
333 // NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the
334 // currently focused content or latest DOM selection. This would normally be
335 // the same element scrolled by keyboard scroll commands, except that this event
336 // will scroll an element scrollable in either direction. I.e., if the nearest
337 // scrollable ancestor element can only be scrolled vertically, and horizontal
338 // scrolling is requested using this event, no scrolling will occur.
339 #define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7)
341 // Event to gesture notification
342 #define NS_GESTURENOTIFY_EVENT_START 3900
344 #define NS_ORIENTATION_EVENT 4000
346 #define NS_SCROLLAREA_EVENT_START 4100
347 #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
349 #define NS_TRANSITION_EVENT_START 4200
350 #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
352 #define NS_ANIMATION_EVENT_START 4250
353 #define NS_ANIMATION_START (NS_ANIMATION_EVENT_START)
354 #define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1)
355 #define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2)
357 #define NS_SMIL_TIME_EVENT_START 4300
358 #define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START)
359 #define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1)
360 #define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
362 #define NS_WEBAUDIO_EVENT_START 4350
363 #define NS_AUDIO_PROCESS (NS_WEBAUDIO_EVENT_START)
364 #define NS_AUDIO_COMPLETE (NS_WEBAUDIO_EVENT_START + 1)
366 // script notification events
367 #define NS_NOTIFYSCRIPT_START 4500
368 #define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
369 #define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1)
371 #define NS_PRINT_EVENT_START 4600
372 #define NS_BEFOREPRINT (NS_PRINT_EVENT_START)
373 #define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1)
375 #define NS_MESSAGE_EVENT_START 4700
376 #define NS_MESSAGE (NS_MESSAGE_EVENT_START)
378 // Open and close events
379 #define NS_OPENCLOSE_EVENT_START 4800
380 #define NS_OPEN (NS_OPENCLOSE_EVENT_START)
381 #define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1)
383 // Device motion and orientation
384 #define NS_DEVICE_ORIENTATION_START 4900
385 #define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START)
386 #define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1)
387 #define NS_DEVICE_PROXIMITY (NS_DEVICE_ORIENTATION_START+2)
388 #define NS_USER_PROXIMITY (NS_DEVICE_ORIENTATION_START+3)
389 #define NS_DEVICE_LIGHT (NS_DEVICE_ORIENTATION_START+4)
391 #define NS_SHOW_EVENT 5000
393 // Fullscreen DOM API
394 #define NS_FULL_SCREEN_START 5100
395 #define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START)
396 #define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1)
398 #define NS_TOUCH_EVENT_START 5200
399 #define NS_TOUCH_START (NS_TOUCH_EVENT_START)
400 #define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1)
401 #define NS_TOUCH_END (NS_TOUCH_EVENT_START+2)
402 #define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+3)
404 // Pointerlock DOM API
405 #define NS_POINTERLOCK_START 5300
406 #define NS_POINTERLOCKCHANGE (NS_POINTERLOCK_START)
407 #define NS_POINTERLOCKERROR (NS_POINTERLOCK_START + 1)
409 #define NS_WHEEL_EVENT_START 5400
410 #define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START)
411 #define NS_WHEEL_START (NS_WHEEL_EVENT_START + 1)
412 #define NS_WHEEL_STOP (NS_WHEEL_EVENT_START + 2)
414 //System time is changed
415 #define NS_MOZ_TIME_CHANGE_EVENT 5500
417 // Network packet events.
418 #define NS_NETWORK_EVENT_START 5600
419 #define NS_NETWORK_UPLOAD_EVENT (NS_NETWORK_EVENT_START + 1)
420 #define NS_NETWORK_DOWNLOAD_EVENT (NS_NETWORK_EVENT_START + 2)
422 // MediaRecorder events.
423 #define NS_MEDIARECORDER_EVENT_START 5700
424 #define NS_MEDIARECORDER_DATAAVAILABLE (NS_MEDIARECORDER_EVENT_START + 1)
425 #define NS_MEDIARECORDER_WARNING (NS_MEDIARECORDER_EVENT_START + 2)
426 #define NS_MEDIARECORDER_STOP (NS_MEDIARECORDER_EVENT_START + 3)
428 // SpeakerManager events
429 #define NS_SPEAKERMANAGER_EVENT_START 5800
430 #define NS_SPEAKERMANAGER_SPEAKERFORCEDCHANGE (NS_SPEAKERMANAGER_EVENT_START + 1)
432 #ifdef MOZ_GAMEPAD
433 // Gamepad input events
434 #define NS_GAMEPAD_START 6000
435 #define NS_GAMEPAD_BUTTONDOWN (NS_GAMEPAD_START)
436 #define NS_GAMEPAD_BUTTONUP (NS_GAMEPAD_START+1)
437 #define NS_GAMEPAD_AXISMOVE (NS_GAMEPAD_START+2)
438 #define NS_GAMEPAD_CONNECTED (NS_GAMEPAD_START+3)
439 #define NS_GAMEPAD_DISCONNECTED (NS_GAMEPAD_START+4)
440 // Keep this defined to the same value as the event above
441 #define NS_GAMEPAD_END (NS_GAMEPAD_START+4)
442 #endif
444 // input and beforeinput events.
445 #define NS_EDITOR_EVENT_START 6100
446 #define NS_EDITOR_INPUT (NS_EDITOR_EVENT_START)
448 namespace IPC {
449 template<typename T>
450 struct ParamTraits;
453 namespace mozilla {
455 /******************************************************************************
456 * mozilla::BaseEventFlags
458 * BaseEventFlags must be a POD struct for safe to use memcpy (including
459 * in ParamTraits<BaseEventFlags>). So don't make virtual methods, constructor,
460 * destructor and operators.
461 * This is necessary for VC which is NOT C++0x compiler.
462 ******************************************************************************/
464 struct BaseEventFlags
466 public:
467 // If mIsTrusted is true, the event is a trusted event. Otherwise, it's
468 // an untrusted event.
469 bool mIsTrusted : 1;
470 // If mInBubblingPhase is true, the event is in bubbling phase or target
471 // phase.
472 bool mInBubblingPhase : 1;
473 // If mInCapturePhase is true, the event is in capture phase or target phase.
474 bool mInCapturePhase : 1;
475 // If mInSystemGroup is true, the event is being dispatched in system group.
476 bool mInSystemGroup: 1;
477 // If mCancelable is true, the event can be consumed. I.e., calling
478 // dom::Event::PreventDefault() can prevent the default action.
479 bool mCancelable : 1;
480 // If mBubbles is true, the event can bubble. Otherwise, cannot be handled
481 // in bubbling phase.
482 bool mBubbles : 1;
483 // If mPropagationStopped is true, dom::Event::StopPropagation() or
484 // dom::Event::StopImmediatePropagation() has been called.
485 bool mPropagationStopped : 1;
486 // If mImmediatePropagationStopped is true,
487 // dom::Event::StopImmediatePropagation() has been called.
488 // Note that mPropagationStopped must be true when this is true.
489 bool mImmediatePropagationStopped : 1;
490 // If mDefaultPrevented is true, the event has been consumed.
491 // E.g., dom::Event::PreventDefault() has been called or
492 // the default action has been performed.
493 bool mDefaultPrevented : 1;
494 // If mDefaultPreventedByContent is true, the event has been
495 // consumed by content.
496 // Note that mDefaultPrevented must be true when this is true.
497 bool mDefaultPreventedByContent : 1;
498 // mMultipleActionsPrevented may be used when default handling don't want to
499 // be prevented, but only one of the event targets should handle the event.
500 // For example, when a <label> element is in another <label> element and
501 // the first <label> element is clicked, that one may set this true.
502 // Then, the second <label> element won't handle the event.
503 bool mMultipleActionsPrevented : 1;
504 // If mIsBeingDispatched is true, the DOM event created from the event is
505 // dispatching into the DOM tree and not completed.
506 bool mIsBeingDispatched : 1;
507 // If mDispatchedAtLeastOnce is true, the event has been dispatched
508 // as a DOM event and the dispatch has been completed.
509 bool mDispatchedAtLeastOnce : 1;
510 // If mIsSynthesizedForTests is true, the event has been synthesized for
511 // automated tests or something hacky approach of an add-on.
512 bool mIsSynthesizedForTests : 1;
513 // If mExceptionHasBeenRisen is true, one of the event handlers has risen an
514 // exception.
515 bool mExceptionHasBeenRisen : 1;
516 // If mRetargetToNonNativeAnonymous is true and the target is in a non-native
517 // native anonymous subtree, the event target is set to originalTarget.
518 bool mRetargetToNonNativeAnonymous : 1;
519 // If mNoCrossProcessBoundaryForwarding is true, the event is not allowed to
520 // cross process boundary.
521 bool mNoCrossProcessBoundaryForwarding : 1;
522 // If mNoContentDispatch is true, the event is never dispatched to the
523 // event handlers which are added to the contents, onfoo attributes and
524 // properties. Note that this flag is ignored when
525 // EventChainPreVisitor::mForceContentDispatch is set true. For exapmle,
526 // window and document object sets it true. Therefore, web applications
527 // can handle the event if they add event listeners to the window or the
528 // document.
529 bool mNoContentDispatch : 1;
530 // If mOnlyChromeDispatch is true, the event is dispatched to only chrome.
531 bool mOnlyChromeDispatch : 1;
532 // If mWantReplyFromContentProcess is true, the event will be redispatched
533 // in the parent process after the content process has handled it. Useful
534 // for when the parent process need the know first how the event was used
535 // by content before handling it itself.
536 bool mWantReplyFromContentProcess : 1;
538 // If the event is being handled in target phase, returns true.
539 inline bool InTargetPhase() const
541 return (mInBubblingPhase && mInCapturePhase);
544 inline void Clear()
546 SetRawFlags(0);
548 // Get if either the instance's bit or the aOther's bit is true, the
549 // instance's bit becomes true. In other words, this works like:
550 // eventFlags |= aOther;
551 inline void Union(const BaseEventFlags& aOther)
553 RawFlags rawFlags = GetRawFlags() | aOther.GetRawFlags();
554 SetRawFlags(rawFlags);
557 private:
558 typedef uint32_t RawFlags;
560 inline void SetRawFlags(RawFlags aRawFlags)
562 static_assert(sizeof(BaseEventFlags) <= sizeof(RawFlags),
563 "mozilla::EventFlags must not be bigger than the RawFlags");
564 memcpy(this, &aRawFlags, sizeof(BaseEventFlags));
566 inline RawFlags GetRawFlags() const
568 RawFlags result = 0;
569 memcpy(&result, this, sizeof(BaseEventFlags));
570 return result;
574 /******************************************************************************
575 * mozilla::EventFlags
576 ******************************************************************************/
578 struct EventFlags : public BaseEventFlags
580 EventFlags()
582 Clear();
586 /******************************************************************************
587 * mozilla::WidgetEvent
588 ******************************************************************************/
590 class WidgetEvent
592 protected:
593 WidgetEvent(bool aIsTrusted, uint32_t aMessage, EventClassID aEventClassID)
594 : mClass(aEventClassID)
595 , message(aMessage)
596 , refPoint(0, 0)
597 , lastRefPoint(0, 0)
598 , time(0)
599 , timeStamp(TimeStamp::Now())
600 , userType(nullptr)
602 MOZ_COUNT_CTOR(WidgetEvent);
603 mFlags.Clear();
604 mFlags.mIsTrusted = aIsTrusted;
605 mFlags.mCancelable = true;
606 mFlags.mBubbles = true;
609 WidgetEvent()
611 MOZ_COUNT_CTOR(WidgetEvent);
614 public:
615 WidgetEvent(bool aIsTrusted, uint32_t aMessage)
616 : mClass(eBasicEventClass)
617 , message(aMessage)
618 , refPoint(0, 0)
619 , lastRefPoint(0, 0)
620 , time(0)
621 , timeStamp(TimeStamp::Now())
622 , userType(nullptr)
624 MOZ_COUNT_CTOR(WidgetEvent);
625 mFlags.Clear();
626 mFlags.mIsTrusted = aIsTrusted;
627 mFlags.mCancelable = true;
628 mFlags.mBubbles = true;
631 virtual ~WidgetEvent()
633 MOZ_COUNT_DTOR(WidgetEvent);
636 WidgetEvent(const WidgetEvent& aOther)
638 MOZ_COUNT_CTOR(WidgetEvent);
639 *this = aOther;
642 virtual WidgetEvent* Duplicate() const
644 MOZ_ASSERT(mClass == eBasicEventClass,
645 "Duplicate() must be overridden by sub class");
646 WidgetEvent* result = new WidgetEvent(false, message);
647 result->AssignEventData(*this, true);
648 result->mFlags = mFlags;
649 return result;
652 EventClassID mClass;
653 // See GUI MESSAGES,
654 uint32_t message;
655 // Relative to the widget of the event, or if there is no widget then it is
656 // in screen coordinates. Not modified by layout code.
657 LayoutDeviceIntPoint refPoint;
658 // The previous refPoint, if known, used to calculate mouse movement deltas.
659 LayoutDeviceIntPoint lastRefPoint;
660 // Elapsed time, in milliseconds, from a platform-specific zero time
661 // to the time the message was created
662 uint64_t time;
663 // Timestamp when the message was created. Set in parallel to 'time' until we
664 // determine if it is safe to drop 'time' (see bug 77992).
665 mozilla::TimeStamp timeStamp;
666 // See BaseEventFlags definition for the detail.
667 BaseEventFlags mFlags;
669 // Additional type info for user defined events
670 nsCOMPtr<nsIAtom> userType;
672 nsString typeString; // always set on non-main-thread events
674 // Event targets, needed by DOM Events
675 nsCOMPtr<dom::EventTarget> target;
676 nsCOMPtr<dom::EventTarget> currentTarget;
677 nsCOMPtr<dom::EventTarget> originalTarget;
679 void AssignEventData(const WidgetEvent& aEvent, bool aCopyTargets)
681 // mClass should be initialized with the constructor.
682 // message should be initialized with the constructor.
683 refPoint = aEvent.refPoint;
684 // lastRefPoint doesn't need to be copied.
685 time = aEvent.time;
686 timeStamp = aEvent.timeStamp;
687 // mFlags should be copied manually if it's necessary.
688 userType = aEvent.userType;
689 // typeString should be copied manually if it's necessary.
690 target = aCopyTargets ? aEvent.target : nullptr;
691 currentTarget = aCopyTargets ? aEvent.currentTarget : nullptr;
692 originalTarget = aCopyTargets ? aEvent.originalTarget : nullptr;
696 * Utils for checking event types
700 * As*Event() returns the pointer of the instance only when the instance is
701 * the class or one of its derived class.
703 #define NS_ROOT_EVENT_CLASS(aPrefix, aName)
704 #define NS_EVENT_CLASS(aPrefix, aName) \
705 virtual aPrefix##aName* As##aName(); \
706 const aPrefix##aName* As##aName() const;
708 #include "mozilla/EventClassList.h"
710 #undef NS_EVENT_CLASS
711 #undef NS_ROOT_EVENT_CLASS
714 * Returns true if the event is a query content event.
716 bool IsQueryContentEvent() const;
718 * Returns true if the event is a selection event.
720 bool IsSelectionEvent() const;
722 * Returns true if the event is a content command event.
724 bool IsContentCommandEvent() const;
726 * Returns true if the event is a native event deliverer event for plugin.
728 bool IsNativeEventDelivererForPlugin() const;
731 * Returns true if the event message is one of mouse events.
733 bool HasMouseEventMessage() const;
735 * Returns true if the event message is one of drag events.
737 bool HasDragEventMessage() const;
739 * Returns true if the event message is one of key events.
741 bool HasKeyEventMessage() const;
743 * Returns true if the event message is one of composition events or text
744 * event.
746 bool HasIMEEventMessage() const;
748 * Returns true if the event message is one of plugin activation events.
750 bool HasPluginActivationEventMessage() const;
753 * Returns true if the event is native event deliverer event for plugin and
754 * it should be retarted to focused document.
756 bool IsRetargetedNativeEventDelivererForPlugin() const;
758 * Returns true if the event is native event deliverer event for plugin and
759 * it should NOT be retarted to focused document.
761 bool IsNonRetargetedNativeEventDelivererForPlugin() const;
763 * Returns true if the event is related to IME handling. It includes
764 * IME events, query content events and selection events.
765 * Be careful when you use this.
767 bool IsIMERelatedEvent() const;
770 * Whether the event should be handled by the frame of the mouse cursor
771 * position or not. When it should be handled there (e.g., the mouse events),
772 * this returns true.
774 bool IsUsingCoordinates() const;
776 * Whether the event should be handled by the focused DOM window in the
777 * same top level window's or not. E.g., key events, IME related events
778 * (including the query content events, they are used in IME transaction)
779 * should be handled by the (last) focused window rather than the dispatched
780 * window.
782 * NOTE: Even if this returns true, the event isn't going to be handled by the
783 * application level active DOM window which is on another top level window.
784 * So, when the event is fired on a deactive window, the event is going to be
785 * handled by the last focused DOM window in the last focused window.
787 bool IsTargetedAtFocusedWindow() const;
789 * Whether the event should be handled by the focused content or not. E.g.,
790 * key events, IME related events and other input events which are not handled
791 * by the frame of the mouse cursor position.
793 * NOTE: Even if this returns true, the event isn't going to be handled by the
794 * application level active DOM window which is on another top level window.
795 * So, when the event is fired on a deactive window, the event is going to be
796 * handled by the last focused DOM element of the last focused DOM window in
797 * the last focused window.
799 bool IsTargetedAtFocusedContent() const;
801 * Whether the event should cause a DOM event.
803 bool IsAllowedToDispatchDOMEvent() const;
806 /******************************************************************************
807 * mozilla::WidgetGUIEvent
808 ******************************************************************************/
810 class WidgetGUIEvent : public WidgetEvent
812 protected:
813 WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
814 EventClassID aEventClassID)
815 : WidgetEvent(aIsTrusted, aMessage, aEventClassID)
816 , widget(aWidget)
820 WidgetGUIEvent()
824 public:
825 virtual WidgetGUIEvent* AsGUIEvent() MOZ_OVERRIDE { return this; }
827 WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
828 WidgetEvent(aIsTrusted, aMessage, eGUIEventClass),
829 widget(aWidget)
833 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
835 MOZ_ASSERT(mClass == eGUIEventClass,
836 "Duplicate() must be overridden by sub class");
837 // Not copying widget, it is a weak reference.
838 WidgetGUIEvent* result = new WidgetGUIEvent(false, message, nullptr);
839 result->AssignGUIEventData(*this, true);
840 result->mFlags = mFlags;
841 return result;
844 /// Originator of the event
845 nsCOMPtr<nsIWidget> widget;
848 * Explanation for this PluginEvent class:
850 * WidgetGUIEvent's mPluginEvent member used to be a void* pointer,
851 * used to reference external, OS-specific data structures.
853 * That void* pointer wasn't serializable by itself, causing
854 * certain plugin events not to function in e10s. See bug 586656.
856 * To make this serializable, we changed this void* pointer into
857 * a proper buffer, and copy these external data structures into this
858 * buffer.
860 * That buffer is PluginEvent::mBuffer below.
862 * We wrap this in that PluginEvent class providing operators to
863 * be compatible with existing code that was written around
864 * the old void* field.
866 * Ideally though, we wouldn't allow arbitrary reinterpret_cast'ing here;
867 * instead, we would at least store type information here so that
868 * this class can't be used to reinterpret one structure type into another.
869 * We can also wonder if it would be possible to properly extend
870 * WidgetGUIEvent and other Event classes to remove the need for this
871 * mPluginEvent field.
873 class PluginEvent MOZ_FINAL
875 nsTArray<uint8_t> mBuffer;
877 friend struct IPC::ParamTraits<mozilla::WidgetGUIEvent>;
879 public:
881 MOZ_EXPLICIT_CONVERSION operator bool() const
883 return !mBuffer.IsEmpty();
886 template<typename T>
887 MOZ_EXPLICIT_CONVERSION operator const T*() const
889 return mBuffer.IsEmpty()
890 ? nullptr
891 : reinterpret_cast<const T*>(mBuffer.Elements());
894 template <typename T>
895 void Copy(const T& other)
897 static_assert(!mozilla::IsPointer<T>::value, "Don't want a pointer!");
898 mBuffer.SetLength(sizeof(T));
899 memcpy(mBuffer.Elements(), &other, mBuffer.Length());
902 void Clear()
904 mBuffer.Clear();
908 /// Event for NPAPI plugin
909 PluginEvent mPluginEvent;
911 void AssignGUIEventData(const WidgetGUIEvent& aEvent, bool aCopyTargets)
913 AssignEventData(aEvent, aCopyTargets);
915 // widget should be initialized with the constructor.
917 mPluginEvent = aEvent.mPluginEvent;
921 /******************************************************************************
922 * mozilla::Modifier
924 * All modifier keys should be defined here. This is used for managing
925 * modifier states for DOM Level 3 or later.
926 ******************************************************************************/
928 enum Modifier
930 MODIFIER_NONE = 0x0000,
931 MODIFIER_ALT = 0x0001,
932 MODIFIER_ALTGRAPH = 0x0002,
933 MODIFIER_CAPSLOCK = 0x0004,
934 MODIFIER_CONTROL = 0x0008,
935 MODIFIER_FN = 0x0010,
936 MODIFIER_META = 0x0020,
937 MODIFIER_NUMLOCK = 0x0040,
938 MODIFIER_SCROLLLOCK = 0x0080,
939 MODIFIER_SHIFT = 0x0100,
940 MODIFIER_SYMBOLLOCK = 0x0200,
941 MODIFIER_OS = 0x0400
944 /******************************************************************************
945 * Modifier key names.
946 ******************************************************************************/
948 #define NS_DOM_KEYNAME_ALT "Alt"
949 #define NS_DOM_KEYNAME_ALTGRAPH "AltGraph"
950 #define NS_DOM_KEYNAME_CAPSLOCK "CapsLock"
951 #define NS_DOM_KEYNAME_CONTROL "Control"
952 #define NS_DOM_KEYNAME_FN "Fn"
953 #define NS_DOM_KEYNAME_META "Meta"
954 #define NS_DOM_KEYNAME_NUMLOCK "NumLock"
955 #define NS_DOM_KEYNAME_SCROLLLOCK "ScrollLock"
956 #define NS_DOM_KEYNAME_SHIFT "Shift"
957 #define NS_DOM_KEYNAME_SYMBOLLOCK "SymbolLock"
958 #define NS_DOM_KEYNAME_OS "OS"
960 /******************************************************************************
961 * mozilla::Modifiers
962 ******************************************************************************/
964 typedef uint16_t Modifiers;
966 /******************************************************************************
967 * mozilla::WidgetInputEvent
968 ******************************************************************************/
970 class WidgetInputEvent : public WidgetGUIEvent
972 protected:
973 WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
974 EventClassID aEventClassID)
975 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
976 , modifiers(0)
980 WidgetInputEvent()
984 public:
985 virtual WidgetInputEvent* AsInputEvent() MOZ_OVERRIDE { return this; }
987 WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
988 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eInputEventClass)
989 , modifiers(0)
993 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
995 MOZ_ASSERT(mClass == eInputEventClass,
996 "Duplicate() must be overridden by sub class");
997 // Not copying widget, it is a weak reference.
998 WidgetInputEvent* result = new WidgetInputEvent(false, message, nullptr);
999 result->AssignInputEventData(*this, true);
1000 result->mFlags = mFlags;
1001 return result;
1006 * Returns a modifier of "Accel" virtual modifier which is used for shortcut
1007 * key.
1009 static Modifier AccelModifier();
1011 // true indicates the accel key on the environment is down
1012 bool IsAccel() const
1014 return ((modifiers & AccelModifier()) != 0);
1017 // true indicates the shift key is down
1018 bool IsShift() const
1020 return ((modifiers & MODIFIER_SHIFT) != 0);
1022 // true indicates the control key is down
1023 bool IsControl() const
1025 return ((modifiers & MODIFIER_CONTROL) != 0);
1027 // true indicates the alt key is down
1028 bool IsAlt() const
1030 return ((modifiers & MODIFIER_ALT) != 0);
1032 // true indicates the meta key is down (or, on Mac, the Command key)
1033 bool IsMeta() const
1035 return ((modifiers & MODIFIER_META) != 0);
1037 // true indicates the win key is down on Windows. Or the Super or Hyper key
1038 // is down on Linux.
1039 bool IsOS() const
1041 return ((modifiers & MODIFIER_OS) != 0);
1043 // true indicates the alt graph key is down
1044 // NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah()
1045 // return true.
1046 bool IsAltGraph() const
1048 return ((modifiers & MODIFIER_ALTGRAPH) != 0);
1050 // true indeicates the CapLock LED is turn on.
1051 bool IsCapsLocked() const
1053 return ((modifiers & MODIFIER_CAPSLOCK) != 0);
1055 // true indeicates the NumLock LED is turn on.
1056 bool IsNumLocked() const
1058 return ((modifiers & MODIFIER_NUMLOCK) != 0);
1060 // true indeicates the ScrollLock LED is turn on.
1061 bool IsScrollLocked() const
1063 return ((modifiers & MODIFIER_SCROLLLOCK) != 0);
1066 // true indeicates the Fn key is down, but this is not supported by native
1067 // key event on any platform.
1068 bool IsFn() const
1070 return ((modifiers & MODIFIER_FN) != 0);
1072 // true indeicates the ScrollLock LED is turn on.
1073 bool IsSymbolLocked() const
1075 return ((modifiers & MODIFIER_SYMBOLLOCK) != 0);
1078 void InitBasicModifiers(bool aCtrlKey,
1079 bool aAltKey,
1080 bool aShiftKey,
1081 bool aMetaKey)
1083 modifiers = 0;
1084 if (aCtrlKey) {
1085 modifiers |= MODIFIER_CONTROL;
1087 if (aAltKey) {
1088 modifiers |= MODIFIER_ALT;
1090 if (aShiftKey) {
1091 modifiers |= MODIFIER_SHIFT;
1093 if (aMetaKey) {
1094 modifiers |= MODIFIER_META;
1098 Modifiers modifiers;
1100 void AssignInputEventData(const WidgetInputEvent& aEvent, bool aCopyTargets)
1102 AssignGUIEventData(aEvent, aCopyTargets);
1104 modifiers = aEvent.modifiers;
1108 /******************************************************************************
1109 * mozilla::InternalUIEvent
1111 * XXX Why this inherits WidgetGUIEvent rather than WidgetEvent?
1112 ******************************************************************************/
1114 class InternalUIEvent : public WidgetGUIEvent
1116 protected:
1117 InternalUIEvent()
1118 : detail(0)
1122 InternalUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
1123 EventClassID aEventClassID)
1124 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
1125 , detail(0)
1129 InternalUIEvent(bool aIsTrusted, uint32_t aMessage,
1130 EventClassID aEventClassID)
1131 : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aEventClassID)
1132 , detail(0)
1136 public:
1137 virtual InternalUIEvent* AsUIEvent() MOZ_OVERRIDE { return this; }
1139 InternalUIEvent(bool aIsTrusted, uint32_t aMessage)
1140 : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, eUIEventClass)
1141 , detail(0)
1145 virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
1147 MOZ_ASSERT(mClass == eUIEventClass,
1148 "Duplicate() must be overridden by sub class");
1149 InternalUIEvent* result = new InternalUIEvent(false, message);
1150 result->AssignUIEventData(*this, true);
1151 result->mFlags = mFlags;
1152 return result;
1155 int32_t detail;
1157 void AssignUIEventData(const InternalUIEvent& aEvent, bool aCopyTargets)
1159 AssignGUIEventData(aEvent, aCopyTargets);
1161 detail = aEvent.detail;
1165 } // namespace mozilla
1167 #endif // mozilla_BasicEvents_h__