1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/BasicEvents.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1115 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_BasicEvents_h__ 1.10 +#define mozilla_BasicEvents_h__ 1.11 + 1.12 +#include <stdint.h> 1.13 + 1.14 +#include "mozilla/dom/EventTarget.h" 1.15 +#include "nsCOMPtr.h" 1.16 +#include "nsIAtom.h" 1.17 +#include "nsISupportsImpl.h" 1.18 +#include "nsIWidget.h" 1.19 +#include "nsString.h" 1.20 +#include "Units.h" 1.21 + 1.22 +/****************************************************************************** 1.23 + * Event Struct Types 1.24 + * 1.25 + * TODO: Move it into mozilla namespace. 1.26 + ******************************************************************************/ 1.27 +enum nsEventStructType 1.28 +{ 1.29 + // BasicEvents.h 1.30 + NS_EVENT, // WidgetEvent 1.31 + NS_GUI_EVENT, // WidgetGUIEvent 1.32 + NS_INPUT_EVENT, // WidgetInputEvent 1.33 + NS_UI_EVENT, // InternalUIEvent 1.34 + 1.35 + // TextEvents.h 1.36 + NS_KEY_EVENT, // WidgetKeyboardEvent 1.37 + NS_COMPOSITION_EVENT, // WidgetCompositionEvent 1.38 + NS_TEXT_EVENT, // WidgetTextEvent 1.39 + NS_QUERY_CONTENT_EVENT, // WidgetQueryContentEvent 1.40 + NS_SELECTION_EVENT, // WidgetSelectionEvent 1.41 + NS_EDITOR_INPUT_EVENT, // InternalEditorInputEvent 1.42 + 1.43 + // MouseEvents.h 1.44 + NS_MOUSE_EVENT, // WidgetMouseEvent 1.45 + NS_DRAG_EVENT, // WidgetDragEvent 1.46 + NS_MOUSE_SCROLL_EVENT, // WidgetMouseScrollEvent 1.47 + NS_WHEEL_EVENT, // WidgetWheelEvent 1.48 + NS_POINTER_EVENT, // PointerEvent 1.49 + 1.50 + // TouchEvents.h 1.51 + NS_GESTURENOTIFY_EVENT, // WidgetGestureNotifyEvent 1.52 + NS_SIMPLE_GESTURE_EVENT, // WidgetSimpleGestureEvent 1.53 + NS_TOUCH_EVENT, // WidgetTouchEvent 1.54 + 1.55 + // ContentEvents.h 1.56 + NS_SCROLLPORT_EVENT, // InternalScrollPortEvent 1.57 + NS_SCROLLAREA_EVENT, // InternalScrollAreaEvent 1.58 + NS_FORM_EVENT, // InternalFormEvent 1.59 + NS_FOCUS_EVENT, // InternalFocusEvent 1.60 + NS_CLIPBOARD_EVENT, // InternalClipboardEvent 1.61 + NS_TRANSITION_EVENT, // InternalTransitionEvent 1.62 + NS_ANIMATION_EVENT, // InternalAnimationEvent 1.63 + 1.64 + // MiscEvents.h 1.65 + NS_COMMAND_EVENT, // WidgetCommandEvent 1.66 + NS_CONTENT_COMMAND_EVENT, // WidgetContentCommandEvent 1.67 + NS_PLUGIN_EVENT, // WidgetPluginEvent 1.68 + 1.69 + // InternalMutationEvent.h (dom/events) 1.70 + NS_MUTATION_EVENT, // InternalMutationEvent 1.71 + 1.72 + // Follwoing struct type values are ugly. They indicate other struct type 1.73 + // actually. However, they are used for distinguishing which DOM event 1.74 + // should be created for the event. 1.75 + NS_SVGZOOM_EVENT, // WidgetGUIEvent 1.76 + NS_SMIL_TIME_EVENT // InternalUIEvent 1.77 +}; 1.78 + 1.79 +/****************************************************************************** 1.80 + * Messages 1.81 + * 1.82 + * TODO: Make them enum. 1.83 + ******************************************************************************/ 1.84 + 1.85 +#define NS_EVENT_NULL 0 1.86 + 1.87 +// This is a dummy event message for all event listener implementation in 1.88 +// EventListenerManager. 1.89 +#define NS_EVENT_ALL 1 1.90 + 1.91 +#define NS_WINDOW_START 100 1.92 + 1.93 +// Widget may be destroyed 1.94 +#define NS_XUL_CLOSE (NS_WINDOW_START + 1) 1.95 +// Key is pressed within a window 1.96 +#define NS_KEY_PRESS (NS_WINDOW_START + 31) 1.97 +// Key is released within a window 1.98 +#define NS_KEY_UP (NS_WINDOW_START + 32) 1.99 +// Key is pressed within a window 1.100 +#define NS_KEY_DOWN (NS_WINDOW_START + 33) 1.101 + 1.102 +#define NS_RESIZE_EVENT (NS_WINDOW_START + 60) 1.103 +#define NS_SCROLL_EVENT (NS_WINDOW_START + 61) 1.104 + 1.105 +// A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be 1.106 +// used when the window is not active. NS_PLUGIN_FOCUS should be used when 1.107 +// the window is active. In the latter case, the dispatcher of the event 1.108 +// is expected to ensure that the plugin's widget is focused beforehand. 1.109 +#define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62) 1.110 +#define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63) 1.111 + 1.112 +#define NS_OFFLINE (NS_WINDOW_START + 64) 1.113 +#define NS_ONLINE (NS_WINDOW_START + 65) 1.114 + 1.115 +// NS_BEFORERESIZE_EVENT used to be here (NS_WINDOW_START + 66) 1.116 + 1.117 +// Indicates that the user is either idle or active 1.118 +#define NS_MOZ_USER_IDLE (NS_WINDOW_START + 67) 1.119 +#define NS_MOZ_USER_ACTIVE (NS_WINDOW_START + 68) 1.120 + 1.121 +// The resolution at which a plugin should draw has changed, for 1.122 +// example as the result of changing from a HiDPI mode to a non- 1.123 +// HiDPI mode. 1.124 +#define NS_PLUGIN_RESOLUTION_CHANGED (NS_WINDOW_START + 69) 1.125 + 1.126 +#define NS_MOUSE_MESSAGE_START 300 1.127 +#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START) 1.128 +#define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1) 1.129 +#define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2) 1.130 +#define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22) 1.131 +#define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23) 1.132 +#define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24) 1.133 +#define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27) 1.134 +#define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30) 1.135 +#define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31) 1.136 +#define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32) 1.137 +#define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33) 1.138 +#define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34) 1.139 +#define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35) 1.140 + 1.141 +// Pointer spec events 1.142 +#define NS_POINTER_EVENT_START 4400 1.143 +#define NS_POINTER_MOVE (NS_POINTER_EVENT_START) 1.144 +#define NS_POINTER_UP (NS_POINTER_EVENT_START + 1) 1.145 +#define NS_POINTER_DOWN (NS_POINTER_EVENT_START + 2) 1.146 +#define NS_POINTER_OVER (NS_POINTER_EVENT_START + 22) 1.147 +#define NS_POINTER_OUT (NS_POINTER_EVENT_START + 23) 1.148 +#define NS_POINTER_ENTER (NS_POINTER_EVENT_START + 24) 1.149 +#define NS_POINTER_LEAVE (NS_POINTER_EVENT_START + 25) 1.150 +#define NS_POINTER_CANCEL (NS_POINTER_EVENT_START + 26) 1.151 +#define NS_POINTER_GOT_CAPTURE (NS_POINTER_EVENT_START + 27) 1.152 +#define NS_POINTER_LOST_CAPTURE (NS_POINTER_EVENT_START + 28) 1.153 + 1.154 +#define NS_CONTEXTMENU_MESSAGE_START 500 1.155 +#define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START) 1.156 + 1.157 +#define NS_STREAM_EVENT_START 1100 1.158 +#define NS_LOAD (NS_STREAM_EVENT_START) 1.159 +#define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1) 1.160 +#define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2) 1.161 +#define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3) 1.162 +#define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4) 1.163 +#define NS_POPSTATE (NS_STREAM_EVENT_START + 5) 1.164 +#define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6) 1.165 +#define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7) 1.166 +#define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8) 1.167 + 1.168 +#define NS_FORM_EVENT_START 1200 1.169 +#define NS_FORM_SUBMIT (NS_FORM_EVENT_START) 1.170 +#define NS_FORM_RESET (NS_FORM_EVENT_START + 1) 1.171 +#define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2) 1.172 +#define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3) 1.173 +#define NS_FORM_INVALID (NS_FORM_EVENT_START + 4) 1.174 + 1.175 +//Need separate focus/blur notifications for non-native widgets 1.176 +#define NS_FOCUS_EVENT_START 1300 1.177 +#define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START) 1.178 +#define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1) 1.179 + 1.180 +#define NS_DRAGDROP_EVENT_START 1400 1.181 +#define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START) 1.182 +#define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1) 1.183 +#define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2) 1.184 +#define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3) 1.185 +#define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4) 1.186 +#define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5) 1.187 +#define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6) 1.188 +#define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7) 1.189 +#define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8) 1.190 +#define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1) 1.191 +#define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2) 1.192 +#define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9) 1.193 + 1.194 +// Events for popups 1.195 +#define NS_XUL_EVENT_START 1500 1.196 +#define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START) 1.197 +#define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1) 1.198 +#define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2) 1.199 +#define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3) 1.200 +// NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4) 1.201 +#define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5) 1.202 +#define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6) 1.203 +//@} 1.204 + 1.205 +// Scroll events 1.206 +#define NS_MOUSE_SCROLL_START 1600 1.207 +#define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START) 1.208 +#define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1) 1.209 + 1.210 +#define NS_SCROLLPORT_START 1700 1.211 +#define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START) 1.212 +#define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1) 1.213 + 1.214 +#define NS_MUTATION_START 1800 1.215 +#define NS_MUTATION_SUBTREEMODIFIED (NS_MUTATION_START) 1.216 +#define NS_MUTATION_NODEINSERTED (NS_MUTATION_START+1) 1.217 +#define NS_MUTATION_NODEREMOVED (NS_MUTATION_START+2) 1.218 +#define NS_MUTATION_NODEREMOVEDFROMDOCUMENT (NS_MUTATION_START+3) 1.219 +#define NS_MUTATION_NODEINSERTEDINTODOCUMENT (NS_MUTATION_START+4) 1.220 +#define NS_MUTATION_ATTRMODIFIED (NS_MUTATION_START+5) 1.221 +#define NS_MUTATION_CHARACTERDATAMODIFIED (NS_MUTATION_START+6) 1.222 +#define NS_MUTATION_END (NS_MUTATION_START+6) 1.223 + 1.224 +#define NS_USER_DEFINED_EVENT 2000 1.225 + 1.226 +// composition events 1.227 +#define NS_COMPOSITION_EVENT_START 2200 1.228 +#define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START) 1.229 +#define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1) 1.230 +#define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2) 1.231 + 1.232 +// text events 1.233 +#define NS_TEXT_START 2400 1.234 +#define NS_TEXT_TEXT (NS_TEXT_START) 1.235 + 1.236 +// UI events 1.237 +#define NS_UI_EVENT_START 2500 1.238 +// this is not to be confused with NS_ACTIVATE! 1.239 +#define NS_UI_ACTIVATE (NS_UI_EVENT_START) 1.240 +#define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1) 1.241 +#define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2) 1.242 + 1.243 +// pagetransition events 1.244 +#define NS_PAGETRANSITION_START 2700 1.245 +#define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1) 1.246 +#define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2) 1.247 + 1.248 +// SVG events 1.249 +#define NS_SVG_EVENT_START 2800 1.250 +#define NS_SVG_LOAD (NS_SVG_EVENT_START) 1.251 +#define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1) 1.252 +#define NS_SVG_ABORT (NS_SVG_EVENT_START + 2) 1.253 +#define NS_SVG_ERROR (NS_SVG_EVENT_START + 3) 1.254 +#define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4) 1.255 +#define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5) 1.256 + 1.257 +// SVG Zoom events 1.258 +#define NS_SVGZOOM_EVENT_START 2900 1.259 +#define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START) 1.260 + 1.261 +// XUL command events 1.262 +#define NS_XULCOMMAND_EVENT_START 3000 1.263 +#define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START) 1.264 + 1.265 +// Cut, copy, paste events 1.266 +#define NS_CUTCOPYPASTE_EVENT_START 3100 1.267 +#define NS_COPY (NS_CUTCOPYPASTE_EVENT_START) 1.268 +#define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1) 1.269 +#define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2) 1.270 + 1.271 +// Query the content information 1.272 +#define NS_QUERY_CONTENT_EVENT_START 3200 1.273 +// Query for the selected text information, it return the selection offset, 1.274 +// selection length and selected text. 1.275 +#define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START) 1.276 +// Query for the text content of specified range, it returns actual lengh (if 1.277 +// the specified range is too long) and the text of the specified range. 1.278 +// Returns the entire text if requested length > actual length. 1.279 +#define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1) 1.280 +// Query for the caret rect of nth insertion point. The offset of the result is 1.281 +// relative position from the top level widget. 1.282 +#define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3) 1.283 +// Query for the bounding rect of a range of characters. This works on any 1.284 +// valid character range given offset and length. Result is relative to top 1.285 +// level widget coordinates 1.286 +#define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4) 1.287 +// Query for the bounding rect of the current focused frame. Result is relative 1.288 +// to top level widget coordinates 1.289 +#define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5) 1.290 +// Query for the current state of the content. The particular members of 1.291 +// mReply that are set for each query content event will be valid on success. 1.292 +#define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6) 1.293 +// Query for the selection in the form of a nsITransferable. 1.294 +#define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7) 1.295 +// Query for character at a point. This returns the character offset and its 1.296 +// rect. The point is specified by Event::refPoint. 1.297 +#define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8) 1.298 +// Query if the DOM element under Event::refPoint belongs to our widget 1.299 +// or not. 1.300 +#define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9) 1.301 + 1.302 +// Video events 1.303 +#define NS_MEDIA_EVENT_START 3300 1.304 +#define NS_LOADSTART (NS_MEDIA_EVENT_START) 1.305 +#define NS_PROGRESS (NS_MEDIA_EVENT_START+1) 1.306 +#define NS_SUSPEND (NS_MEDIA_EVENT_START+2) 1.307 +#define NS_EMPTIED (NS_MEDIA_EVENT_START+3) 1.308 +#define NS_STALLED (NS_MEDIA_EVENT_START+4) 1.309 +#define NS_PLAY (NS_MEDIA_EVENT_START+5) 1.310 +#define NS_PAUSE (NS_MEDIA_EVENT_START+6) 1.311 +#define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7) 1.312 +#define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8) 1.313 +#define NS_WAITING (NS_MEDIA_EVENT_START+9) 1.314 +#define NS_PLAYING (NS_MEDIA_EVENT_START+10) 1.315 +#define NS_CANPLAY (NS_MEDIA_EVENT_START+11) 1.316 +#define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12) 1.317 +#define NS_SEEKING (NS_MEDIA_EVENT_START+13) 1.318 +#define NS_SEEKED (NS_MEDIA_EVENT_START+14) 1.319 +#define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15) 1.320 +#define NS_ENDED (NS_MEDIA_EVENT_START+16) 1.321 +#define NS_RATECHANGE (NS_MEDIA_EVENT_START+17) 1.322 +#define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18) 1.323 +#define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19) 1.324 + 1.325 +// paint notification events 1.326 +#define NS_NOTIFYPAINT_START 3400 1.327 +#define NS_AFTERPAINT (NS_NOTIFYPAINT_START) 1.328 + 1.329 +// Simple gesture events 1.330 +#define NS_SIMPLE_GESTURE_EVENT_START 3500 1.331 +#define NS_SIMPLE_GESTURE_SWIPE_START (NS_SIMPLE_GESTURE_EVENT_START) 1.332 +#define NS_SIMPLE_GESTURE_SWIPE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+1) 1.333 +#define NS_SIMPLE_GESTURE_SWIPE_END (NS_SIMPLE_GESTURE_EVENT_START+2) 1.334 +#define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START+3) 1.335 +#define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+4) 1.336 +#define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5) 1.337 +#define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+6) 1.338 +#define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+7) 1.339 +#define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+8) 1.340 +#define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+9) 1.341 +#define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+10) 1.342 +#define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+11) 1.343 +#define NS_SIMPLE_GESTURE_EDGE_STARTED (NS_SIMPLE_GESTURE_EVENT_START+12) 1.344 +#define NS_SIMPLE_GESTURE_EDGE_CANCELED (NS_SIMPLE_GESTURE_EVENT_START+13) 1.345 +#define NS_SIMPLE_GESTURE_EDGE_COMPLETED (NS_SIMPLE_GESTURE_EVENT_START+14) 1.346 + 1.347 +// These are used to send native events to plugins. 1.348 +#define NS_PLUGIN_EVENT_START 3600 1.349 +#define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START) 1.350 +#define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1) 1.351 + 1.352 +// Events to manipulate selection (WidgetSelectionEvent) 1.353 +#define NS_SELECTION_EVENT_START 3700 1.354 +// Clear any previous selection and set the given range as the selection 1.355 +#define NS_SELECTION_SET (NS_SELECTION_EVENT_START) 1.356 + 1.357 +// Events of commands for the contents 1.358 +#define NS_CONTENT_COMMAND_EVENT_START 3800 1.359 +#define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START) 1.360 +#define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1) 1.361 +#define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2) 1.362 +#define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3) 1.363 +#define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4) 1.364 +#define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5) 1.365 +#define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6) 1.366 +// NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the 1.367 +// currently focused content or latest DOM selection. This would normally be 1.368 +// the same element scrolled by keyboard scroll commands, except that this event 1.369 +// will scroll an element scrollable in either direction. I.e., if the nearest 1.370 +// scrollable ancestor element can only be scrolled vertically, and horizontal 1.371 +// scrolling is requested using this event, no scrolling will occur. 1.372 +#define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7) 1.373 + 1.374 +// Event to gesture notification 1.375 +#define NS_GESTURENOTIFY_EVENT_START 3900 1.376 + 1.377 +#define NS_ORIENTATION_EVENT 4000 1.378 + 1.379 +#define NS_SCROLLAREA_EVENT_START 4100 1.380 +#define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START) 1.381 + 1.382 +#define NS_TRANSITION_EVENT_START 4200 1.383 +#define NS_TRANSITION_END (NS_TRANSITION_EVENT_START) 1.384 + 1.385 +#define NS_ANIMATION_EVENT_START 4250 1.386 +#define NS_ANIMATION_START (NS_ANIMATION_EVENT_START) 1.387 +#define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1) 1.388 +#define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2) 1.389 + 1.390 +#define NS_SMIL_TIME_EVENT_START 4300 1.391 +#define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START) 1.392 +#define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1) 1.393 +#define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2) 1.394 + 1.395 +#define NS_WEBAUDIO_EVENT_START 4350 1.396 +#define NS_AUDIO_PROCESS (NS_WEBAUDIO_EVENT_START) 1.397 +#define NS_AUDIO_COMPLETE (NS_WEBAUDIO_EVENT_START + 1) 1.398 + 1.399 +// script notification events 1.400 +#define NS_NOTIFYSCRIPT_START 4500 1.401 +#define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START) 1.402 +#define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1) 1.403 + 1.404 +#define NS_PRINT_EVENT_START 4600 1.405 +#define NS_BEFOREPRINT (NS_PRINT_EVENT_START) 1.406 +#define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1) 1.407 + 1.408 +#define NS_MESSAGE_EVENT_START 4700 1.409 +#define NS_MESSAGE (NS_MESSAGE_EVENT_START) 1.410 + 1.411 +// Open and close events 1.412 +#define NS_OPENCLOSE_EVENT_START 4800 1.413 +#define NS_OPEN (NS_OPENCLOSE_EVENT_START) 1.414 +#define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1) 1.415 + 1.416 +// Device motion and orientation 1.417 +#define NS_DEVICE_ORIENTATION_START 4900 1.418 +#define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START) 1.419 +#define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1) 1.420 +#define NS_DEVICE_PROXIMITY (NS_DEVICE_ORIENTATION_START+2) 1.421 +#define NS_USER_PROXIMITY (NS_DEVICE_ORIENTATION_START+3) 1.422 +#define NS_DEVICE_LIGHT (NS_DEVICE_ORIENTATION_START+4) 1.423 + 1.424 +#define NS_SHOW_EVENT 5000 1.425 + 1.426 +// Fullscreen DOM API 1.427 +#define NS_FULL_SCREEN_START 5100 1.428 +#define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START) 1.429 +#define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1) 1.430 + 1.431 +#define NS_TOUCH_EVENT_START 5200 1.432 +#define NS_TOUCH_START (NS_TOUCH_EVENT_START) 1.433 +#define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1) 1.434 +#define NS_TOUCH_END (NS_TOUCH_EVENT_START+2) 1.435 +#define NS_TOUCH_ENTER (NS_TOUCH_EVENT_START+3) 1.436 +#define NS_TOUCH_LEAVE (NS_TOUCH_EVENT_START+4) 1.437 +#define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+5) 1.438 + 1.439 +// Pointerlock DOM API 1.440 +#define NS_POINTERLOCK_START 5300 1.441 +#define NS_POINTERLOCKCHANGE (NS_POINTERLOCK_START) 1.442 +#define NS_POINTERLOCKERROR (NS_POINTERLOCK_START + 1) 1.443 + 1.444 +#define NS_WHEEL_EVENT_START 5400 1.445 +#define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START) 1.446 +#define NS_WHEEL_START (NS_WHEEL_EVENT_START + 1) 1.447 +#define NS_WHEEL_STOP (NS_WHEEL_EVENT_START + 2) 1.448 + 1.449 +//System time is changed 1.450 +#define NS_MOZ_TIME_CHANGE_EVENT 5500 1.451 + 1.452 +// Network packet events. 1.453 +#define NS_NETWORK_EVENT_START 5600 1.454 +#define NS_NETWORK_UPLOAD_EVENT (NS_NETWORK_EVENT_START + 1) 1.455 +#define NS_NETWORK_DOWNLOAD_EVENT (NS_NETWORK_EVENT_START + 2) 1.456 + 1.457 +// MediaRecorder events. 1.458 +#define NS_MEDIARECORDER_EVENT_START 5700 1.459 +#define NS_MEDIARECORDER_DATAAVAILABLE (NS_MEDIARECORDER_EVENT_START + 1) 1.460 +#define NS_MEDIARECORDER_WARNING (NS_MEDIARECORDER_EVENT_START + 2) 1.461 +#define NS_MEDIARECORDER_STOP (NS_MEDIARECORDER_EVENT_START + 3) 1.462 + 1.463 +// SpeakerManager events 1.464 +#define NS_SPEAKERMANAGER_EVENT_START 5800 1.465 +#define NS_SPEAKERMANAGER_SPEAKERFORCEDCHANGE (NS_SPEAKERMANAGER_EVENT_START + 1) 1.466 + 1.467 +#ifdef MOZ_GAMEPAD 1.468 +// Gamepad input events 1.469 +#define NS_GAMEPAD_START 6000 1.470 +#define NS_GAMEPAD_BUTTONDOWN (NS_GAMEPAD_START) 1.471 +#define NS_GAMEPAD_BUTTONUP (NS_GAMEPAD_START+1) 1.472 +#define NS_GAMEPAD_AXISMOVE (NS_GAMEPAD_START+2) 1.473 +#define NS_GAMEPAD_CONNECTED (NS_GAMEPAD_START+3) 1.474 +#define NS_GAMEPAD_DISCONNECTED (NS_GAMEPAD_START+4) 1.475 +// Keep this defined to the same value as the event above 1.476 +#define NS_GAMEPAD_END (NS_GAMEPAD_START+4) 1.477 +#endif 1.478 + 1.479 +// input and beforeinput events. 1.480 +#define NS_EDITOR_EVENT_START 6100 1.481 +#define NS_EDITOR_INPUT (NS_EDITOR_EVENT_START) 1.482 + 1.483 +namespace mozilla { 1.484 + 1.485 +/****************************************************************************** 1.486 + * mozilla::BaseEventFlags 1.487 + * 1.488 + * BaseEventFlags must be a POD struct for safe to use memcpy (including 1.489 + * in ParamTraits<BaseEventFlags>). So don't make virtual methods, constructor, 1.490 + * destructor and operators. 1.491 + * This is necessary for VC which is NOT C++0x compiler. 1.492 + ******************************************************************************/ 1.493 + 1.494 +struct BaseEventFlags 1.495 +{ 1.496 +public: 1.497 + // If mIsTrusted is true, the event is a trusted event. Otherwise, it's 1.498 + // an untrusted event. 1.499 + bool mIsTrusted : 1; 1.500 + // If mInBubblingPhase is true, the event is in bubbling phase or target 1.501 + // phase. 1.502 + bool mInBubblingPhase : 1; 1.503 + // If mInCapturePhase is true, the event is in capture phase or target phase. 1.504 + bool mInCapturePhase : 1; 1.505 + // If mInSystemGroup is true, the event is being dispatched in system group. 1.506 + bool mInSystemGroup: 1; 1.507 + // If mCancelable is true, the event can be consumed. I.e., calling 1.508 + // dom::Event::PreventDefault() can prevent the default action. 1.509 + bool mCancelable : 1; 1.510 + // If mBubbles is true, the event can bubble. Otherwise, cannot be handled 1.511 + // in bubbling phase. 1.512 + bool mBubbles : 1; 1.513 + // If mPropagationStopped is true, dom::Event::StopPropagation() or 1.514 + // dom::Event::StopImmediatePropagation() has been called. 1.515 + bool mPropagationStopped : 1; 1.516 + // If mImmediatePropagationStopped is true, 1.517 + // dom::Event::StopImmediatePropagation() has been called. 1.518 + // Note that mPropagationStopped must be true when this is true. 1.519 + bool mImmediatePropagationStopped : 1; 1.520 + // If mDefaultPrevented is true, the event has been consumed. 1.521 + // E.g., dom::Event::PreventDefault() has been called or 1.522 + // the default action has been performed. 1.523 + bool mDefaultPrevented : 1; 1.524 + // If mDefaultPreventedByContent is true, the event has been 1.525 + // consumed by content. 1.526 + // Note that mDefaultPrevented must be true when this is true. 1.527 + bool mDefaultPreventedByContent : 1; 1.528 + // mMultipleActionsPrevented may be used when default handling don't want to 1.529 + // be prevented, but only one of the event targets should handle the event. 1.530 + // For example, when a <label> element is in another <label> element and 1.531 + // the first <label> element is clicked, that one may set this true. 1.532 + // Then, the second <label> element won't handle the event. 1.533 + bool mMultipleActionsPrevented : 1; 1.534 + // If mIsBeingDispatched is true, the DOM event created from the event is 1.535 + // dispatching into the DOM tree and not completed. 1.536 + bool mIsBeingDispatched : 1; 1.537 + // If mDispatchedAtLeastOnce is true, the event has been dispatched 1.538 + // as a DOM event and the dispatch has been completed. 1.539 + bool mDispatchedAtLeastOnce : 1; 1.540 + // If mIsSynthesizedForTests is true, the event has been synthesized for 1.541 + // automated tests or something hacky approach of an add-on. 1.542 + bool mIsSynthesizedForTests : 1; 1.543 + // If mExceptionHasBeenRisen is true, one of the event handlers has risen an 1.544 + // exception. 1.545 + bool mExceptionHasBeenRisen : 1; 1.546 + // If mRetargetToNonNativeAnonymous is true and the target is in a non-native 1.547 + // native anonymous subtree, the event target is set to originalTarget. 1.548 + bool mRetargetToNonNativeAnonymous : 1; 1.549 + // If mNoCrossProcessBoundaryForwarding is true, the event is not allowed to 1.550 + // cross process boundary. 1.551 + bool mNoCrossProcessBoundaryForwarding : 1; 1.552 + // If mNoContentDispatch is true, the event is never dispatched to the 1.553 + // event handlers which are added to the contents, onfoo attributes and 1.554 + // properties. Note that this flag is ignored when 1.555 + // EventChainPreVisitor::mForceContentDispatch is set true. For exapmle, 1.556 + // window and document object sets it true. Therefore, web applications 1.557 + // can handle the event if they add event listeners to the window or the 1.558 + // document. 1.559 + bool mNoContentDispatch : 1; 1.560 + // If mOnlyChromeDispatch is true, the event is dispatched to only chrome. 1.561 + bool mOnlyChromeDispatch : 1; 1.562 + // If mWantReplyFromContentProcess is true, the event will be redispatched 1.563 + // in the parent process after the content process has handled it. Useful 1.564 + // for when the parent process need the know first how the event was used 1.565 + // by content before handling it itself. 1.566 + bool mWantReplyFromContentProcess : 1; 1.567 + 1.568 + // If the event is being handled in target phase, returns true. 1.569 + inline bool InTargetPhase() const 1.570 + { 1.571 + return (mInBubblingPhase && mInCapturePhase); 1.572 + } 1.573 + 1.574 + inline void Clear() 1.575 + { 1.576 + SetRawFlags(0); 1.577 + } 1.578 + // Get if either the instance's bit or the aOther's bit is true, the 1.579 + // instance's bit becomes true. In other words, this works like: 1.580 + // eventFlags |= aOther; 1.581 + inline void Union(const BaseEventFlags& aOther) 1.582 + { 1.583 + RawFlags rawFlags = GetRawFlags() | aOther.GetRawFlags(); 1.584 + SetRawFlags(rawFlags); 1.585 + } 1.586 + 1.587 +private: 1.588 + typedef uint32_t RawFlags; 1.589 + 1.590 + inline void SetRawFlags(RawFlags aRawFlags) 1.591 + { 1.592 + static_assert(sizeof(BaseEventFlags) <= sizeof(RawFlags), 1.593 + "mozilla::EventFlags must not be bigger than the RawFlags"); 1.594 + memcpy(this, &aRawFlags, sizeof(BaseEventFlags)); 1.595 + } 1.596 + inline RawFlags GetRawFlags() const 1.597 + { 1.598 + RawFlags result = 0; 1.599 + memcpy(&result, this, sizeof(BaseEventFlags)); 1.600 + return result; 1.601 + } 1.602 +}; 1.603 + 1.604 +/****************************************************************************** 1.605 + * mozilla::EventFlags 1.606 + ******************************************************************************/ 1.607 + 1.608 +struct EventFlags : public BaseEventFlags 1.609 +{ 1.610 + EventFlags() 1.611 + { 1.612 + Clear(); 1.613 + } 1.614 +}; 1.615 + 1.616 +/****************************************************************************** 1.617 + * mozilla::WidgetEvent 1.618 + ******************************************************************************/ 1.619 + 1.620 +class WidgetEvent 1.621 +{ 1.622 +protected: 1.623 + WidgetEvent(bool aIsTrusted, uint32_t aMessage, 1.624 + nsEventStructType aStructType) : 1.625 + eventStructType(aStructType), message(aMessage), refPoint(0, 0), 1.626 + lastRefPoint(0, 0), time(0), userType(0) 1.627 + { 1.628 + MOZ_COUNT_CTOR(WidgetEvent); 1.629 + mFlags.Clear(); 1.630 + mFlags.mIsTrusted = aIsTrusted; 1.631 + mFlags.mCancelable = true; 1.632 + mFlags.mBubbles = true; 1.633 + } 1.634 + 1.635 + WidgetEvent() 1.636 + { 1.637 + MOZ_COUNT_CTOR(WidgetEvent); 1.638 + } 1.639 + 1.640 +public: 1.641 + WidgetEvent(bool aIsTrusted, uint32_t aMessage) : 1.642 + eventStructType(NS_EVENT), message(aMessage), refPoint(0, 0), 1.643 + lastRefPoint(0, 0), time(0), userType(0) 1.644 + { 1.645 + MOZ_COUNT_CTOR(WidgetEvent); 1.646 + mFlags.Clear(); 1.647 + mFlags.mIsTrusted = aIsTrusted; 1.648 + mFlags.mCancelable = true; 1.649 + mFlags.mBubbles = true; 1.650 + } 1.651 + 1.652 + virtual ~WidgetEvent() 1.653 + { 1.654 + MOZ_COUNT_DTOR(WidgetEvent); 1.655 + } 1.656 + 1.657 + WidgetEvent(const WidgetEvent& aOther) 1.658 + { 1.659 + MOZ_COUNT_CTOR(WidgetEvent); 1.660 + *this = aOther; 1.661 + } 1.662 + 1.663 + virtual WidgetEvent* Duplicate() const 1.664 + { 1.665 + MOZ_ASSERT(eventStructType == NS_EVENT, 1.666 + "Duplicate() must be overridden by sub class"); 1.667 + WidgetEvent* result = new WidgetEvent(false, message); 1.668 + result->AssignEventData(*this, true); 1.669 + result->mFlags = mFlags; 1.670 + return result; 1.671 + } 1.672 + 1.673 + // See event struct types 1.674 + nsEventStructType eventStructType; 1.675 + // See GUI MESSAGES, 1.676 + uint32_t message; 1.677 + // Relative to the widget of the event, or if there is no widget then it is 1.678 + // in screen coordinates. Not modified by layout code. 1.679 + LayoutDeviceIntPoint refPoint; 1.680 + // The previous refPoint, if known, used to calculate mouse movement deltas. 1.681 + LayoutDeviceIntPoint lastRefPoint; 1.682 + // Elapsed time, in milliseconds, from a platform-specific zero time 1.683 + // to the time the message was created 1.684 + uint64_t time; 1.685 + // See BaseEventFlags definition for the detail. 1.686 + BaseEventFlags mFlags; 1.687 + 1.688 + // Additional type info for user defined events 1.689 + nsCOMPtr<nsIAtom> userType; 1.690 + 1.691 + nsString typeString; // always set on non-main-thread events 1.692 + 1.693 + // Event targets, needed by DOM Events 1.694 + nsCOMPtr<dom::EventTarget> target; 1.695 + nsCOMPtr<dom::EventTarget> currentTarget; 1.696 + nsCOMPtr<dom::EventTarget> originalTarget; 1.697 + 1.698 + void AssignEventData(const WidgetEvent& aEvent, bool aCopyTargets) 1.699 + { 1.700 + // eventStructType should be initialized with the constructor. 1.701 + // However, NS_SVGZOOM_EVENT and NS_SMIL_TIME_EVENT are set after that. 1.702 + // Therefore, we need to copy eventStructType here. 1.703 + eventStructType = aEvent.eventStructType; 1.704 + // message should be initialized with the constructor. 1.705 + refPoint = aEvent.refPoint; 1.706 + // lastRefPoint doesn't need to be copied. 1.707 + time = aEvent.time; 1.708 + // mFlags should be copied manually if it's necessary. 1.709 + userType = aEvent.userType; 1.710 + // typeString should be copied manually if it's necessary. 1.711 + target = aCopyTargets ? aEvent.target : nullptr; 1.712 + currentTarget = aCopyTargets ? aEvent.currentTarget : nullptr; 1.713 + originalTarget = aCopyTargets ? aEvent.originalTarget : nullptr; 1.714 + } 1.715 + 1.716 + /** 1.717 + * Utils for checking event types 1.718 + */ 1.719 + 1.720 + /** 1.721 + * As*Event() returns the pointer of the instance only when the instance is 1.722 + * the class or one of its derived class. 1.723 + */ 1.724 +#define NS_ROOT_EVENT_CLASS(aPrefix, aName) 1.725 +#define NS_EVENT_CLASS(aPrefix, aName) \ 1.726 + virtual aPrefix##aName* As##aName(); \ 1.727 + const aPrefix##aName* As##aName() const; 1.728 + 1.729 +#include "mozilla/EventClassList.h" 1.730 + 1.731 +#undef NS_EVENT_CLASS 1.732 +#undef NS_ROOT_EVENT_CLASS 1.733 + 1.734 + /** 1.735 + * Returns true if the event is a query content event. 1.736 + */ 1.737 + bool IsQueryContentEvent() const; 1.738 + /** 1.739 + * Returns true if the event is a selection event. 1.740 + */ 1.741 + bool IsSelectionEvent() const; 1.742 + /** 1.743 + * Returns true if the event is a content command event. 1.744 + */ 1.745 + bool IsContentCommandEvent() const; 1.746 + /** 1.747 + * Returns true if the event is a native event deliverer event for plugin. 1.748 + */ 1.749 + bool IsNativeEventDelivererForPlugin() const; 1.750 + 1.751 + /** 1.752 + * Returns true if the event message is one of mouse events. 1.753 + */ 1.754 + bool HasMouseEventMessage() const; 1.755 + /** 1.756 + * Returns true if the event message is one of drag events. 1.757 + */ 1.758 + bool HasDragEventMessage() const; 1.759 + /** 1.760 + * Returns true if the event message is one of key events. 1.761 + */ 1.762 + bool HasKeyEventMessage() const; 1.763 + /** 1.764 + * Returns true if the event message is one of composition events or text 1.765 + * event. 1.766 + */ 1.767 + bool HasIMEEventMessage() const; 1.768 + /** 1.769 + * Returns true if the event message is one of plugin activation events. 1.770 + */ 1.771 + bool HasPluginActivationEventMessage() const; 1.772 + 1.773 + /** 1.774 + * Returns true if the event is native event deliverer event for plugin and 1.775 + * it should be retarted to focused document. 1.776 + */ 1.777 + bool IsRetargetedNativeEventDelivererForPlugin() const; 1.778 + /** 1.779 + * Returns true if the event is native event deliverer event for plugin and 1.780 + * it should NOT be retarted to focused document. 1.781 + */ 1.782 + bool IsNonRetargetedNativeEventDelivererForPlugin() const; 1.783 + /** 1.784 + * Returns true if the event is related to IME handling. It includes 1.785 + * IME events, query content events and selection events. 1.786 + * Be careful when you use this. 1.787 + */ 1.788 + bool IsIMERelatedEvent() const; 1.789 + 1.790 + /** 1.791 + * Whether the event should be handled by the frame of the mouse cursor 1.792 + * position or not. When it should be handled there (e.g., the mouse events), 1.793 + * this returns true. 1.794 + */ 1.795 + bool IsUsingCoordinates() const; 1.796 + /** 1.797 + * Whether the event should be handled by the focused DOM window in the 1.798 + * same top level window's or not. E.g., key events, IME related events 1.799 + * (including the query content events, they are used in IME transaction) 1.800 + * should be handled by the (last) focused window rather than the dispatched 1.801 + * window. 1.802 + * 1.803 + * NOTE: Even if this returns true, the event isn't going to be handled by the 1.804 + * application level active DOM window which is on another top level window. 1.805 + * So, when the event is fired on a deactive window, the event is going to be 1.806 + * handled by the last focused DOM window in the last focused window. 1.807 + */ 1.808 + bool IsTargetedAtFocusedWindow() const; 1.809 + /** 1.810 + * Whether the event should be handled by the focused content or not. E.g., 1.811 + * key events, IME related events and other input events which are not handled 1.812 + * by the frame of the mouse cursor position. 1.813 + * 1.814 + * NOTE: Even if this returns true, the event isn't going to be handled by the 1.815 + * application level active DOM window which is on another top level window. 1.816 + * So, when the event is fired on a deactive window, the event is going to be 1.817 + * handled by the last focused DOM element of the last focused DOM window in 1.818 + * the last focused window. 1.819 + */ 1.820 + bool IsTargetedAtFocusedContent() const; 1.821 + /** 1.822 + * Whether the event should cause a DOM event. 1.823 + */ 1.824 + bool IsAllowedToDispatchDOMEvent() const; 1.825 +}; 1.826 + 1.827 +/****************************************************************************** 1.828 + * mozilla::WidgetGUIEvent 1.829 + ******************************************************************************/ 1.830 + 1.831 +class WidgetGUIEvent : public WidgetEvent 1.832 +{ 1.833 +protected: 1.834 + WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, 1.835 + nsEventStructType aStructType) : 1.836 + WidgetEvent(aIsTrusted, aMessage, aStructType), 1.837 + widget(aWidget), pluginEvent(nullptr) 1.838 + { 1.839 + } 1.840 + 1.841 + WidgetGUIEvent() : 1.842 + pluginEvent(nullptr) 1.843 + { 1.844 + } 1.845 + 1.846 +public: 1.847 + virtual WidgetGUIEvent* AsGUIEvent() MOZ_OVERRIDE { return this; } 1.848 + 1.849 + WidgetGUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : 1.850 + WidgetEvent(aIsTrusted, aMessage, NS_GUI_EVENT), 1.851 + widget(aWidget), pluginEvent(nullptr) 1.852 + { 1.853 + } 1.854 + 1.855 + virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE 1.856 + { 1.857 + MOZ_ASSERT(eventStructType == NS_GUI_EVENT || 1.858 + eventStructType == NS_SVGZOOM_EVENT, 1.859 + "Duplicate() must be overridden by sub class"); 1.860 + // Not copying widget, it is a weak reference. 1.861 + WidgetGUIEvent* result = new WidgetGUIEvent(false, message, nullptr); 1.862 + result->AssignGUIEventData(*this, true); 1.863 + result->mFlags = mFlags; 1.864 + return result; 1.865 + } 1.866 + 1.867 + /// Originator of the event 1.868 + nsCOMPtr<nsIWidget> widget; 1.869 + 1.870 + /// Event for NPAPI plugin 1.871 + void* pluginEvent; 1.872 + 1.873 + void AssignGUIEventData(const WidgetGUIEvent& aEvent, bool aCopyTargets) 1.874 + { 1.875 + AssignEventData(aEvent, aCopyTargets); 1.876 + 1.877 + // widget should be initialized with the constructor. 1.878 + 1.879 + // pluginEvent shouldn't be copied because it may be referred after its 1.880 + // instance is destroyed. 1.881 + pluginEvent = nullptr; 1.882 + } 1.883 +}; 1.884 + 1.885 +/****************************************************************************** 1.886 + * mozilla::Modifier 1.887 + * 1.888 + * All modifier keys should be defined here. This is used for managing 1.889 + * modifier states for DOM Level 3 or later. 1.890 + ******************************************************************************/ 1.891 + 1.892 +enum Modifier 1.893 +{ 1.894 + MODIFIER_ALT = 0x0001, 1.895 + MODIFIER_ALTGRAPH = 0x0002, 1.896 + MODIFIER_CAPSLOCK = 0x0004, 1.897 + MODIFIER_CONTROL = 0x0008, 1.898 + MODIFIER_FN = 0x0010, 1.899 + MODIFIER_META = 0x0020, 1.900 + MODIFIER_NUMLOCK = 0x0040, 1.901 + MODIFIER_SCROLLLOCK = 0x0080, 1.902 + MODIFIER_SHIFT = 0x0100, 1.903 + MODIFIER_SYMBOLLOCK = 0x0200, 1.904 + MODIFIER_OS = 0x0400 1.905 +}; 1.906 + 1.907 +/****************************************************************************** 1.908 + * Modifier key names. 1.909 + ******************************************************************************/ 1.910 + 1.911 +#define NS_DOM_KEYNAME_ALT "Alt" 1.912 +#define NS_DOM_KEYNAME_ALTGRAPH "AltGraph" 1.913 +#define NS_DOM_KEYNAME_CAPSLOCK "CapsLock" 1.914 +#define NS_DOM_KEYNAME_CONTROL "Control" 1.915 +#define NS_DOM_KEYNAME_FN "Fn" 1.916 +#define NS_DOM_KEYNAME_META "Meta" 1.917 +#define NS_DOM_KEYNAME_NUMLOCK "NumLock" 1.918 +#define NS_DOM_KEYNAME_SCROLLLOCK "ScrollLock" 1.919 +#define NS_DOM_KEYNAME_SHIFT "Shift" 1.920 +#define NS_DOM_KEYNAME_SYMBOLLOCK "SymbolLock" 1.921 +#define NS_DOM_KEYNAME_OS "OS" 1.922 + 1.923 +/****************************************************************************** 1.924 + * mozilla::Modifiers 1.925 + ******************************************************************************/ 1.926 + 1.927 +typedef uint16_t Modifiers; 1.928 + 1.929 +/****************************************************************************** 1.930 + * mozilla::WidgetInputEvent 1.931 + ******************************************************************************/ 1.932 + 1.933 +class WidgetInputEvent : public WidgetGUIEvent 1.934 +{ 1.935 +protected: 1.936 + WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, 1.937 + nsEventStructType aStructType) : 1.938 + WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aStructType), 1.939 + modifiers(0) 1.940 + { 1.941 + } 1.942 + 1.943 + WidgetInputEvent() 1.944 + { 1.945 + } 1.946 + 1.947 +public: 1.948 + virtual WidgetInputEvent* AsInputEvent() MOZ_OVERRIDE { return this; } 1.949 + 1.950 + WidgetInputEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : 1.951 + WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_INPUT_EVENT), 1.952 + modifiers(0) 1.953 + { 1.954 + } 1.955 + 1.956 + virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE 1.957 + { 1.958 + MOZ_ASSERT(eventStructType == NS_INPUT_EVENT, 1.959 + "Duplicate() must be overridden by sub class"); 1.960 + // Not copying widget, it is a weak reference. 1.961 + WidgetInputEvent* result = new WidgetInputEvent(false, message, nullptr); 1.962 + result->AssignInputEventData(*this, true); 1.963 + result->mFlags = mFlags; 1.964 + return result; 1.965 + } 1.966 + 1.967 + // true indicates the shift key is down 1.968 + bool IsShift() const 1.969 + { 1.970 + return ((modifiers & MODIFIER_SHIFT) != 0); 1.971 + } 1.972 + // true indicates the control key is down 1.973 + bool IsControl() const 1.974 + { 1.975 + return ((modifiers & MODIFIER_CONTROL) != 0); 1.976 + } 1.977 + // true indicates the alt key is down 1.978 + bool IsAlt() const 1.979 + { 1.980 + return ((modifiers & MODIFIER_ALT) != 0); 1.981 + } 1.982 + // true indicates the meta key is down (or, on Mac, the Command key) 1.983 + bool IsMeta() const 1.984 + { 1.985 + return ((modifiers & MODIFIER_META) != 0); 1.986 + } 1.987 + // true indicates the win key is down on Windows. Or the Super or Hyper key 1.988 + // is down on Linux. 1.989 + bool IsOS() const 1.990 + { 1.991 + return ((modifiers & MODIFIER_OS) != 0); 1.992 + } 1.993 + // true indicates the alt graph key is down 1.994 + // NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah() 1.995 + // return true. 1.996 + bool IsAltGraph() const 1.997 + { 1.998 + return ((modifiers & MODIFIER_ALTGRAPH) != 0); 1.999 + } 1.1000 + // true indeicates the CapLock LED is turn on. 1.1001 + bool IsCapsLocked() const 1.1002 + { 1.1003 + return ((modifiers & MODIFIER_CAPSLOCK) != 0); 1.1004 + } 1.1005 + // true indeicates the NumLock LED is turn on. 1.1006 + bool IsNumLocked() const 1.1007 + { 1.1008 + return ((modifiers & MODIFIER_NUMLOCK) != 0); 1.1009 + } 1.1010 + // true indeicates the ScrollLock LED is turn on. 1.1011 + bool IsScrollLocked() const 1.1012 + { 1.1013 + return ((modifiers & MODIFIER_SCROLLLOCK) != 0); 1.1014 + } 1.1015 + 1.1016 + // true indeicates the Fn key is down, but this is not supported by native 1.1017 + // key event on any platform. 1.1018 + bool IsFn() const 1.1019 + { 1.1020 + return ((modifiers & MODIFIER_FN) != 0); 1.1021 + } 1.1022 + // true indeicates the ScrollLock LED is turn on. 1.1023 + bool IsSymbolLocked() const 1.1024 + { 1.1025 + return ((modifiers & MODIFIER_SYMBOLLOCK) != 0); 1.1026 + } 1.1027 + 1.1028 + void InitBasicModifiers(bool aCtrlKey, 1.1029 + bool aAltKey, 1.1030 + bool aShiftKey, 1.1031 + bool aMetaKey) 1.1032 + { 1.1033 + modifiers = 0; 1.1034 + if (aCtrlKey) { 1.1035 + modifiers |= MODIFIER_CONTROL; 1.1036 + } 1.1037 + if (aAltKey) { 1.1038 + modifiers |= MODIFIER_ALT; 1.1039 + } 1.1040 + if (aShiftKey) { 1.1041 + modifiers |= MODIFIER_SHIFT; 1.1042 + } 1.1043 + if (aMetaKey) { 1.1044 + modifiers |= MODIFIER_META; 1.1045 + } 1.1046 + } 1.1047 + 1.1048 + Modifiers modifiers; 1.1049 + 1.1050 + void AssignInputEventData(const WidgetInputEvent& aEvent, bool aCopyTargets) 1.1051 + { 1.1052 + AssignGUIEventData(aEvent, aCopyTargets); 1.1053 + 1.1054 + modifiers = aEvent.modifiers; 1.1055 + } 1.1056 +}; 1.1057 + 1.1058 +/****************************************************************************** 1.1059 + * mozilla::InternalUIEvent 1.1060 + * 1.1061 + * XXX Why this inherits WidgetGUIEvent rather than WidgetEvent? 1.1062 + ******************************************************************************/ 1.1063 + 1.1064 +class InternalUIEvent : public WidgetGUIEvent 1.1065 +{ 1.1066 +protected: 1.1067 + InternalUIEvent() 1.1068 + : detail(0) 1.1069 + { 1.1070 + } 1.1071 + 1.1072 + InternalUIEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget, 1.1073 + nsEventStructType aStructType) 1.1074 + : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, aStructType) 1.1075 + , detail(0) 1.1076 + { 1.1077 + } 1.1078 + 1.1079 + InternalUIEvent(bool aIsTrusted, uint32_t aMessage, 1.1080 + nsEventStructType aStructType) 1.1081 + : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aStructType) 1.1082 + , detail(0) 1.1083 + { 1.1084 + } 1.1085 + 1.1086 +public: 1.1087 + virtual InternalUIEvent* AsUIEvent() MOZ_OVERRIDE { return this; } 1.1088 + 1.1089 + InternalUIEvent(bool aIsTrusted, uint32_t aMessage) 1.1090 + : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, NS_UI_EVENT) 1.1091 + , detail(0) 1.1092 + { 1.1093 + } 1.1094 + 1.1095 + virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE 1.1096 + { 1.1097 + MOZ_ASSERT(eventStructType == NS_UI_EVENT || 1.1098 + eventStructType == NS_SMIL_TIME_EVENT, 1.1099 + "Duplicate() must be overridden by sub class"); 1.1100 + InternalUIEvent* result = new InternalUIEvent(false, message); 1.1101 + result->AssignUIEventData(*this, true); 1.1102 + result->mFlags = mFlags; 1.1103 + return result; 1.1104 + } 1.1105 + 1.1106 + int32_t detail; 1.1107 + 1.1108 + void AssignUIEventData(const InternalUIEvent& aEvent, bool aCopyTargets) 1.1109 + { 1.1110 + AssignGUIEventData(aEvent, aCopyTargets); 1.1111 + 1.1112 + detail = aEvent.detail; 1.1113 + } 1.1114 +}; 1.1115 + 1.1116 +} // namespace mozilla 1.1117 + 1.1118 +#endif // mozilla_BasicEvents_h__