Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_BasicEvents_h__ |
michael@0 | 7 | #define mozilla_BasicEvents_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include <stdint.h> |
michael@0 | 10 | |
michael@0 | 11 | #include "mozilla/dom/EventTarget.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsIAtom.h" |
michael@0 | 14 | #include "nsISupportsImpl.h" |
michael@0 | 15 | #include "nsIWidget.h" |
michael@0 | 16 | #include "nsString.h" |
michael@0 | 17 | #include "Units.h" |
michael@0 | 18 | |
michael@0 | 19 | /****************************************************************************** |
michael@0 | 20 | * Event Struct Types |
michael@0 | 21 | * |
michael@0 | 22 | * TODO: Move it into mozilla namespace. |
michael@0 | 23 | ******************************************************************************/ |
michael@0 | 24 | enum nsEventStructType |
michael@0 | 25 | { |
michael@0 | 26 | // BasicEvents.h |
michael@0 | 27 | NS_EVENT, // WidgetEvent |
michael@0 | 28 | NS_GUI_EVENT, // WidgetGUIEvent |
michael@0 | 29 | NS_INPUT_EVENT, // WidgetInputEvent |
michael@0 | 30 | NS_UI_EVENT, // InternalUIEvent |
michael@0 | 31 | |
michael@0 | 32 | // TextEvents.h |
michael@0 | 33 | NS_KEY_EVENT, // WidgetKeyboardEvent |
michael@0 | 34 | NS_COMPOSITION_EVENT, // WidgetCompositionEvent |
michael@0 | 35 | NS_TEXT_EVENT, // WidgetTextEvent |
michael@0 | 36 | NS_QUERY_CONTENT_EVENT, // WidgetQueryContentEvent |
michael@0 | 37 | NS_SELECTION_EVENT, // WidgetSelectionEvent |
michael@0 | 38 | NS_EDITOR_INPUT_EVENT, // InternalEditorInputEvent |
michael@0 | 39 | |
michael@0 | 40 | // MouseEvents.h |
michael@0 | 41 | NS_MOUSE_EVENT, // WidgetMouseEvent |
michael@0 | 42 | NS_DRAG_EVENT, // WidgetDragEvent |
michael@0 | 43 | NS_MOUSE_SCROLL_EVENT, // WidgetMouseScrollEvent |
michael@0 | 44 | NS_WHEEL_EVENT, // WidgetWheelEvent |
michael@0 | 45 | NS_POINTER_EVENT, // PointerEvent |
michael@0 | 46 | |
michael@0 | 47 | // TouchEvents.h |
michael@0 | 48 | NS_GESTURENOTIFY_EVENT, // WidgetGestureNotifyEvent |
michael@0 | 49 | NS_SIMPLE_GESTURE_EVENT, // WidgetSimpleGestureEvent |
michael@0 | 50 | NS_TOUCH_EVENT, // WidgetTouchEvent |
michael@0 | 51 | |
michael@0 | 52 | // ContentEvents.h |
michael@0 | 53 | NS_SCROLLPORT_EVENT, // InternalScrollPortEvent |
michael@0 | 54 | NS_SCROLLAREA_EVENT, // InternalScrollAreaEvent |
michael@0 | 55 | NS_FORM_EVENT, // InternalFormEvent |
michael@0 | 56 | NS_FOCUS_EVENT, // InternalFocusEvent |
michael@0 | 57 | NS_CLIPBOARD_EVENT, // InternalClipboardEvent |
michael@0 | 58 | NS_TRANSITION_EVENT, // InternalTransitionEvent |
michael@0 | 59 | NS_ANIMATION_EVENT, // InternalAnimationEvent |
michael@0 | 60 | |
michael@0 | 61 | // MiscEvents.h |
michael@0 | 62 | NS_COMMAND_EVENT, // WidgetCommandEvent |
michael@0 | 63 | NS_CONTENT_COMMAND_EVENT, // WidgetContentCommandEvent |
michael@0 | 64 | NS_PLUGIN_EVENT, // WidgetPluginEvent |
michael@0 | 65 | |
michael@0 | 66 | // InternalMutationEvent.h (dom/events) |
michael@0 | 67 | NS_MUTATION_EVENT, // InternalMutationEvent |
michael@0 | 68 | |
michael@0 | 69 | // Follwoing struct type values are ugly. They indicate other struct type |
michael@0 | 70 | // actually. However, they are used for distinguishing which DOM event |
michael@0 | 71 | // should be created for the event. |
michael@0 | 72 | NS_SVGZOOM_EVENT, // WidgetGUIEvent |
michael@0 | 73 | NS_SMIL_TIME_EVENT // InternalUIEvent |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | /****************************************************************************** |
michael@0 | 77 | * Messages |
michael@0 | 78 | * |
michael@0 | 79 | * TODO: Make them enum. |
michael@0 | 80 | ******************************************************************************/ |
michael@0 | 81 | |
michael@0 | 82 | #define NS_EVENT_NULL 0 |
michael@0 | 83 | |
michael@0 | 84 | // This is a dummy event message for all event listener implementation in |
michael@0 | 85 | // EventListenerManager. |
michael@0 | 86 | #define NS_EVENT_ALL 1 |
michael@0 | 87 | |
michael@0 | 88 | #define NS_WINDOW_START 100 |
michael@0 | 89 | |
michael@0 | 90 | // Widget may be destroyed |
michael@0 | 91 | #define NS_XUL_CLOSE (NS_WINDOW_START + 1) |
michael@0 | 92 | // Key is pressed within a window |
michael@0 | 93 | #define NS_KEY_PRESS (NS_WINDOW_START + 31) |
michael@0 | 94 | // Key is released within a window |
michael@0 | 95 | #define NS_KEY_UP (NS_WINDOW_START + 32) |
michael@0 | 96 | // Key is pressed within a window |
michael@0 | 97 | #define NS_KEY_DOWN (NS_WINDOW_START + 33) |
michael@0 | 98 | |
michael@0 | 99 | #define NS_RESIZE_EVENT (NS_WINDOW_START + 60) |
michael@0 | 100 | #define NS_SCROLL_EVENT (NS_WINDOW_START + 61) |
michael@0 | 101 | |
michael@0 | 102 | // A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be |
michael@0 | 103 | // used when the window is not active. NS_PLUGIN_FOCUS should be used when |
michael@0 | 104 | // the window is active. In the latter case, the dispatcher of the event |
michael@0 | 105 | // is expected to ensure that the plugin's widget is focused beforehand. |
michael@0 | 106 | #define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62) |
michael@0 | 107 | #define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63) |
michael@0 | 108 | |
michael@0 | 109 | #define NS_OFFLINE (NS_WINDOW_START + 64) |
michael@0 | 110 | #define NS_ONLINE (NS_WINDOW_START + 65) |
michael@0 | 111 | |
michael@0 | 112 | // NS_BEFORERESIZE_EVENT used to be here (NS_WINDOW_START + 66) |
michael@0 | 113 | |
michael@0 | 114 | // Indicates that the user is either idle or active |
michael@0 | 115 | #define NS_MOZ_USER_IDLE (NS_WINDOW_START + 67) |
michael@0 | 116 | #define NS_MOZ_USER_ACTIVE (NS_WINDOW_START + 68) |
michael@0 | 117 | |
michael@0 | 118 | // The resolution at which a plugin should draw has changed, for |
michael@0 | 119 | // example as the result of changing from a HiDPI mode to a non- |
michael@0 | 120 | // HiDPI mode. |
michael@0 | 121 | #define NS_PLUGIN_RESOLUTION_CHANGED (NS_WINDOW_START + 69) |
michael@0 | 122 | |
michael@0 | 123 | #define NS_MOUSE_MESSAGE_START 300 |
michael@0 | 124 | #define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START) |
michael@0 | 125 | #define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1) |
michael@0 | 126 | #define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2) |
michael@0 | 127 | #define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22) |
michael@0 | 128 | #define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23) |
michael@0 | 129 | #define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24) |
michael@0 | 130 | #define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27) |
michael@0 | 131 | #define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30) |
michael@0 | 132 | #define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31) |
michael@0 | 133 | #define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32) |
michael@0 | 134 | #define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33) |
michael@0 | 135 | #define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34) |
michael@0 | 136 | #define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35) |
michael@0 | 137 | |
michael@0 | 138 | // Pointer spec events |
michael@0 | 139 | #define NS_POINTER_EVENT_START 4400 |
michael@0 | 140 | #define NS_POINTER_MOVE (NS_POINTER_EVENT_START) |
michael@0 | 141 | #define NS_POINTER_UP (NS_POINTER_EVENT_START + 1) |
michael@0 | 142 | #define NS_POINTER_DOWN (NS_POINTER_EVENT_START + 2) |
michael@0 | 143 | #define NS_POINTER_OVER (NS_POINTER_EVENT_START + 22) |
michael@0 | 144 | #define NS_POINTER_OUT (NS_POINTER_EVENT_START + 23) |
michael@0 | 145 | #define NS_POINTER_ENTER (NS_POINTER_EVENT_START + 24) |
michael@0 | 146 | #define NS_POINTER_LEAVE (NS_POINTER_EVENT_START + 25) |
michael@0 | 147 | #define NS_POINTER_CANCEL (NS_POINTER_EVENT_START + 26) |
michael@0 | 148 | #define NS_POINTER_GOT_CAPTURE (NS_POINTER_EVENT_START + 27) |
michael@0 | 149 | #define NS_POINTER_LOST_CAPTURE (NS_POINTER_EVENT_START + 28) |
michael@0 | 150 | |
michael@0 | 151 | #define NS_CONTEXTMENU_MESSAGE_START 500 |
michael@0 | 152 | #define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START) |
michael@0 | 153 | |
michael@0 | 154 | #define NS_STREAM_EVENT_START 1100 |
michael@0 | 155 | #define NS_LOAD (NS_STREAM_EVENT_START) |
michael@0 | 156 | #define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1) |
michael@0 | 157 | #define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2) |
michael@0 | 158 | #define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3) |
michael@0 | 159 | #define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4) |
michael@0 | 160 | #define NS_POPSTATE (NS_STREAM_EVENT_START + 5) |
michael@0 | 161 | #define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6) |
michael@0 | 162 | #define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7) |
michael@0 | 163 | #define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8) |
michael@0 | 164 | |
michael@0 | 165 | #define NS_FORM_EVENT_START 1200 |
michael@0 | 166 | #define NS_FORM_SUBMIT (NS_FORM_EVENT_START) |
michael@0 | 167 | #define NS_FORM_RESET (NS_FORM_EVENT_START + 1) |
michael@0 | 168 | #define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2) |
michael@0 | 169 | #define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3) |
michael@0 | 170 | #define NS_FORM_INVALID (NS_FORM_EVENT_START + 4) |
michael@0 | 171 | |
michael@0 | 172 | //Need separate focus/blur notifications for non-native widgets |
michael@0 | 173 | #define NS_FOCUS_EVENT_START 1300 |
michael@0 | 174 | #define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START) |
michael@0 | 175 | #define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1) |
michael@0 | 176 | |
michael@0 | 177 | #define NS_DRAGDROP_EVENT_START 1400 |
michael@0 | 178 | #define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START) |
michael@0 | 179 | #define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1) |
michael@0 | 180 | #define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2) |
michael@0 | 181 | #define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3) |
michael@0 | 182 | #define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4) |
michael@0 | 183 | #define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5) |
michael@0 | 184 | #define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6) |
michael@0 | 185 | #define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7) |
michael@0 | 186 | #define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8) |
michael@0 | 187 | #define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1) |
michael@0 | 188 | #define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2) |
michael@0 | 189 | #define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9) |
michael@0 | 190 | |
michael@0 | 191 | // Events for popups |
michael@0 | 192 | #define NS_XUL_EVENT_START 1500 |
michael@0 | 193 | #define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START) |
michael@0 | 194 | #define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1) |
michael@0 | 195 | #define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2) |
michael@0 | 196 | #define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3) |
michael@0 | 197 | // NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4) |
michael@0 | 198 | #define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5) |
michael@0 | 199 | #define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6) |
michael@0 | 200 | //@} |
michael@0 | 201 | |
michael@0 | 202 | // Scroll events |
michael@0 | 203 | #define NS_MOUSE_SCROLL_START 1600 |
michael@0 | 204 | #define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START) |
michael@0 | 205 | #define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1) |
michael@0 | 206 | |
michael@0 | 207 | #define NS_SCROLLPORT_START 1700 |
michael@0 | 208 | #define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START) |
michael@0 | 209 | #define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1) |
michael@0 | 210 | |
michael@0 | 211 | #define NS_MUTATION_START 1800 |
michael@0 | 212 | #define NS_MUTATION_SUBTREEMODIFIED (NS_MUTATION_START) |
michael@0 | 213 | #define NS_MUTATION_NODEINSERTED (NS_MUTATION_START+1) |
michael@0 | 214 | #define NS_MUTATION_NODEREMOVED (NS_MUTATION_START+2) |
michael@0 | 215 | #define NS_MUTATION_NODEREMOVEDFROMDOCUMENT (NS_MUTATION_START+3) |
michael@0 | 216 | #define NS_MUTATION_NODEINSERTEDINTODOCUMENT (NS_MUTATION_START+4) |
michael@0 | 217 | #define NS_MUTATION_ATTRMODIFIED (NS_MUTATION_START+5) |
michael@0 | 218 | #define NS_MUTATION_CHARACTERDATAMODIFIED (NS_MUTATION_START+6) |
michael@0 | 219 | #define NS_MUTATION_END (NS_MUTATION_START+6) |
michael@0 | 220 | |
michael@0 | 221 | #define NS_USER_DEFINED_EVENT 2000 |
michael@0 | 222 | |
michael@0 | 223 | // composition events |
michael@0 | 224 | #define NS_COMPOSITION_EVENT_START 2200 |
michael@0 | 225 | #define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START) |
michael@0 | 226 | #define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1) |
michael@0 | 227 | #define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2) |
michael@0 | 228 | |
michael@0 | 229 | // text events |
michael@0 | 230 | #define NS_TEXT_START 2400 |
michael@0 | 231 | #define NS_TEXT_TEXT (NS_TEXT_START) |
michael@0 | 232 | |
michael@0 | 233 | // UI events |
michael@0 | 234 | #define NS_UI_EVENT_START 2500 |
michael@0 | 235 | // this is not to be confused with NS_ACTIVATE! |
michael@0 | 236 | #define NS_UI_ACTIVATE (NS_UI_EVENT_START) |
michael@0 | 237 | #define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1) |
michael@0 | 238 | #define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2) |
michael@0 | 239 | |
michael@0 | 240 | // pagetransition events |
michael@0 | 241 | #define NS_PAGETRANSITION_START 2700 |
michael@0 | 242 | #define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1) |
michael@0 | 243 | #define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2) |
michael@0 | 244 | |
michael@0 | 245 | // SVG events |
michael@0 | 246 | #define NS_SVG_EVENT_START 2800 |
michael@0 | 247 | #define NS_SVG_LOAD (NS_SVG_EVENT_START) |
michael@0 | 248 | #define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1) |
michael@0 | 249 | #define NS_SVG_ABORT (NS_SVG_EVENT_START + 2) |
michael@0 | 250 | #define NS_SVG_ERROR (NS_SVG_EVENT_START + 3) |
michael@0 | 251 | #define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4) |
michael@0 | 252 | #define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5) |
michael@0 | 253 | |
michael@0 | 254 | // SVG Zoom events |
michael@0 | 255 | #define NS_SVGZOOM_EVENT_START 2900 |
michael@0 | 256 | #define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START) |
michael@0 | 257 | |
michael@0 | 258 | // XUL command events |
michael@0 | 259 | #define NS_XULCOMMAND_EVENT_START 3000 |
michael@0 | 260 | #define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START) |
michael@0 | 261 | |
michael@0 | 262 | // Cut, copy, paste events |
michael@0 | 263 | #define NS_CUTCOPYPASTE_EVENT_START 3100 |
michael@0 | 264 | #define NS_COPY (NS_CUTCOPYPASTE_EVENT_START) |
michael@0 | 265 | #define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1) |
michael@0 | 266 | #define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2) |
michael@0 | 267 | |
michael@0 | 268 | // Query the content information |
michael@0 | 269 | #define NS_QUERY_CONTENT_EVENT_START 3200 |
michael@0 | 270 | // Query for the selected text information, it return the selection offset, |
michael@0 | 271 | // selection length and selected text. |
michael@0 | 272 | #define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START) |
michael@0 | 273 | // Query for the text content of specified range, it returns actual lengh (if |
michael@0 | 274 | // the specified range is too long) and the text of the specified range. |
michael@0 | 275 | // Returns the entire text if requested length > actual length. |
michael@0 | 276 | #define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1) |
michael@0 | 277 | // Query for the caret rect of nth insertion point. The offset of the result is |
michael@0 | 278 | // relative position from the top level widget. |
michael@0 | 279 | #define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3) |
michael@0 | 280 | // Query for the bounding rect of a range of characters. This works on any |
michael@0 | 281 | // valid character range given offset and length. Result is relative to top |
michael@0 | 282 | // level widget coordinates |
michael@0 | 283 | #define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4) |
michael@0 | 284 | // Query for the bounding rect of the current focused frame. Result is relative |
michael@0 | 285 | // to top level widget coordinates |
michael@0 | 286 | #define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5) |
michael@0 | 287 | // Query for the current state of the content. The particular members of |
michael@0 | 288 | // mReply that are set for each query content event will be valid on success. |
michael@0 | 289 | #define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6) |
michael@0 | 290 | // Query for the selection in the form of a nsITransferable. |
michael@0 | 291 | #define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7) |
michael@0 | 292 | // Query for character at a point. This returns the character offset and its |
michael@0 | 293 | // rect. The point is specified by Event::refPoint. |
michael@0 | 294 | #define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8) |
michael@0 | 295 | // Query if the DOM element under Event::refPoint belongs to our widget |
michael@0 | 296 | // or not. |
michael@0 | 297 | #define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9) |
michael@0 | 298 | |
michael@0 | 299 | // Video events |
michael@0 | 300 | #define NS_MEDIA_EVENT_START 3300 |
michael@0 | 301 | #define NS_LOADSTART (NS_MEDIA_EVENT_START) |
michael@0 | 302 | #define NS_PROGRESS (NS_MEDIA_EVENT_START+1) |
michael@0 | 303 | #define NS_SUSPEND (NS_MEDIA_EVENT_START+2) |
michael@0 | 304 | #define NS_EMPTIED (NS_MEDIA_EVENT_START+3) |
michael@0 | 305 | #define NS_STALLED (NS_MEDIA_EVENT_START+4) |
michael@0 | 306 | #define NS_PLAY (NS_MEDIA_EVENT_START+5) |
michael@0 | 307 | #define NS_PAUSE (NS_MEDIA_EVENT_START+6) |
michael@0 | 308 | #define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7) |
michael@0 | 309 | #define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8) |
michael@0 | 310 | #define NS_WAITING (NS_MEDIA_EVENT_START+9) |
michael@0 | 311 | #define NS_PLAYING (NS_MEDIA_EVENT_START+10) |
michael@0 | 312 | #define NS_CANPLAY (NS_MEDIA_EVENT_START+11) |
michael@0 | 313 | #define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12) |
michael@0 | 314 | #define NS_SEEKING (NS_MEDIA_EVENT_START+13) |
michael@0 | 315 | #define NS_SEEKED (NS_MEDIA_EVENT_START+14) |
michael@0 | 316 | #define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15) |
michael@0 | 317 | #define NS_ENDED (NS_MEDIA_EVENT_START+16) |
michael@0 | 318 | #define NS_RATECHANGE (NS_MEDIA_EVENT_START+17) |
michael@0 | 319 | #define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18) |
michael@0 | 320 | #define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19) |
michael@0 | 321 | |
michael@0 | 322 | // paint notification events |
michael@0 | 323 | #define NS_NOTIFYPAINT_START 3400 |
michael@0 | 324 | #define NS_AFTERPAINT (NS_NOTIFYPAINT_START) |
michael@0 | 325 | |
michael@0 | 326 | // Simple gesture events |
michael@0 | 327 | #define NS_SIMPLE_GESTURE_EVENT_START 3500 |
michael@0 | 328 | #define NS_SIMPLE_GESTURE_SWIPE_START (NS_SIMPLE_GESTURE_EVENT_START) |
michael@0 | 329 | #define NS_SIMPLE_GESTURE_SWIPE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+1) |
michael@0 | 330 | #define NS_SIMPLE_GESTURE_SWIPE_END (NS_SIMPLE_GESTURE_EVENT_START+2) |
michael@0 | 331 | #define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START+3) |
michael@0 | 332 | #define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+4) |
michael@0 | 333 | #define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5) |
michael@0 | 334 | #define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+6) |
michael@0 | 335 | #define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+7) |
michael@0 | 336 | #define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+8) |
michael@0 | 337 | #define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+9) |
michael@0 | 338 | #define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+10) |
michael@0 | 339 | #define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+11) |
michael@0 | 340 | #define NS_SIMPLE_GESTURE_EDGE_STARTED (NS_SIMPLE_GESTURE_EVENT_START+12) |
michael@0 | 341 | #define NS_SIMPLE_GESTURE_EDGE_CANCELED (NS_SIMPLE_GESTURE_EVENT_START+13) |
michael@0 | 342 | #define NS_SIMPLE_GESTURE_EDGE_COMPLETED (NS_SIMPLE_GESTURE_EVENT_START+14) |
michael@0 | 343 | |
michael@0 | 344 | // These are used to send native events to plugins. |
michael@0 | 345 | #define NS_PLUGIN_EVENT_START 3600 |
michael@0 | 346 | #define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START) |
michael@0 | 347 | #define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1) |
michael@0 | 348 | |
michael@0 | 349 | // Events to manipulate selection (WidgetSelectionEvent) |
michael@0 | 350 | #define NS_SELECTION_EVENT_START 3700 |
michael@0 | 351 | // Clear any previous selection and set the given range as the selection |
michael@0 | 352 | #define NS_SELECTION_SET (NS_SELECTION_EVENT_START) |
michael@0 | 353 | |
michael@0 | 354 | // Events of commands for the contents |
michael@0 | 355 | #define NS_CONTENT_COMMAND_EVENT_START 3800 |
michael@0 | 356 | #define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START) |
michael@0 | 357 | #define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1) |
michael@0 | 358 | #define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2) |
michael@0 | 359 | #define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3) |
michael@0 | 360 | #define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4) |
michael@0 | 361 | #define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5) |
michael@0 | 362 | #define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6) |
michael@0 | 363 | // NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the |
michael@0 | 364 | // currently focused content or latest DOM selection. This would normally be |
michael@0 | 365 | // the same element scrolled by keyboard scroll commands, except that this event |
michael@0 | 366 | // will scroll an element scrollable in either direction. I.e., if the nearest |
michael@0 | 367 | // scrollable ancestor element can only be scrolled vertically, and horizontal |
michael@0 | 368 | // scrolling is requested using this event, no scrolling will occur. |
michael@0 | 369 | #define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7) |
michael@0 | 370 | |
michael@0 | 371 | // Event to gesture notification |
michael@0 | 372 | #define NS_GESTURENOTIFY_EVENT_START 3900 |
michael@0 | 373 | |
michael@0 | 374 | #define NS_ORIENTATION_EVENT 4000 |
michael@0 | 375 | |
michael@0 | 376 | #define NS_SCROLLAREA_EVENT_START 4100 |
michael@0 | 377 | #define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START) |
michael@0 | 378 | |
michael@0 | 379 | #define NS_TRANSITION_EVENT_START 4200 |
michael@0 | 380 | #define NS_TRANSITION_END (NS_TRANSITION_EVENT_START) |
michael@0 | 381 | |
michael@0 | 382 | #define NS_ANIMATION_EVENT_START 4250 |
michael@0 | 383 | #define NS_ANIMATION_START (NS_ANIMATION_EVENT_START) |
michael@0 | 384 | #define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1) |
michael@0 | 385 | #define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2) |
michael@0 | 386 | |
michael@0 | 387 | #define NS_SMIL_TIME_EVENT_START 4300 |
michael@0 | 388 | #define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START) |
michael@0 | 389 | #define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1) |
michael@0 | 390 | #define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2) |
michael@0 | 391 | |
michael@0 | 392 | #define NS_WEBAUDIO_EVENT_START 4350 |
michael@0 | 393 | #define NS_AUDIO_PROCESS (NS_WEBAUDIO_EVENT_START) |
michael@0 | 394 | #define NS_AUDIO_COMPLETE (NS_WEBAUDIO_EVENT_START + 1) |
michael@0 | 395 | |
michael@0 | 396 | // script notification events |
michael@0 | 397 | #define NS_NOTIFYSCRIPT_START 4500 |
michael@0 | 398 | #define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START) |
michael@0 | 399 | #define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1) |
michael@0 | 400 | |
michael@0 | 401 | #define NS_PRINT_EVENT_START 4600 |
michael@0 | 402 | #define NS_BEFOREPRINT (NS_PRINT_EVENT_START) |
michael@0 | 403 | #define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1) |
michael@0 | 404 | |
michael@0 | 405 | #define NS_MESSAGE_EVENT_START 4700 |
michael@0 | 406 | #define NS_MESSAGE (NS_MESSAGE_EVENT_START) |
michael@0 | 407 | |
michael@0 | 408 | // Open and close events |
michael@0 | 409 | #define NS_OPENCLOSE_EVENT_START 4800 |
michael@0 | 410 | #define NS_OPEN (NS_OPENCLOSE_EVENT_START) |
michael@0 | 411 | #define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1) |
michael@0 | 412 | |
michael@0 | 413 | // Device motion and orientation |
michael@0 | 414 | #define NS_DEVICE_ORIENTATION_START 4900 |
michael@0 | 415 | #define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START) |
michael@0 | 416 | #define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1) |
michael@0 | 417 | #define NS_DEVICE_PROXIMITY (NS_DEVICE_ORIENTATION_START+2) |
michael@0 | 418 | #define NS_USER_PROXIMITY (NS_DEVICE_ORIENTATION_START+3) |
michael@0 | 419 | #define NS_DEVICE_LIGHT (NS_DEVICE_ORIENTATION_START+4) |
michael@0 | 420 | |
michael@0 | 421 | #define NS_SHOW_EVENT 5000 |
michael@0 | 422 | |
michael@0 | 423 | // Fullscreen DOM API |
michael@0 | 424 | #define NS_FULL_SCREEN_START 5100 |
michael@0 | 425 | #define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START) |
michael@0 | 426 | #define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1) |
michael@0 | 427 | |
michael@0 | 428 | #define NS_TOUCH_EVENT_START 5200 |
michael@0 | 429 | #define NS_TOUCH_START (NS_TOUCH_EVENT_START) |
michael@0 | 430 | #define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1) |
michael@0 | 431 | #define NS_TOUCH_END (NS_TOUCH_EVENT_START+2) |
michael@0 | 432 | #define NS_TOUCH_ENTER (NS_TOUCH_EVENT_START+3) |
michael@0 | 433 | #define NS_TOUCH_LEAVE (NS_TOUCH_EVENT_START+4) |
michael@0 | 434 | #define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+5) |
michael@0 | 435 | |
michael@0 | 436 | // Pointerlock DOM API |
michael@0 | 437 | #define NS_POINTERLOCK_START 5300 |
michael@0 | 438 | #define NS_POINTERLOCKCHANGE (NS_POINTERLOCK_START) |
michael@0 | 439 | #define NS_POINTERLOCKERROR (NS_POINTERLOCK_START + 1) |
michael@0 | 440 | |
michael@0 | 441 | #define NS_WHEEL_EVENT_START 5400 |
michael@0 | 442 | #define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START) |
michael@0 | 443 | #define NS_WHEEL_START (NS_WHEEL_EVENT_START + 1) |
michael@0 | 444 | #define NS_WHEEL_STOP (NS_WHEEL_EVENT_START + 2) |
michael@0 | 445 | |
michael@0 | 446 | //System time is changed |
michael@0 | 447 | #define NS_MOZ_TIME_CHANGE_EVENT 5500 |
michael@0 | 448 | |
michael@0 | 449 | // Network packet events. |
michael@0 | 450 | #define NS_NETWORK_EVENT_START 5600 |
michael@0 | 451 | #define NS_NETWORK_UPLOAD_EVENT (NS_NETWORK_EVENT_START + 1) |
michael@0 | 452 | #define NS_NETWORK_DOWNLOAD_EVENT (NS_NETWORK_EVENT_START + 2) |
michael@0 | 453 | |
michael@0 | 454 | // MediaRecorder events. |
michael@0 | 455 | #define NS_MEDIARECORDER_EVENT_START 5700 |
michael@0 | 456 | #define NS_MEDIARECORDER_DATAAVAILABLE (NS_MEDIARECORDER_EVENT_START + 1) |
michael@0 | 457 | #define NS_MEDIARECORDER_WARNING (NS_MEDIARECORDER_EVENT_START + 2) |
michael@0 | 458 | #define NS_MEDIARECORDER_STOP (NS_MEDIARECORDER_EVENT_START + 3) |
michael@0 | 459 | |
michael@0 | 460 | // SpeakerManager events |
michael@0 | 461 | #define NS_SPEAKERMANAGER_EVENT_START 5800 |
michael@0 | 462 | #define NS_SPEAKERMANAGER_SPEAKERFORCEDCHANGE (NS_SPEAKERMANAGER_EVENT_START + 1) |
michael@0 | 463 | |
michael@0 | 464 | #ifdef MOZ_GAMEPAD |
michael@0 | 465 | // Gamepad input events |
michael@0 | 466 | #define NS_GAMEPAD_START 6000 |
michael@0 | 467 | #define NS_GAMEPAD_BUTTONDOWN (NS_GAMEPAD_START) |
michael@0 | 468 | #define NS_GAMEPAD_BUTTONUP (NS_GAMEPAD_START+1) |
michael@0 | 469 | #define NS_GAMEPAD_AXISMOVE (NS_GAMEPAD_START+2) |
michael@0 | 470 | #define NS_GAMEPAD_CONNECTED (NS_GAMEPAD_START+3) |
michael@0 | 471 | #define NS_GAMEPAD_DISCONNECTED (NS_GAMEPAD_START+4) |
michael@0 | 472 | // Keep this defined to the same value as the event above |
michael@0 | 473 | #define NS_GAMEPAD_END (NS_GAMEPAD_START+4) |
michael@0 | 474 | #endif |
michael@0 | 475 | |
michael@0 | 476 | // input and beforeinput events. |
michael@0 | 477 | #define NS_EDITOR_EVENT_START 6100 |
michael@0 | 478 | #define NS_EDITOR_INPUT (NS_EDITOR_EVENT_START) |
michael@0 | 479 | |
michael@0 | 480 | namespace mozilla { |
michael@0 | 481 | |
michael@0 | 482 | /****************************************************************************** |
michael@0 | 483 | * mozilla::BaseEventFlags |
michael@0 | 484 | * |
michael@0 | 485 | * BaseEventFlags must be a POD struct for safe to use memcpy (including |
michael@0 | 486 | * in ParamTraits<BaseEventFlags>). So don't make virtual methods, constructor, |
michael@0 | 487 | * destructor and operators. |
michael@0 | 488 | * This is necessary for VC which is NOT C++0x compiler. |
michael@0 | 489 | ******************************************************************************/ |
michael@0 | 490 | |
michael@0 | 491 | struct BaseEventFlags |
michael@0 | 492 | { |
michael@0 | 493 | public: |
michael@0 | 494 | // If mIsTrusted is true, the event is a trusted event. Otherwise, it's |
michael@0 | 495 | // an untrusted event. |
michael@0 | 496 | bool mIsTrusted : 1; |
michael@0 | 497 | // If mInBubblingPhase is true, the event is in bubbling phase or target |
michael@0 | 498 | // phase. |
michael@0 | 499 | bool mInBubblingPhase : 1; |
michael@0 | 500 | // If mInCapturePhase is true, the event is in capture phase or target phase. |
michael@0 | 501 | bool mInCapturePhase : 1; |
michael@0 | 502 | // If mInSystemGroup is true, the event is being dispatched in system group. |
michael@0 | 503 | bool mInSystemGroup: 1; |
michael@0 | 504 | // If mCancelable is true, the event can be consumed. I.e., calling |
michael@0 | 505 | // dom::Event::PreventDefault() can prevent the default action. |
michael@0 | 506 | bool mCancelable : 1; |
michael@0 | 507 | // If mBubbles is true, the event can bubble. Otherwise, cannot be handled |
michael@0 | 508 | // in bubbling phase. |
michael@0 | 509 | bool mBubbles : 1; |
michael@0 | 510 | // If mPropagationStopped is true, dom::Event::StopPropagation() or |
michael@0 | 511 | // dom::Event::StopImmediatePropagation() has been called. |
michael@0 | 512 | bool mPropagationStopped : 1; |
michael@0 | 513 | // If mImmediatePropagationStopped is true, |
michael@0 | 514 | // dom::Event::StopImmediatePropagation() has been called. |
michael@0 | 515 | // Note that mPropagationStopped must be true when this is true. |
michael@0 | 516 | bool mImmediatePropagationStopped : 1; |
michael@0 | 517 | // If mDefaultPrevented is true, the event has been consumed. |
michael@0 | 518 | // E.g., dom::Event::PreventDefault() has been called or |
michael@0 | 519 | // the default action has been performed. |
michael@0 | 520 | bool mDefaultPrevented : 1; |
michael@0 | 521 | // If mDefaultPreventedByContent is true, the event has been |
michael@0 | 522 | // consumed by content. |
michael@0 | 523 | // Note that mDefaultPrevented must be true when this is true. |
michael@0 | 524 | bool mDefaultPreventedByContent : 1; |
michael@0 | 525 | // mMultipleActionsPrevented may be used when default handling don't want to |
michael@0 | 526 | // be prevented, but only one of the event targets should handle the event. |
michael@0 | 527 | // For example, when a <label> element is in another <label> element and |
michael@0 | 528 | // the first <label> element is clicked, that one may set this true. |
michael@0 | 529 | // Then, the second <label> element won't handle the event. |
michael@0 | 530 | bool mMultipleActionsPrevented : 1; |
michael@0 | 531 | // If mIsBeingDispatched is true, the DOM event created from the event is |
michael@0 | 532 | // dispatching into the DOM tree and not completed. |
michael@0 | 533 | bool mIsBeingDispatched : 1; |
michael@0 | 534 | // If mDispatchedAtLeastOnce is true, the event has been dispatched |
michael@0 | 535 | // as a DOM event and the dispatch has been completed. |
michael@0 | 536 | bool mDispatchedAtLeastOnce : 1; |
michael@0 | 537 | // If mIsSynthesizedForTests is true, the event has been synthesized for |
michael@0 | 538 | // automated tests or something hacky approach of an add-on. |
michael@0 | 539 | bool mIsSynthesizedForTests : 1; |
michael@0 | 540 | // If mExceptionHasBeenRisen is true, one of the event handlers has risen an |
michael@0 | 541 | // exception. |
michael@0 | 542 | bool mExceptionHasBeenRisen : 1; |
michael@0 | 543 | // If mRetargetToNonNativeAnonymous is true and the target is in a non-native |
michael@0 | 544 | // native anonymous subtree, the event target is set to originalTarget. |
michael@0 | 545 | bool mRetargetToNonNativeAnonymous : 1; |
michael@0 | 546 | // If mNoCrossProcessBoundaryForwarding is true, the event is not allowed to |
michael@0 | 547 | // cross process boundary. |
michael@0 | 548 | bool mNoCrossProcessBoundaryForwarding : 1; |
michael@0 | 549 | // If mNoContentDispatch is true, the event is never dispatched to the |
michael@0 | 550 | // event handlers which are added to the contents, onfoo attributes and |
michael@0 | 551 | // properties. Note that this flag is ignored when |
michael@0 | 552 | // EventChainPreVisitor::mForceContentDispatch is set true. For exapmle, |
michael@0 | 553 | // window and document object sets it true. Therefore, web applications |
michael@0 | 554 | // can handle the event if they add event listeners to the window or the |
michael@0 | 555 | // document. |
michael@0 | 556 | bool mNoContentDispatch : 1; |
michael@0 | 557 | // If mOnlyChromeDispatch is true, the event is dispatched to only chrome. |
michael@0 | 558 | bool mOnlyChromeDispatch : 1; |
michael@0 | 559 | // If mWantReplyFromContentProcess is true, the event will be redispatched |
michael@0 | 560 | // in the parent process after the content process has handled it. Useful |
michael@0 | 561 | // for when the parent process need the know first how the event was used |
michael@0 | 562 | // by content before handling it itself. |
michael@0 | 563 | bool mWantReplyFromContentProcess : 1; |
michael@0 | 564 | |
michael@0 | 565 | // If the event is being handled in target phase, returns true. |
michael@0 | 566 | inline bool InTargetPhase() const |
michael@0 | 567 | { |
michael@0 | 568 | return (mInBubblingPhase && mInCapturePhase); |
michael@0 | 569 | } |
michael@0 | 570 | |
michael@0 | 571 | inline void Clear() |
michael@0 | 572 | { |
michael@0 | 573 | SetRawFlags(0); |
michael@0 | 574 | } |
michael@0 | 575 | // Get if either the instance's bit or the aOther's bit is true, the |
michael@0 | 576 | // instance's bit becomes true. In other words, this works like: |
michael@0 | 577 | // eventFlags |= aOther; |
michael@0 | 578 | inline void Union(const BaseEventFlags& aOther) |
michael@0 | 579 | { |
michael@0 | 580 | RawFlags rawFlags = GetRawFlags() | aOther.GetRawFlags(); |
michael@0 | 581 | SetRawFlags(rawFlags); |
michael@0 | 582 | } |
michael@0 | 583 | |
michael@0 | 584 | private: |
michael@0 | 585 | typedef uint32_t RawFlags; |
michael@0 | 586 | |
michael@0 | 587 | inline void SetRawFlags(RawFlags aRawFlags) |
michael@0 | 588 | { |
michael@0 | 589 | static_assert(sizeof(BaseEventFlags) <= sizeof(RawFlags), |
michael@0 | 590 | "mozilla::EventFlags must not be bigger than the RawFlags"); |
michael@0 | 591 | memcpy(this, &aRawFlags, sizeof(BaseEventFlags)); |
michael@0 | 592 | } |
michael@0 | 593 | inline RawFlags GetRawFlags() const |
michael@0 | 594 | { |
michael@0 | 595 | RawFlags result = 0; |
michael@0 | 596 | memcpy(&result, this, sizeof(BaseEventFlags)); |
michael@0 | 597 | return result; |
michael@0 | 598 | } |
michael@0 | 599 | }; |
michael@0 | 600 | |
michael@0 | 601 | /****************************************************************************** |
michael@0 | 602 | * mozilla::EventFlags |
michael@0 | 603 | ******************************************************************************/ |
michael@0 | 604 | |
michael@0 | 605 | struct EventFlags : public BaseEventFlags |
michael@0 | 606 | { |
michael@0 | 607 | EventFlags() |
michael@0 | 608 | { |
michael@0 | 609 | Clear(); |
michael@0 | 610 | } |
michael@0 | 611 | }; |
michael@0 | 612 | |
michael@0 | 613 | /****************************************************************************** |
michael@0 | 614 | * mozilla::WidgetEvent |
michael@0 | 615 | ******************************************************************************/ |
michael@0 | 616 | |
michael@0 | 617 | class WidgetEvent |
michael@0 | 618 | { |
michael@0 | 619 | protected: |
michael@0 | 620 | WidgetEvent(bool aIsTrusted, uint32_t aMessage, |
michael@0 | 621 | nsEventStructType aStructType) : |
michael@0 | 622 | eventStructType(aStructType), message(aMessage), refPoint(0, 0), |
michael@0 | 623 | lastRefPoint(0, 0), time(0), userType(0) |
michael@0 | 624 | { |
michael@0 | 625 | MOZ_COUNT_CTOR(WidgetEvent); |
michael@0 | 626 | mFlags.Clear(); |
michael@0 | 627 | mFlags.mIsTrusted = aIsTrusted; |
michael@0 | 628 | mFlags.mCancelable = true; |
michael@0 | 629 | mFlags.mBubbles = true; |
michael@0 | 630 | } |
michael@0 | 631 | |
michael@0 | 632 | WidgetEvent() |
michael@0 | 633 | { |
michael@0 | 634 | MOZ_COUNT_CTOR(WidgetEvent); |
michael@0 | 635 | } |
michael@0 | 636 | |
michael@0 | 637 | public: |
michael@0 | 638 | WidgetEvent(bool aIsTrusted, uint32_t aMessage) : |
michael@0 | 639 | eventStructType(NS_EVENT), message(aMessage), refPoint(0, 0), |
michael@0 | 640 | lastRefPoint(0, 0), time(0), userType(0) |
michael@0 | 641 | { |
michael@0 | 642 | MOZ_COUNT_CTOR(WidgetEvent); |
michael@0 | 643 | mFlags.Clear(); |
michael@0 | 644 | mFlags.mIsTrusted = aIsTrusted; |
michael@0 | 645 | mFlags.mCancelable = true; |
michael@0 | 646 | mFlags.mBubbles = true; |
michael@0 | 647 | } |
michael@0 | 648 | |
michael@0 | 649 | virtual ~WidgetEvent() |
michael@0 | 650 | { |
michael@0 | 651 | MOZ_COUNT_DTOR(WidgetEvent); |
michael@0 | 652 | } |
michael@0 | 653 | |
michael@0 | 654 | WidgetEvent(const WidgetEvent& aOther) |
michael@0 | 655 | { |
michael@0 | 656 | MOZ_COUNT_CTOR(WidgetEvent); |
michael@0 | 657 | *this = aOther; |
michael@0 | 658 | } |
michael@0 | 659 | |
michael@0 | 660 | virtual WidgetEvent* Duplicate() const |
michael@0 | 661 | { |
michael@0 | 662 | MOZ_ASSERT(eventStructType == NS_EVENT, |
michael@0 | 663 | "Duplicate() must be overridden by sub class"); |
michael@0 | 664 | WidgetEvent* result = new WidgetEvent(false, message); |
michael@0 | 665 | result->AssignEventData(*this, true); |
michael@0 | 666 | result->mFlags = mFlags; |
michael@0 | 667 | return result; |
michael@0 | 668 | } |
michael@0 | 669 | |
michael@0 | 670 | // See event struct types |
michael@0 | 671 | nsEventStructType eventStructType; |
michael@0 | 672 | // See GUI MESSAGES, |
michael@0 | 673 | uint32_t message; |
michael@0 | 674 | // Relative to the widget of the event, or if there is no widget then it is |
michael@0 | 675 | // in screen coordinates. Not modified by layout code. |
michael@0 | 676 | LayoutDeviceIntPoint refPoint; |
michael@0 | 677 | // The previous refPoint, if known, used to calculate mouse movement deltas. |
michael@0 | 678 | LayoutDeviceIntPoint lastRefPoint; |
michael@0 | 679 | // Elapsed time, in milliseconds, from a platform-specific zero time |
michael@0 | 680 | // to the time the message was created |
michael@0 | 681 | uint64_t time; |
michael@0 | 682 | // See BaseEventFlags definition for the detail. |
michael@0 | 683 | BaseEventFlags mFlags; |
michael@0 | 684 | |
michael@0 | 685 | // Additional type info for user defined events |
michael@0 | 686 | nsCOMPtr<nsIAtom> userType; |
michael@0 | 687 | |
michael@0 | 688 | nsString typeString; // always set on non-main-thread events |
michael@0 | 689 | |
michael@0 | 690 | // Event targets, needed by DOM Events |
michael@0 | 691 | nsCOMPtr<dom::EventTarget> target; |
michael@0 | 692 | nsCOMPtr<dom::EventTarget> currentTarget; |
michael@0 | 693 | nsCOMPtr<dom::EventTarget> originalTarget; |
michael@0 | 694 | |
michael@0 | 695 | void AssignEventData(const WidgetEvent& aEvent, bool aCopyTargets) |
michael@0 | 696 | { |
michael@0 | 697 | // eventStructType should be initialized with the constructor. |
michael@0 | 698 | // However, NS_SVGZOOM_EVENT and NS_SMIL_TIME_EVENT are set after that. |
michael@0 | 699 | // Therefore, we need to copy eventStructType here. |
michael@0 | 700 | eventStructType = aEvent.eventStructType; |
michael@0 | 701 | // message should be initialized with the constructor. |
michael@0 | 702 | refPoint = aEvent.refPoint; |
michael@0 | 703 | // lastRefPoint doesn't need to be copied. |
michael@0 | 704 | time = aEvent.time; |
michael@0 | 705 | // mFlags should be copied manually if it's necessary. |
michael@0 | 706 | userType = aEvent.userType; |
michael@0 | 707 | // typeString should be copied manually if it's necessary. |
michael@0 | 708 | target = aCopyTargets ? aEvent.target : nullptr; |
michael@0 | 709 | currentTarget = aCopyTargets ? aEvent.currentTarget : nullptr; |
michael@0 | 710 | originalTarget = aCopyTargets ? aEvent.originalTarget : nullptr; |
michael@0 | 711 | } |
michael@0 | 712 | |
michael@0 | 713 | /** |
michael@0 | 714 | * Utils for checking event types |
michael@0 | 715 | */ |
michael@0 | 716 | |
michael@0 | 717 | /** |
michael@0 | 718 | * As*Event() returns the pointer of the instance only when the instance is |
michael@0 | 719 | * the class or one of its derived class. |
michael@0 | 720 | */ |
michael@0 | 721 | #define NS_ROOT_EVENT_CLASS(aPrefix, aName) |
michael@0 | 722 | #define NS_EVENT_CLASS(aPrefix, aName) \ |
michael@0 | 723 | virtual aPrefix##aName* As##aName(); \ |
michael@0 | 724 | const aPrefix##aName* As##aName() const; |
michael@0 | 725 | |
michael@0 | 726 | #include "mozilla/EventClassList.h" |
michael@0 | 727 | |
michael@0 | 728 | #undef NS_EVENT_CLASS |
michael@0 | 729 | #undef NS_ROOT_EVENT_CLASS |
michael@0 | 730 | |
michael@0 | 731 | /** |
michael@0 | 732 | * Returns true if the event is a query content event. |
michael@0 | 733 | */ |
michael@0 | 734 | bool IsQueryContentEvent() const; |
michael@0 | 735 | /** |
michael@0 | 736 | * Returns true if the event is a selection event. |
michael@0 | 737 | */ |
michael@0 | 738 | bool IsSelectionEvent() const; |
michael@0 | 739 | /** |
michael@0 | 740 | * Returns true if the event is a content command event. |
michael@0 | 741 | */ |
michael@0 | 742 | bool IsContentCommandEvent() const; |
michael@0 | 743 | /** |
michael@0 | 744 | * Returns true if the event is a native event deliverer event for plugin. |
michael@0 | 745 | */ |
michael@0 | 746 | bool IsNativeEventDelivererForPlugin() const; |
michael@0 | 747 | |
michael@0 | 748 | /** |
michael@0 | 749 | * Returns true if the event message is one of mouse events. |
michael@0 | 750 | */ |
michael@0 | 751 | bool HasMouseEventMessage() const; |
michael@0 | 752 | /** |
michael@0 | 753 | * Returns true if the event message is one of drag events. |
michael@0 | 754 | */ |
michael@0 | 755 | bool HasDragEventMessage() const; |
michael@0 | 756 | /** |
michael@0 | 757 | * Returns true if the event message is one of key events. |
michael@0 | 758 | */ |
michael@0 | 759 | bool HasKeyEventMessage() const; |
michael@0 | 760 | /** |
michael@0 | 761 | * Returns true if the event message is one of composition events or text |
michael@0 | 762 | * event. |
michael@0 | 763 | */ |
michael@0 | 764 | bool HasIMEEventMessage() const; |
michael@0 | 765 | /** |
michael@0 | 766 | * Returns true if the event message is one of plugin activation events. |
michael@0 | 767 | */ |
michael@0 | 768 | bool HasPluginActivationEventMessage() const; |
michael@0 | 769 | |
michael@0 | 770 | /** |
michael@0 | 771 | * Returns true if the event is native event deliverer event for plugin and |
michael@0 | 772 | * it should be retarted to focused document. |
michael@0 | 773 | */ |
michael@0 | 774 | bool IsRetargetedNativeEventDelivererForPlugin() const; |
michael@0 | 775 | /** |
michael@0 | 776 | * Returns true if the event is native event deliverer event for plugin and |
michael@0 | 777 | * it should NOT be retarted to focused document. |
michael@0 | 778 | */ |
michael@0 | 779 | bool IsNonRetargetedNativeEventDelivererForPlugin() const; |
michael@0 | 780 | /** |
michael@0 | 781 | * Returns true if the event is related to IME handling. It includes |
michael@0 | 782 | * IME events, query content events and selection events. |
michael@0 | 783 | * Be careful when you use this. |
michael@0 | 784 | */ |
michael@0 | 785 | bool IsIMERelatedEvent() const; |
michael@0 | 786 | |
michael@0 | 787 | /** |
michael@0 | 788 | * Whether the event should be handled by the frame of the mouse cursor |
michael@0 | 789 | * position or not. When it should be handled there (e.g., the mouse events), |
michael@0 | 790 | * this returns true. |
michael@0 | 791 | */ |
michael@0 | 792 | bool IsUsingCoordinates() const; |
michael@0 | 793 | /** |
michael@0 | 794 | * Whether the event should be handled by the focused DOM window in the |
michael@0 | 795 | * same top level window's or not. E.g., key events, IME related events |
michael@0 | 796 | * (including the query content events, they are used in IME transaction) |
michael@0 | 797 | * should be handled by the (last) focused window rather than the dispatched |
michael@0 | 798 | * window. |
michael@0 | 799 | * |
michael@0 | 800 | * NOTE: Even if this returns true, the event isn't going to be handled by the |
michael@0 | 801 | * application level active DOM window which is on another top level window. |
michael@0 | 802 | * So, when the event is fired on a deactive window, the event is going to be |
michael@0 | 803 | * handled by the last focused DOM window in the last focused window. |
michael@0 | 804 | */ |
michael@0 | 805 | bool IsTargetedAtFocusedWindow() const; |
michael@0 | 806 | /** |
michael@0 | 807 | * Whether the event should be handled by the focused content or not. E.g., |
michael@0 | 808 | * key events, IME related events and other input events which are not handled |
michael@0 | 809 | * by the frame of the mouse cursor position. |
michael@0 | 810 | * |
michael@0 | 811 | * NOTE: Even if this returns true, the event isn't going to be handled by the |
michael@0 | 812 | * application level active DOM window which is on another top level window. |
michael@0 | 813 | * So, when the event is fired on a deactive window, the event is going to be |
michael@0 | 814 | * handled by the last focused DOM element of the last focused DOM window in |
michael@0 | 815 | * the last focused window. |
michael@0 | 816 | */ |
michael@0 | 817 | bool IsTargetedAtFocusedContent() const; |
michael@0 | 818 | /** |
michael@0 | 819 | * Whether the event should cause a DOM event. |
michael@0 | 820 | */ |
michael@0 | 821 | bool IsAllowedToDispatchDOMEvent() const; |
michael@0 | 822 | }; |
michael@0 | 823 | |
michael@0 | 824 | /****************************************************************************** |
michael@0 | 825 | * mozilla::WidgetGUIEvent |
michael@0 | 826 | ******************************************************************************/ |
michael@0 | 827 | |
michael@0 | 828 | class WidgetGUIEvent : public WidgetEvent |
michael@0 | 829 | { |
michael@0 | 830 | protected: |
michael@0 | 831 | WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, |
michael@0 | 832 | nsEventStructType aStructType) : |
michael@0 | 833 | WidgetEvent(aIsTrusted, aMessage, aStructType), |
michael@0 | 834 | widget(aWidget), pluginEvent(nullptr) |
michael@0 | 835 | { |
michael@0 | 836 | } |
michael@0 | 837 | |
michael@0 | 838 | WidgetGUIEvent() : |
michael@0 | 839 | pluginEvent(nullptr) |
michael@0 | 840 | { |
michael@0 | 841 | } |
michael@0 | 842 | |
michael@0 | 843 | public: |
michael@0 | 844 | virtual WidgetGUIEvent* AsGUIEvent() MOZ_OVERRIDE { return this; } |
michael@0 | 845 | |
michael@0 | 846 | WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : |
michael@0 | 847 | WidgetEvent(aIsTrusted, aMessage, NS_GUI_EVENT), |
michael@0 | 848 | widget(aWidget), pluginEvent(nullptr) |
michael@0 | 849 | { |
michael@0 | 850 | } |
michael@0 | 851 | |
michael@0 | 852 | virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE |
michael@0 | 853 | { |
michael@0 | 854 | MOZ_ASSERT(eventStructType == NS_GUI_EVENT || |
michael@0 | 855 | eventStructType == NS_SVGZOOM_EVENT, |
michael@0 | 856 | "Duplicate() must be overridden by sub class"); |
michael@0 | 857 | // Not copying widget, it is a weak reference. |
michael@0 | 858 | WidgetGUIEvent* result = new WidgetGUIEvent(false, message, nullptr); |
michael@0 | 859 | result->AssignGUIEventData(*this, true); |
michael@0 | 860 | result->mFlags = mFlags; |
michael@0 | 861 | return result; |
michael@0 | 862 | } |
michael@0 | 863 | |
michael@0 | 864 | /// Originator of the event |
michael@0 | 865 | nsCOMPtr<nsIWidget> widget; |
michael@0 | 866 | |
michael@0 | 867 | /// Event for NPAPI plugin |
michael@0 | 868 | void* pluginEvent; |
michael@0 | 869 | |
michael@0 | 870 | void AssignGUIEventData(const WidgetGUIEvent& aEvent, bool aCopyTargets) |
michael@0 | 871 | { |
michael@0 | 872 | AssignEventData(aEvent, aCopyTargets); |
michael@0 | 873 | |
michael@0 | 874 | // widget should be initialized with the constructor. |
michael@0 | 875 | |
michael@0 | 876 | // pluginEvent shouldn't be copied because it may be referred after its |
michael@0 | 877 | // instance is destroyed. |
michael@0 | 878 | pluginEvent = nullptr; |
michael@0 | 879 | } |
michael@0 | 880 | }; |
michael@0 | 881 | |
michael@0 | 882 | /****************************************************************************** |
michael@0 | 883 | * mozilla::Modifier |
michael@0 | 884 | * |
michael@0 | 885 | * All modifier keys should be defined here. This is used for managing |
michael@0 | 886 | * modifier states for DOM Level 3 or later. |
michael@0 | 887 | ******************************************************************************/ |
michael@0 | 888 | |
michael@0 | 889 | enum Modifier |
michael@0 | 890 | { |
michael@0 | 891 | MODIFIER_ALT = 0x0001, |
michael@0 | 892 | MODIFIER_ALTGRAPH = 0x0002, |
michael@0 | 893 | MODIFIER_CAPSLOCK = 0x0004, |
michael@0 | 894 | MODIFIER_CONTROL = 0x0008, |
michael@0 | 895 | MODIFIER_FN = 0x0010, |
michael@0 | 896 | MODIFIER_META = 0x0020, |
michael@0 | 897 | MODIFIER_NUMLOCK = 0x0040, |
michael@0 | 898 | MODIFIER_SCROLLLOCK = 0x0080, |
michael@0 | 899 | MODIFIER_SHIFT = 0x0100, |
michael@0 | 900 | MODIFIER_SYMBOLLOCK = 0x0200, |
michael@0 | 901 | MODIFIER_OS = 0x0400 |
michael@0 | 902 | }; |
michael@0 | 903 | |
michael@0 | 904 | /****************************************************************************** |
michael@0 | 905 | * Modifier key names. |
michael@0 | 906 | ******************************************************************************/ |
michael@0 | 907 | |
michael@0 | 908 | #define NS_DOM_KEYNAME_ALT "Alt" |
michael@0 | 909 | #define NS_DOM_KEYNAME_ALTGRAPH "AltGraph" |
michael@0 | 910 | #define NS_DOM_KEYNAME_CAPSLOCK "CapsLock" |
michael@0 | 911 | #define NS_DOM_KEYNAME_CONTROL "Control" |
michael@0 | 912 | #define NS_DOM_KEYNAME_FN "Fn" |
michael@0 | 913 | #define NS_DOM_KEYNAME_META "Meta" |
michael@0 | 914 | #define NS_DOM_KEYNAME_NUMLOCK "NumLock" |
michael@0 | 915 | #define NS_DOM_KEYNAME_SCROLLLOCK "ScrollLock" |
michael@0 | 916 | #define NS_DOM_KEYNAME_SHIFT "Shift" |
michael@0 | 917 | #define NS_DOM_KEYNAME_SYMBOLLOCK "SymbolLock" |
michael@0 | 918 | #define NS_DOM_KEYNAME_OS "OS" |
michael@0 | 919 | |
michael@0 | 920 | /****************************************************************************** |
michael@0 | 921 | * mozilla::Modifiers |
michael@0 | 922 | ******************************************************************************/ |
michael@0 | 923 | |
michael@0 | 924 | typedef uint16_t Modifiers; |
michael@0 | 925 | |
michael@0 | 926 | /****************************************************************************** |
michael@0 | 927 | * mozilla::WidgetInputEvent |
michael@0 | 928 | ******************************************************************************/ |
michael@0 | 929 | |
michael@0 | 930 | class WidgetInputEvent : public WidgetGUIEvent |
michael@0 | 931 | { |
michael@0 | 932 | protected: |
michael@0 | 933 | WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, |
michael@0 | 934 | nsEventStructType aStructType) : |
michael@0 | 935 | WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aStructType), |
michael@0 | 936 | modifiers(0) |
michael@0 | 937 | { |
michael@0 | 938 | } |
michael@0 | 939 | |
michael@0 | 940 | WidgetInputEvent() |
michael@0 | 941 | { |
michael@0 | 942 | } |
michael@0 | 943 | |
michael@0 | 944 | public: |
michael@0 | 945 | virtual WidgetInputEvent* AsInputEvent() MOZ_OVERRIDE { return this; } |
michael@0 | 946 | |
michael@0 | 947 | WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : |
michael@0 | 948 | WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_INPUT_EVENT), |
michael@0 | 949 | modifiers(0) |
michael@0 | 950 | { |
michael@0 | 951 | } |
michael@0 | 952 | |
michael@0 | 953 | virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE |
michael@0 | 954 | { |
michael@0 | 955 | MOZ_ASSERT(eventStructType == NS_INPUT_EVENT, |
michael@0 | 956 | "Duplicate() must be overridden by sub class"); |
michael@0 | 957 | // Not copying widget, it is a weak reference. |
michael@0 | 958 | WidgetInputEvent* result = new WidgetInputEvent(false, message, nullptr); |
michael@0 | 959 | result->AssignInputEventData(*this, true); |
michael@0 | 960 | result->mFlags = mFlags; |
michael@0 | 961 | return result; |
michael@0 | 962 | } |
michael@0 | 963 | |
michael@0 | 964 | // true indicates the shift key is down |
michael@0 | 965 | bool IsShift() const |
michael@0 | 966 | { |
michael@0 | 967 | return ((modifiers & MODIFIER_SHIFT) != 0); |
michael@0 | 968 | } |
michael@0 | 969 | // true indicates the control key is down |
michael@0 | 970 | bool IsControl() const |
michael@0 | 971 | { |
michael@0 | 972 | return ((modifiers & MODIFIER_CONTROL) != 0); |
michael@0 | 973 | } |
michael@0 | 974 | // true indicates the alt key is down |
michael@0 | 975 | bool IsAlt() const |
michael@0 | 976 | { |
michael@0 | 977 | return ((modifiers & MODIFIER_ALT) != 0); |
michael@0 | 978 | } |
michael@0 | 979 | // true indicates the meta key is down (or, on Mac, the Command key) |
michael@0 | 980 | bool IsMeta() const |
michael@0 | 981 | { |
michael@0 | 982 | return ((modifiers & MODIFIER_META) != 0); |
michael@0 | 983 | } |
michael@0 | 984 | // true indicates the win key is down on Windows. Or the Super or Hyper key |
michael@0 | 985 | // is down on Linux. |
michael@0 | 986 | bool IsOS() const |
michael@0 | 987 | { |
michael@0 | 988 | return ((modifiers & MODIFIER_OS) != 0); |
michael@0 | 989 | } |
michael@0 | 990 | // true indicates the alt graph key is down |
michael@0 | 991 | // NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah() |
michael@0 | 992 | // return true. |
michael@0 | 993 | bool IsAltGraph() const |
michael@0 | 994 | { |
michael@0 | 995 | return ((modifiers & MODIFIER_ALTGRAPH) != 0); |
michael@0 | 996 | } |
michael@0 | 997 | // true indeicates the CapLock LED is turn on. |
michael@0 | 998 | bool IsCapsLocked() const |
michael@0 | 999 | { |
michael@0 | 1000 | return ((modifiers & MODIFIER_CAPSLOCK) != 0); |
michael@0 | 1001 | } |
michael@0 | 1002 | // true indeicates the NumLock LED is turn on. |
michael@0 | 1003 | bool IsNumLocked() const |
michael@0 | 1004 | { |
michael@0 | 1005 | return ((modifiers & MODIFIER_NUMLOCK) != 0); |
michael@0 | 1006 | } |
michael@0 | 1007 | // true indeicates the ScrollLock LED is turn on. |
michael@0 | 1008 | bool IsScrollLocked() const |
michael@0 | 1009 | { |
michael@0 | 1010 | return ((modifiers & MODIFIER_SCROLLLOCK) != 0); |
michael@0 | 1011 | } |
michael@0 | 1012 | |
michael@0 | 1013 | // true indeicates the Fn key is down, but this is not supported by native |
michael@0 | 1014 | // key event on any platform. |
michael@0 | 1015 | bool IsFn() const |
michael@0 | 1016 | { |
michael@0 | 1017 | return ((modifiers & MODIFIER_FN) != 0); |
michael@0 | 1018 | } |
michael@0 | 1019 | // true indeicates the ScrollLock LED is turn on. |
michael@0 | 1020 | bool IsSymbolLocked() const |
michael@0 | 1021 | { |
michael@0 | 1022 | return ((modifiers & MODIFIER_SYMBOLLOCK) != 0); |
michael@0 | 1023 | } |
michael@0 | 1024 | |
michael@0 | 1025 | void InitBasicModifiers(bool aCtrlKey, |
michael@0 | 1026 | bool aAltKey, |
michael@0 | 1027 | bool aShiftKey, |
michael@0 | 1028 | bool aMetaKey) |
michael@0 | 1029 | { |
michael@0 | 1030 | modifiers = 0; |
michael@0 | 1031 | if (aCtrlKey) { |
michael@0 | 1032 | modifiers |= MODIFIER_CONTROL; |
michael@0 | 1033 | } |
michael@0 | 1034 | if (aAltKey) { |
michael@0 | 1035 | modifiers |= MODIFIER_ALT; |
michael@0 | 1036 | } |
michael@0 | 1037 | if (aShiftKey) { |
michael@0 | 1038 | modifiers |= MODIFIER_SHIFT; |
michael@0 | 1039 | } |
michael@0 | 1040 | if (aMetaKey) { |
michael@0 | 1041 | modifiers |= MODIFIER_META; |
michael@0 | 1042 | } |
michael@0 | 1043 | } |
michael@0 | 1044 | |
michael@0 | 1045 | Modifiers modifiers; |
michael@0 | 1046 | |
michael@0 | 1047 | void AssignInputEventData(const WidgetInputEvent& aEvent, bool aCopyTargets) |
michael@0 | 1048 | { |
michael@0 | 1049 | AssignGUIEventData(aEvent, aCopyTargets); |
michael@0 | 1050 | |
michael@0 | 1051 | modifiers = aEvent.modifiers; |
michael@0 | 1052 | } |
michael@0 | 1053 | }; |
michael@0 | 1054 | |
michael@0 | 1055 | /****************************************************************************** |
michael@0 | 1056 | * mozilla::InternalUIEvent |
michael@0 | 1057 | * |
michael@0 | 1058 | * XXX Why this inherits WidgetGUIEvent rather than WidgetEvent? |
michael@0 | 1059 | ******************************************************************************/ |
michael@0 | 1060 | |
michael@0 | 1061 | class InternalUIEvent : public WidgetGUIEvent |
michael@0 | 1062 | { |
michael@0 | 1063 | protected: |
michael@0 | 1064 | InternalUIEvent() |
michael@0 | 1065 | : detail(0) |
michael@0 | 1066 | { |
michael@0 | 1067 | } |
michael@0 | 1068 | |
michael@0 | 1069 | InternalUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, |
michael@0 | 1070 | nsEventStructType aStructType) |
michael@0 | 1071 | : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aStructType) |
michael@0 | 1072 | , detail(0) |
michael@0 | 1073 | { |
michael@0 | 1074 | } |
michael@0 | 1075 | |
michael@0 | 1076 | InternalUIEvent(bool aIsTrusted, uint32_t aMessage, |
michael@0 | 1077 | nsEventStructType aStructType) |
michael@0 | 1078 | : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aStructType) |
michael@0 | 1079 | , detail(0) |
michael@0 | 1080 | { |
michael@0 | 1081 | } |
michael@0 | 1082 | |
michael@0 | 1083 | public: |
michael@0 | 1084 | virtual InternalUIEvent* AsUIEvent() MOZ_OVERRIDE { return this; } |
michael@0 | 1085 | |
michael@0 | 1086 | InternalUIEvent(bool aIsTrusted, uint32_t aMessage) |
michael@0 | 1087 | : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, NS_UI_EVENT) |
michael@0 | 1088 | , detail(0) |
michael@0 | 1089 | { |
michael@0 | 1090 | } |
michael@0 | 1091 | |
michael@0 | 1092 | virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE |
michael@0 | 1093 | { |
michael@0 | 1094 | MOZ_ASSERT(eventStructType == NS_UI_EVENT || |
michael@0 | 1095 | eventStructType == NS_SMIL_TIME_EVENT, |
michael@0 | 1096 | "Duplicate() must be overridden by sub class"); |
michael@0 | 1097 | InternalUIEvent* result = new InternalUIEvent(false, message); |
michael@0 | 1098 | result->AssignUIEventData(*this, true); |
michael@0 | 1099 | result->mFlags = mFlags; |
michael@0 | 1100 | return result; |
michael@0 | 1101 | } |
michael@0 | 1102 | |
michael@0 | 1103 | int32_t detail; |
michael@0 | 1104 | |
michael@0 | 1105 | void AssignUIEventData(const InternalUIEvent& aEvent, bool aCopyTargets) |
michael@0 | 1106 | { |
michael@0 | 1107 | AssignGUIEventData(aEvent, aCopyTargets); |
michael@0 | 1108 | |
michael@0 | 1109 | detail = aEvent.detail; |
michael@0 | 1110 | } |
michael@0 | 1111 | }; |
michael@0 | 1112 | |
michael@0 | 1113 | } // namespace mozilla |
michael@0 | 1114 | |
michael@0 | 1115 | #endif // mozilla_BasicEvents_h__ |