2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsGUIEvent_h__
|
|
|
|
#define nsGUIEvent_h__
|
|
|
|
|
2013-02-15 19:55:36 -08:00
|
|
|
#include "mozilla/MathAlgorithms.h"
|
|
|
|
|
2011-12-16 16:24:11 -08:00
|
|
|
#include "nsCOMArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsRect.h"
|
2008-09-18 02:47:21 -07:00
|
|
|
#include "nsRegion.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsEvent.h"
|
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIDOMKeyEvent.h"
|
2011-08-26 00:43:56 -07:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
2012-08-11 18:42:34 -07:00
|
|
|
#include "nsIDOMWheelEvent.h"
|
2008-08-27 05:07:27 -07:00
|
|
|
#include "nsIDOMDataTransfer.h"
|
2011-06-23 19:18:00 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2011-12-16 16:24:11 -08:00
|
|
|
#include "nsIDOMTouchEvent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsWeakPtr.h"
|
2008-02-06 20:04:58 -08:00
|
|
|
#include "nsIWidget.h"
|
2008-04-14 21:16:24 -07:00
|
|
|
#include "nsTArray.h"
|
2008-04-17 15:38:35 -07:00
|
|
|
#include "nsTraceRefcnt.h"
|
2009-03-17 19:04:01 -07:00
|
|
|
#include "nsITransferable.h"
|
2009-09-01 09:45:05 -07:00
|
|
|
#include "nsIVariant.h"
|
2011-03-31 05:26:49 -07:00
|
|
|
#include "nsStyleConsts.h"
|
2011-12-16 16:24:11 -08:00
|
|
|
#include "nsAutoPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
|
|
|
}
|
2011-08-29 09:26:24 -07:00
|
|
|
namespace plugins {
|
|
|
|
class PPluginInstanceChild;
|
|
|
|
}
|
2010-08-17 01:07:42 -07:00
|
|
|
}
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
class nsRenderingContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIMenuItem;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIURI;
|
|
|
|
class nsHashKey;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event Struct Types
|
|
|
|
*/
|
2012-11-19 22:05:56 -08:00
|
|
|
enum nsEventStructType {
|
|
|
|
// Generic events
|
|
|
|
NS_EVENT, // nsEvent
|
|
|
|
NS_GUI_EVENT, // nsGUIEvent
|
|
|
|
NS_INPUT_EVENT, // nsInputEvent
|
|
|
|
|
|
|
|
// Mouse related events
|
|
|
|
NS_MOUSE_EVENT, // nsMouseEvent
|
|
|
|
NS_MOUSE_SCROLL_EVENT, // nsMouseScrollEvent
|
|
|
|
NS_DRAG_EVENT, // nsDragEvent
|
|
|
|
NS_WHEEL_EVENT, // widget::WheelEvent
|
|
|
|
|
|
|
|
// Touchpad related events
|
|
|
|
NS_GESTURENOTIFY_EVENT, // nsGestureNotifyEvent
|
|
|
|
NS_SIMPLE_GESTURE_EVENT, // nsSimpleGestureEvent
|
|
|
|
NS_TOUCH_EVENT, // nsTouchEvent
|
|
|
|
|
|
|
|
// Key or IME events
|
|
|
|
NS_KEY_EVENT, // nsKeyEvent
|
|
|
|
NS_COMPOSITION_EVENT, // nsCompositionEvent
|
|
|
|
NS_TEXT_EVENT, // nsTextEvent
|
|
|
|
|
|
|
|
// IME related events
|
|
|
|
NS_QUERY_CONTENT_EVENT, // nsQueryContentEvent
|
|
|
|
NS_SELECTION_EVENT, // nsSelectionEvent
|
|
|
|
|
|
|
|
// Scroll related events
|
|
|
|
NS_SCROLLBAR_EVENT, // nsScrollbarEvent
|
|
|
|
NS_SCROLLPORT_EVENT, // nsScrollPortEvent
|
|
|
|
NS_SCROLLAREA_EVENT, // nsScrollAreaEvent
|
|
|
|
|
|
|
|
// DOM events
|
|
|
|
NS_UI_EVENT, // nsUIEvent
|
|
|
|
NS_SCRIPT_ERROR_EVENT, // nsScriptErrorEvent
|
|
|
|
NS_MUTATION_EVENT, // nsMutationEvent
|
|
|
|
NS_FORM_EVENT, // nsFormEvent
|
|
|
|
NS_FOCUS_EVENT, // nsFocusEvent
|
2013-03-11 08:49:48 -07:00
|
|
|
NS_CLIPBOARD_EVENT, // nsClipboardEvent
|
2012-11-19 22:05:56 -08:00
|
|
|
|
|
|
|
// SVG events
|
|
|
|
NS_SVGZOOM_EVENT, // nsGUIEvent
|
|
|
|
NS_SMIL_TIME_EVENT, // nsUIEvent
|
|
|
|
|
|
|
|
// CSS events
|
|
|
|
NS_TRANSITION_EVENT, // nsTransitionEvent
|
|
|
|
NS_ANIMATION_EVENT, // nsAnimationEvent
|
|
|
|
|
|
|
|
// Command events
|
|
|
|
NS_COMMAND_EVENT, // nsCommandEvent
|
|
|
|
NS_CONTENT_COMMAND_EVENT, // nsContentCommandEvent
|
|
|
|
|
|
|
|
// Plugin event
|
|
|
|
NS_PLUGIN_EVENT // nsPluginEvent
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_EVENT_TYPE_NULL 0
|
2012-11-01 05:42:29 -07:00
|
|
|
#define NS_EVENT_TYPE_ALL 1 // Not a real event type
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GUI MESSAGES
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
#define NS_EVENT_NULL 0
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_WINDOW_START 100
|
|
|
|
|
|
|
|
// Widget may be destroyed
|
|
|
|
#define NS_XUL_CLOSE (NS_WINDOW_START + 1)
|
|
|
|
// Key is pressed within a window
|
|
|
|
#define NS_KEY_PRESS (NS_WINDOW_START + 31)
|
|
|
|
// Key is released within a window
|
|
|
|
#define NS_KEY_UP (NS_WINDOW_START + 32)
|
|
|
|
// Key is pressed within a window
|
|
|
|
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
|
2011-03-25 16:17:35 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
|
|
|
|
#define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
|
|
|
|
|
2010-11-15 13:12:50 -08:00
|
|
|
// A plugin was clicked or otherwise focused. NS_PLUGIN_ACTIVATE should be
|
|
|
|
// used when the window is not active. NS_PLUGIN_FOCUS should be used when
|
|
|
|
// the window is active. In the latter case, the dispatcher of the event
|
|
|
|
// is expected to ensure that the plugin's widget is focused beforehand.
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_PLUGIN_ACTIVATE (NS_WINDOW_START + 62)
|
2010-11-15 13:12:50 -08:00
|
|
|
#define NS_PLUGIN_FOCUS (NS_WINDOW_START + 63)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-15 13:12:50 -08:00
|
|
|
#define NS_OFFLINE (NS_WINDOW_START + 64)
|
|
|
|
#define NS_ONLINE (NS_WINDOW_START + 65)
|
2007-06-06 20:28:04 -07:00
|
|
|
|
2010-11-17 05:46:00 -08:00
|
|
|
// Indicates a resize will occur
|
|
|
|
#define NS_BEFORERESIZE_EVENT (NS_WINDOW_START + 66)
|
|
|
|
|
2012-06-29 01:32:21 -07:00
|
|
|
// Indicates that the user is either idle or active
|
|
|
|
#define NS_MOZ_USER_IDLE (NS_WINDOW_START + 67)
|
|
|
|
#define NS_MOZ_USER_ACTIVE (NS_WINDOW_START + 68)
|
|
|
|
|
2012-10-16 12:41:21 -07:00
|
|
|
// The resolution at which a plugin should draw has changed, for
|
|
|
|
// example as the result of changing from a HiDPI mode to a non-
|
|
|
|
// HiDPI mode.
|
|
|
|
#define NS_PLUGIN_RESOLUTION_CHANGED (NS_WINDOW_START + 69)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_MOUSE_MESSAGE_START 300
|
|
|
|
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
|
|
|
#define NS_MOUSE_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
|
|
|
|
#define NS_MOUSE_BUTTON_DOWN (NS_MOUSE_MESSAGE_START + 2)
|
|
|
|
#define NS_MOUSE_ENTER (NS_MOUSE_MESSAGE_START + 22)
|
|
|
|
#define NS_MOUSE_EXIT (NS_MOUSE_MESSAGE_START + 23)
|
|
|
|
#define NS_MOUSE_DOUBLECLICK (NS_MOUSE_MESSAGE_START + 24)
|
|
|
|
#define NS_MOUSE_CLICK (NS_MOUSE_MESSAGE_START + 27)
|
|
|
|
#define NS_MOUSE_ACTIVATE (NS_MOUSE_MESSAGE_START + 30)
|
|
|
|
#define NS_MOUSE_ENTER_SYNTH (NS_MOUSE_MESSAGE_START + 31)
|
|
|
|
#define NS_MOUSE_EXIT_SYNTH (NS_MOUSE_MESSAGE_START + 32)
|
2010-06-27 23:04:05 -07:00
|
|
|
#define NS_MOUSE_MOZHITTEST (NS_MOUSE_MESSAGE_START + 33)
|
2011-09-18 00:45:14 -07:00
|
|
|
#define NS_MOUSEENTER (NS_MOUSE_MESSAGE_START + 34)
|
|
|
|
#define NS_MOUSELEAVE (NS_MOUSE_MESSAGE_START + 35)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_CONTEXTMENU_MESSAGE_START 500
|
|
|
|
#define NS_CONTEXTMENU (NS_CONTEXTMENU_MESSAGE_START)
|
|
|
|
|
|
|
|
#define NS_STREAM_EVENT_START 1100
|
|
|
|
#define NS_LOAD (NS_STREAM_EVENT_START)
|
|
|
|
#define NS_PAGE_UNLOAD (NS_STREAM_EVENT_START + 1)
|
2009-06-26 10:16:50 -07:00
|
|
|
#define NS_HASHCHANGE (NS_STREAM_EVENT_START + 2)
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_IMAGE_ABORT (NS_STREAM_EVENT_START + 3)
|
|
|
|
#define NS_LOAD_ERROR (NS_STREAM_EVENT_START + 4)
|
2009-09-01 09:45:05 -07:00
|
|
|
#define NS_POPSTATE (NS_STREAM_EVENT_START + 5)
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_BEFORE_PAGE_UNLOAD (NS_STREAM_EVENT_START + 6)
|
|
|
|
#define NS_PAGE_RESTORE (NS_STREAM_EVENT_START + 7)
|
2010-06-23 18:12:07 -07:00
|
|
|
#define NS_READYSTATECHANGE (NS_STREAM_EVENT_START + 8)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_FORM_EVENT_START 1200
|
|
|
|
#define NS_FORM_SUBMIT (NS_FORM_EVENT_START)
|
|
|
|
#define NS_FORM_RESET (NS_FORM_EVENT_START + 1)
|
|
|
|
#define NS_FORM_CHANGE (NS_FORM_EVENT_START + 2)
|
|
|
|
#define NS_FORM_SELECTED (NS_FORM_EVENT_START + 3)
|
|
|
|
#define NS_FORM_INPUT (NS_FORM_EVENT_START + 4)
|
2010-08-18 11:28:08 -07:00
|
|
|
#define NS_FORM_INVALID (NS_FORM_EVENT_START + 5)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//Need separate focus/blur notifications for non-native widgets
|
|
|
|
#define NS_FOCUS_EVENT_START 1300
|
|
|
|
#define NS_FOCUS_CONTENT (NS_FOCUS_EVENT_START)
|
|
|
|
#define NS_BLUR_CONTENT (NS_FOCUS_EVENT_START + 1)
|
|
|
|
|
|
|
|
#define NS_DRAGDROP_EVENT_START 1400
|
|
|
|
#define NS_DRAGDROP_ENTER (NS_DRAGDROP_EVENT_START)
|
|
|
|
#define NS_DRAGDROP_OVER (NS_DRAGDROP_EVENT_START + 1)
|
|
|
|
#define NS_DRAGDROP_EXIT (NS_DRAGDROP_EVENT_START + 2)
|
2008-08-27 05:07:27 -07:00
|
|
|
#define NS_DRAGDROP_DRAGDROP (NS_DRAGDROP_EVENT_START + 3)
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_DRAGDROP_GESTURE (NS_DRAGDROP_EVENT_START + 4)
|
2007-04-11 21:37:39 -07:00
|
|
|
#define NS_DRAGDROP_DRAG (NS_DRAGDROP_EVENT_START + 5)
|
|
|
|
#define NS_DRAGDROP_END (NS_DRAGDROP_EVENT_START + 6)
|
2008-08-27 05:07:27 -07:00
|
|
|
#define NS_DRAGDROP_START (NS_DRAGDROP_EVENT_START + 7)
|
|
|
|
#define NS_DRAGDROP_DROP (NS_DRAGDROP_EVENT_START + 8)
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_DRAGDROP_OVER_SYNTH (NS_DRAGDROP_EVENT_START + 1)
|
|
|
|
#define NS_DRAGDROP_EXIT_SYNTH (NS_DRAGDROP_EVENT_START + 2)
|
2008-08-27 05:07:27 -07:00
|
|
|
#define NS_DRAGDROP_LEAVE_SYNTH (NS_DRAGDROP_EVENT_START + 9)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Events for popups
|
|
|
|
#define NS_XUL_EVENT_START 1500
|
|
|
|
#define NS_XUL_POPUP_SHOWING (NS_XUL_EVENT_START)
|
|
|
|
#define NS_XUL_POPUP_SHOWN (NS_XUL_EVENT_START+1)
|
|
|
|
#define NS_XUL_POPUP_HIDING (NS_XUL_EVENT_START+2)
|
|
|
|
#define NS_XUL_POPUP_HIDDEN (NS_XUL_EVENT_START+3)
|
|
|
|
// NS_XUL_COMMAND used to be here (NS_XUL_EVENT_START+4)
|
|
|
|
#define NS_XUL_BROADCAST (NS_XUL_EVENT_START+5)
|
|
|
|
#define NS_XUL_COMMAND_UPDATE (NS_XUL_EVENT_START+6)
|
|
|
|
//@}
|
|
|
|
|
|
|
|
// Scroll events
|
|
|
|
#define NS_MOUSE_SCROLL_START 1600
|
|
|
|
#define NS_MOUSE_SCROLL (NS_MOUSE_SCROLL_START)
|
2008-09-17 04:27:19 -07:00
|
|
|
#define NS_MOUSE_PIXEL_SCROLL (NS_MOUSE_SCROLL_START + 1)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_SCROLLPORT_START 1700
|
|
|
|
#define NS_SCROLLPORT_UNDERFLOW (NS_SCROLLPORT_START)
|
|
|
|
#define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
|
|
|
|
|
|
|
|
// Mutation events defined elsewhere starting at 1800
|
|
|
|
|
|
|
|
#define NS_USER_DEFINED_EVENT 2000
|
|
|
|
|
|
|
|
// composition events
|
|
|
|
#define NS_COMPOSITION_EVENT_START 2200
|
|
|
|
#define NS_COMPOSITION_START (NS_COMPOSITION_EVENT_START)
|
|
|
|
#define NS_COMPOSITION_END (NS_COMPOSITION_EVENT_START + 1)
|
2011-09-22 02:17:40 -07:00
|
|
|
#define NS_COMPOSITION_UPDATE (NS_COMPOSITION_EVENT_START + 2)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// text events
|
|
|
|
#define NS_TEXT_START 2400
|
|
|
|
#define NS_TEXT_TEXT (NS_TEXT_START)
|
|
|
|
|
|
|
|
// UI events
|
|
|
|
#define NS_UI_EVENT_START 2500
|
|
|
|
// this is not to be confused with NS_ACTIVATE!
|
|
|
|
#define NS_UI_ACTIVATE (NS_UI_EVENT_START)
|
|
|
|
#define NS_UI_FOCUSIN (NS_UI_EVENT_START + 1)
|
|
|
|
#define NS_UI_FOCUSOUT (NS_UI_EVENT_START + 2)
|
|
|
|
|
|
|
|
// pagetransition events
|
|
|
|
#define NS_PAGETRANSITION_START 2700
|
|
|
|
#define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
|
|
|
|
#define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
|
|
|
|
|
|
|
|
// SVG events
|
|
|
|
#define NS_SVG_EVENT_START 2800
|
|
|
|
#define NS_SVG_LOAD (NS_SVG_EVENT_START)
|
|
|
|
#define NS_SVG_UNLOAD (NS_SVG_EVENT_START + 1)
|
|
|
|
#define NS_SVG_ABORT (NS_SVG_EVENT_START + 2)
|
|
|
|
#define NS_SVG_ERROR (NS_SVG_EVENT_START + 3)
|
|
|
|
#define NS_SVG_RESIZE (NS_SVG_EVENT_START + 4)
|
|
|
|
#define NS_SVG_SCROLL (NS_SVG_EVENT_START + 5)
|
|
|
|
|
|
|
|
// SVG Zoom events
|
|
|
|
#define NS_SVGZOOM_EVENT_START 2900
|
|
|
|
#define NS_SVG_ZOOM (NS_SVGZOOM_EVENT_START)
|
|
|
|
|
|
|
|
// XUL command events
|
|
|
|
#define NS_XULCOMMAND_EVENT_START 3000
|
|
|
|
#define NS_XUL_COMMAND (NS_XULCOMMAND_EVENT_START)
|
|
|
|
|
2007-07-25 21:14:33 -07:00
|
|
|
// Cut, copy, paste events
|
|
|
|
#define NS_CUTCOPYPASTE_EVENT_START 3100
|
|
|
|
#define NS_COPY (NS_CUTCOPYPASTE_EVENT_START)
|
|
|
|
#define NS_CUT (NS_CUTCOPYPASTE_EVENT_START + 1)
|
|
|
|
#define NS_PASTE (NS_CUTCOPYPASTE_EVENT_START + 2)
|
|
|
|
|
2008-02-19 23:40:04 -08:00
|
|
|
// Query the content information
|
|
|
|
#define NS_QUERY_CONTENT_EVENT_START 3200
|
|
|
|
// Query for the selected text information, it return the selection offset,
|
|
|
|
// selection length and selected text.
|
|
|
|
#define NS_QUERY_SELECTED_TEXT (NS_QUERY_CONTENT_EVENT_START)
|
|
|
|
// Query for the text content of specified range, it returns actual lengh (if
|
|
|
|
// the specified range is too long) and the text of the specified range.
|
2009-02-10 12:56:51 -08:00
|
|
|
// Returns the entire text if requested length > actual length.
|
2008-02-19 23:40:04 -08:00
|
|
|
#define NS_QUERY_TEXT_CONTENT (NS_QUERY_CONTENT_EVENT_START + 1)
|
|
|
|
// Query for the caret rect of nth insertion point. The offset of the result is
|
|
|
|
// relative position from the top level widget.
|
|
|
|
#define NS_QUERY_CARET_RECT (NS_QUERY_CONTENT_EVENT_START + 3)
|
2009-02-10 12:56:51 -08:00
|
|
|
// Query for the bounding rect of a range of characters. This works on any
|
|
|
|
// valid character range given offset and length. Result is relative to top
|
|
|
|
// level widget coordinates
|
|
|
|
#define NS_QUERY_TEXT_RECT (NS_QUERY_CONTENT_EVENT_START + 4)
|
|
|
|
// Query for the bounding rect of the current focused frame. Result is relative
|
|
|
|
// to top level widget coordinates
|
2009-05-14 17:46:24 -07:00
|
|
|
#define NS_QUERY_EDITOR_RECT (NS_QUERY_CONTENT_EVENT_START + 5)
|
2009-03-17 19:04:01 -07:00
|
|
|
// Query for the current state of the content. The particular members of
|
|
|
|
// mReply that are set for each query content event will be valid on success.
|
2009-05-14 17:46:24 -07:00
|
|
|
#define NS_QUERY_CONTENT_STATE (NS_QUERY_CONTENT_EVENT_START + 6)
|
2009-03-17 19:04:01 -07:00
|
|
|
// Query for the selection in the form of a nsITransferable.
|
|
|
|
#define NS_QUERY_SELECTION_AS_TRANSFERABLE (NS_QUERY_CONTENT_EVENT_START + 7)
|
2009-05-14 17:46:24 -07:00
|
|
|
// Query for character at a point. This returns the character offset and its
|
|
|
|
// rect. The point is specified by nsEvent::refPoint.
|
|
|
|
#define NS_QUERY_CHARACTER_AT_POINT (NS_QUERY_CONTENT_EVENT_START + 8)
|
2011-03-01 13:15:23 -08:00
|
|
|
// Query if the DOM element under nsEvent::refPoint belongs to our widget
|
|
|
|
// or not.
|
|
|
|
#define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9)
|
2008-02-19 23:40:04 -08:00
|
|
|
|
2008-07-09 01:22:20 -07:00
|
|
|
// Video events
|
|
|
|
#define NS_MEDIA_EVENT_START 3300
|
|
|
|
#define NS_LOADSTART (NS_MEDIA_EVENT_START)
|
|
|
|
#define NS_PROGRESS (NS_MEDIA_EVENT_START+1)
|
2009-02-26 03:55:30 -08:00
|
|
|
#define NS_SUSPEND (NS_MEDIA_EVENT_START+2)
|
|
|
|
#define NS_EMPTIED (NS_MEDIA_EVENT_START+3)
|
|
|
|
#define NS_STALLED (NS_MEDIA_EVENT_START+4)
|
|
|
|
#define NS_PLAY (NS_MEDIA_EVENT_START+5)
|
|
|
|
#define NS_PAUSE (NS_MEDIA_EVENT_START+6)
|
|
|
|
#define NS_LOADEDMETADATA (NS_MEDIA_EVENT_START+7)
|
|
|
|
#define NS_LOADEDDATA (NS_MEDIA_EVENT_START+8)
|
|
|
|
#define NS_WAITING (NS_MEDIA_EVENT_START+9)
|
|
|
|
#define NS_PLAYING (NS_MEDIA_EVENT_START+10)
|
|
|
|
#define NS_CANPLAY (NS_MEDIA_EVENT_START+11)
|
|
|
|
#define NS_CANPLAYTHROUGH (NS_MEDIA_EVENT_START+12)
|
|
|
|
#define NS_SEEKING (NS_MEDIA_EVENT_START+13)
|
|
|
|
#define NS_SEEKED (NS_MEDIA_EVENT_START+14)
|
|
|
|
#define NS_TIMEUPDATE (NS_MEDIA_EVENT_START+15)
|
|
|
|
#define NS_ENDED (NS_MEDIA_EVENT_START+16)
|
|
|
|
#define NS_RATECHANGE (NS_MEDIA_EVENT_START+17)
|
|
|
|
#define NS_DURATIONCHANGE (NS_MEDIA_EVENT_START+18)
|
|
|
|
#define NS_VOLUMECHANGE (NS_MEDIA_EVENT_START+19)
|
2010-08-25 06:10:00 -07:00
|
|
|
#define NS_MOZAUDIOAVAILABLE (NS_MEDIA_EVENT_START+20)
|
2008-07-09 01:22:20 -07:00
|
|
|
|
2008-09-18 02:47:21 -07:00
|
|
|
// paint notification events
|
|
|
|
#define NS_NOTIFYPAINT_START 3400
|
|
|
|
#define NS_AFTERPAINT (NS_NOTIFYPAINT_START)
|
|
|
|
|
2008-10-23 13:15:20 -07:00
|
|
|
// Simple gesture events
|
|
|
|
#define NS_SIMPLE_GESTURE_EVENT_START 3500
|
2013-02-08 16:52:12 -08:00
|
|
|
#define NS_SIMPLE_GESTURE_SWIPE (NS_SIMPLE_GESTURE_EVENT_START)
|
|
|
|
#define NS_SIMPLE_GESTURE_MAGNIFY_START (NS_SIMPLE_GESTURE_EVENT_START+1)
|
|
|
|
#define NS_SIMPLE_GESTURE_MAGNIFY_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+2)
|
|
|
|
#define NS_SIMPLE_GESTURE_MAGNIFY (NS_SIMPLE_GESTURE_EVENT_START+3)
|
|
|
|
#define NS_SIMPLE_GESTURE_ROTATE_START (NS_SIMPLE_GESTURE_EVENT_START+4)
|
|
|
|
#define NS_SIMPLE_GESTURE_ROTATE_UPDATE (NS_SIMPLE_GESTURE_EVENT_START+5)
|
|
|
|
#define NS_SIMPLE_GESTURE_ROTATE (NS_SIMPLE_GESTURE_EVENT_START+6)
|
|
|
|
#define NS_SIMPLE_GESTURE_TAP (NS_SIMPLE_GESTURE_EVENT_START+7)
|
|
|
|
#define NS_SIMPLE_GESTURE_PRESSTAP (NS_SIMPLE_GESTURE_EVENT_START+8)
|
|
|
|
#define NS_SIMPLE_GESTURE_EDGEUI (NS_SIMPLE_GESTURE_EVENT_START+9)
|
2008-10-23 13:15:20 -07:00
|
|
|
|
2011-05-10 21:52:44 -07:00
|
|
|
// These are used to send native events to plugins.
|
|
|
|
#define NS_PLUGIN_EVENT_START 3600
|
|
|
|
#define NS_PLUGIN_INPUT_EVENT (NS_PLUGIN_EVENT_START)
|
|
|
|
#define NS_PLUGIN_FOCUS_EVENT (NS_PLUGIN_EVENT_START+1)
|
2008-12-14 19:54:54 -08:00
|
|
|
|
2009-02-10 12:56:51 -08:00
|
|
|
// Events to manipulate selection (nsSelectionEvent)
|
|
|
|
#define NS_SELECTION_EVENT_START 3700
|
|
|
|
// Clear any previous selection and set the given range as the selection
|
|
|
|
#define NS_SELECTION_SET (NS_SELECTION_EVENT_START)
|
|
|
|
|
2009-08-07 08:11:17 -07:00
|
|
|
// Events of commands for the contents
|
|
|
|
#define NS_CONTENT_COMMAND_EVENT_START 3800
|
|
|
|
#define NS_CONTENT_COMMAND_CUT (NS_CONTENT_COMMAND_EVENT_START)
|
|
|
|
#define NS_CONTENT_COMMAND_COPY (NS_CONTENT_COMMAND_EVENT_START+1)
|
|
|
|
#define NS_CONTENT_COMMAND_PASTE (NS_CONTENT_COMMAND_EVENT_START+2)
|
|
|
|
#define NS_CONTENT_COMMAND_DELETE (NS_CONTENT_COMMAND_EVENT_START+3)
|
|
|
|
#define NS_CONTENT_COMMAND_UNDO (NS_CONTENT_COMMAND_EVENT_START+4)
|
|
|
|
#define NS_CONTENT_COMMAND_REDO (NS_CONTENT_COMMAND_EVENT_START+5)
|
2010-01-10 17:45:45 -08:00
|
|
|
#define NS_CONTENT_COMMAND_PASTE_TRANSFERABLE (NS_CONTENT_COMMAND_EVENT_START+6)
|
2010-03-10 21:25:29 -08:00
|
|
|
// NS_CONTENT_COMMAND_SCROLL scrolls the nearest scrollable element to the
|
|
|
|
// currently focused content or latest DOM selection. This would normally be
|
|
|
|
// the same element scrolled by keyboard scroll commands, except that this event
|
|
|
|
// will scroll an element scrollable in either direction. I.e., if the nearest
|
|
|
|
// scrollable ancestor element can only be scrolled vertically, and horizontal
|
|
|
|
// scrolling is requested using this event, no scrolling will occur.
|
|
|
|
#define NS_CONTENT_COMMAND_SCROLL (NS_CONTENT_COMMAND_EVENT_START+7)
|
2009-08-07 08:11:17 -07:00
|
|
|
|
2009-08-13 13:54:09 -07:00
|
|
|
// Event to gesture notification
|
|
|
|
#define NS_GESTURENOTIFY_EVENT_START 3900
|
|
|
|
|
2009-08-21 10:28:52 -07:00
|
|
|
#define NS_ORIENTATION_EVENT 4000
|
|
|
|
|
2009-09-11 16:13:56 -07:00
|
|
|
#define NS_SCROLLAREA_EVENT_START 4100
|
|
|
|
#define NS_SCROLLEDAREACHANGED (NS_SCROLLAREA_EVENT_START)
|
|
|
|
|
2009-12-23 11:10:31 -08:00
|
|
|
#define NS_TRANSITION_EVENT_START 4200
|
|
|
|
#define NS_TRANSITION_END (NS_TRANSITION_EVENT_START)
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2011-04-11 23:18:44 -07:00
|
|
|
#define NS_ANIMATION_EVENT_START 4250
|
|
|
|
#define NS_ANIMATION_START (NS_ANIMATION_EVENT_START)
|
|
|
|
#define NS_ANIMATION_END (NS_ANIMATION_EVENT_START + 1)
|
|
|
|
#define NS_ANIMATION_ITERATION (NS_ANIMATION_EVENT_START + 2)
|
|
|
|
|
2010-07-31 00:02:52 -07:00
|
|
|
#define NS_SMIL_TIME_EVENT_START 4300
|
|
|
|
#define NS_SMIL_BEGIN (NS_SMIL_TIME_EVENT_START)
|
|
|
|
#define NS_SMIL_END (NS_SMIL_TIME_EVENT_START + 1)
|
|
|
|
#define NS_SMIL_REPEAT (NS_SMIL_TIME_EVENT_START + 2)
|
|
|
|
|
2010-09-16 01:48:47 -07:00
|
|
|
// script notification events
|
2011-05-14 05:03:58 -07:00
|
|
|
#define NS_NOTIFYSCRIPT_START 4500
|
|
|
|
#define NS_BEFORE_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START)
|
|
|
|
#define NS_AFTER_SCRIPT_EXECUTE (NS_NOTIFYSCRIPT_START+1)
|
|
|
|
|
|
|
|
#define NS_PRINT_EVENT_START 4600
|
|
|
|
#define NS_BEFOREPRINT (NS_PRINT_EVENT_START)
|
|
|
|
#define NS_AFTERPRINT (NS_PRINT_EVENT_START + 1)
|
2010-09-16 01:48:47 -07:00
|
|
|
|
2011-05-22 14:30:07 -07:00
|
|
|
#define NS_MESSAGE_EVENT_START 4700
|
|
|
|
#define NS_MESSAGE (NS_MESSAGE_EVENT_START)
|
|
|
|
|
|
|
|
// Open and close events
|
|
|
|
#define NS_OPENCLOSE_EVENT_START 4800
|
|
|
|
#define NS_OPEN (NS_OPENCLOSE_EVENT_START)
|
|
|
|
#define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1)
|
|
|
|
|
2011-06-28 15:37:31 -07:00
|
|
|
// Device motion and orientation
|
|
|
|
#define NS_DEVICE_ORIENTATION_START 4900
|
|
|
|
#define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START)
|
|
|
|
#define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1)
|
2012-05-02 09:43:45 -07:00
|
|
|
#define NS_DEVICE_PROXIMITY (NS_DEVICE_ORIENTATION_START+2)
|
2012-05-16 13:27:54 -07:00
|
|
|
#define NS_USER_PROXIMITY (NS_DEVICE_ORIENTATION_START+3)
|
|
|
|
#define NS_DEVICE_LIGHT (NS_DEVICE_ORIENTATION_START+4)
|
2011-06-28 15:37:31 -07:00
|
|
|
|
2011-08-08 10:31:32 -07:00
|
|
|
#define NS_SHOW_EVENT 5000
|
|
|
|
|
2011-09-04 13:40:11 -07:00
|
|
|
// Fullscreen DOM API
|
|
|
|
#define NS_FULL_SCREEN_START 5100
|
|
|
|
#define NS_FULLSCREENCHANGE (NS_FULL_SCREEN_START)
|
2011-11-01 17:02:47 -07:00
|
|
|
#define NS_FULLSCREENERROR (NS_FULL_SCREEN_START + 1)
|
2011-09-04 13:40:11 -07:00
|
|
|
|
2011-12-16 16:24:11 -08:00
|
|
|
#define NS_TOUCH_EVENT_START 5200
|
|
|
|
#define NS_TOUCH_START (NS_TOUCH_EVENT_START)
|
|
|
|
#define NS_TOUCH_MOVE (NS_TOUCH_EVENT_START+1)
|
|
|
|
#define NS_TOUCH_END (NS_TOUCH_EVENT_START+2)
|
|
|
|
#define NS_TOUCH_ENTER (NS_TOUCH_EVENT_START+3)
|
|
|
|
#define NS_TOUCH_LEAVE (NS_TOUCH_EVENT_START+4)
|
|
|
|
#define NS_TOUCH_CANCEL (NS_TOUCH_EVENT_START+5)
|
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
// Pointerlock DOM API
|
|
|
|
#define NS_POINTERLOCK_START 5300
|
|
|
|
#define NS_POINTERLOCKCHANGE (NS_POINTERLOCK_START)
|
|
|
|
#define NS_POINTERLOCKERROR (NS_POINTERLOCK_START + 1)
|
|
|
|
|
2012-08-11 18:42:34 -07:00
|
|
|
#define NS_WHEEL_EVENT_START 5400
|
|
|
|
#define NS_WHEEL_WHEEL (NS_WHEEL_EVENT_START)
|
|
|
|
|
2012-09-10 23:05:00 -07:00
|
|
|
//System time is changed
|
|
|
|
#define NS_MOZ_TIME_CHANGE_EVENT 5500
|
|
|
|
|
2012-09-30 06:47:48 -07:00
|
|
|
// Network packet events.
|
|
|
|
#define NS_NETWORK_EVENT_START 5600
|
|
|
|
#define NS_NETWORK_UPLOAD_EVENT (NS_NETWORK_EVENT_START + 1)
|
|
|
|
#define NS_NETWORK_DOWNLOAD_EVENT (NS_NETWORK_EVENT_START + 2)
|
|
|
|
|
2011-08-03 11:12:08 -07:00
|
|
|
#ifdef MOZ_GAMEPAD
|
|
|
|
// Gamepad input events
|
|
|
|
#define NS_GAMEPAD_START 6000
|
|
|
|
#define NS_GAMEPAD_BUTTONDOWN (NS_GAMEPAD_START)
|
|
|
|
#define NS_GAMEPAD_BUTTONUP (NS_GAMEPAD_START+1)
|
|
|
|
#define NS_GAMEPAD_AXISMOVE (NS_GAMEPAD_START+2)
|
|
|
|
#define NS_GAMEPAD_CONNECTED (NS_GAMEPAD_START+3)
|
|
|
|
#define NS_GAMEPAD_DISCONNECTED (NS_GAMEPAD_START+4)
|
|
|
|
// Keep this defined to the same value as the event above
|
|
|
|
#define NS_GAMEPAD_END (NS_GAMEPAD_START+4)
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Return status for event processors, nsEventStatus, is defined in
|
|
|
|
* nsEvent.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* different types of (top-level) window z-level positioning
|
|
|
|
*/
|
|
|
|
enum nsWindowZ {
|
|
|
|
nsWindowZTop = 0, // on top
|
|
|
|
nsWindowZBottom, // on bottom
|
|
|
|
nsWindowZRelative // just below some specified widget
|
|
|
|
};
|
|
|
|
|
2012-12-15 17:26:03 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
2012-12-28 06:13:18 -08:00
|
|
|
|
|
|
|
// BaseEventFlags must be a POD struct for safe to use memcpy (including
|
|
|
|
// in ParamTraits<BaseEventFlags>). So don't make virtual methods, constructor,
|
|
|
|
// destructor and operators.
|
|
|
|
// This is necessary for VC which is NOT C++0x compiler.
|
|
|
|
struct BaseEventFlags
|
2012-12-15 17:26:03 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// If mIsTrusted is true, the event is a trusted event. Otherwise, it's
|
|
|
|
// an untrusted event.
|
|
|
|
bool mIsTrusted : 1;
|
2012-12-15 17:26:03 -08:00
|
|
|
// If mInBubblingPhase is true, the event is in bubbling phase or target
|
|
|
|
// phase.
|
|
|
|
bool mInBubblingPhase : 1;
|
|
|
|
// If mInCapturePhase is true, the event is in capture phase or target phase.
|
|
|
|
bool mInCapturePhase : 1;
|
2012-12-15 17:26:05 -08:00
|
|
|
// If mInSystemGroup is true, the event is being dispatched in system group.
|
|
|
|
bool mInSystemGroup: 1;
|
2012-12-15 17:26:03 -08:00
|
|
|
// If mCancelable is true, the event can be consumed. I.e., calling
|
|
|
|
// nsDOMEvent::PreventDefault() can prevent the default action.
|
|
|
|
bool mCancelable : 1;
|
|
|
|
// If mBubbles is true, the event can bubble. Otherwise, cannot be handled
|
|
|
|
// in bubbling phase.
|
|
|
|
bool mBubbles : 1;
|
2012-12-15 17:26:03 -08:00
|
|
|
// If mPropagationStopped is true, nsDOMEvent::StopPropagation() or
|
|
|
|
// nsDOMEvent::StopImmediatePropagation() has been called.
|
|
|
|
bool mPropagationStopped : 1;
|
|
|
|
// If mImmediatePropagationStopped is true,
|
|
|
|
// nsDOMEvent::StopImmediatePropagation() has been called.
|
|
|
|
// Note that mPropagationStopped must be true when this is true.
|
|
|
|
bool mImmediatePropagationStopped : 1;
|
2012-12-15 17:26:04 -08:00
|
|
|
// If mDefaultPrevented is true, the event has been consumed.
|
|
|
|
// E.g., nsDOMEvent::PreventDefault() has been called or
|
|
|
|
// the default action has been performed.
|
|
|
|
bool mDefaultPrevented : 1;
|
|
|
|
// If mDefaultPreventedByContent is true, the event has been
|
|
|
|
// consumed by content.
|
|
|
|
// Note that mDefaultPrevented must be true when this is true.
|
|
|
|
bool mDefaultPreventedByContent : 1;
|
2012-12-15 17:26:04 -08:00
|
|
|
// mMultipleActionsPrevented may be used when default handling don't want to
|
|
|
|
// be prevented, but only one of the event targets should handle the event.
|
|
|
|
// For example, when a <label> element is in another <label> element and
|
|
|
|
// the first <label> element is clicked, that one may set this true.
|
|
|
|
// Then, the second <label> element won't handle the event.
|
|
|
|
bool mMultipleActionsPrevented : 1;
|
2012-12-15 17:26:04 -08:00
|
|
|
// If mIsBeingDispatched is true, the DOM event created from the event is
|
|
|
|
// dispatching into the DOM tree and not completed.
|
|
|
|
bool mIsBeingDispatched : 1;
|
|
|
|
// If mDispatchedAtLeastOnce is true, the event has been dispatched
|
|
|
|
// as a DOM event and the dispatch has been completed.
|
|
|
|
bool mDispatchedAtLeastOnce : 1;
|
2012-12-15 17:26:04 -08:00
|
|
|
// If mIsSynthesizedForTests is true, the event has been synthesized for
|
|
|
|
// automated tests or something hacky approach of an add-on.
|
|
|
|
bool mIsSynthesizedForTests : 1;
|
2012-12-15 17:26:04 -08:00
|
|
|
// If mExceptionHasBeenRisen is true, one of the event handlers has risen an
|
|
|
|
// exception.
|
|
|
|
bool mExceptionHasBeenRisen : 1;
|
2012-12-15 17:26:05 -08:00
|
|
|
// If mRetargetToNonNativeAnonymous is true and the target is in a non-native
|
|
|
|
// native anonymous subtree, the event target is set to originalTarget.
|
|
|
|
bool mRetargetToNonNativeAnonymous : 1;
|
|
|
|
// If mNoCrossProcessBoundaryForwarding is true, the event is not allowed to
|
|
|
|
// cross process boundary.
|
|
|
|
bool mNoCrossProcessBoundaryForwarding : 1;
|
2012-12-15 17:26:05 -08:00
|
|
|
// If mNoContentDispatch is true, the event is never dispatched to the
|
|
|
|
// event handlers which are added to the contents, onfoo attributes and
|
|
|
|
// properties. Note that this flag is ignored when
|
|
|
|
// nsEventChainPreVisitor::mForceContentDispatch is set true. For exapmle,
|
|
|
|
// window and document object sets it true. Therefore, web applications
|
|
|
|
// can handle the event if they add event listeners to the window or the
|
|
|
|
// document.
|
|
|
|
bool mNoContentDispatch : 1;
|
2012-12-15 17:26:05 -08:00
|
|
|
// If mOnlyChromeDispatch is true, the event is dispatched to only chrome.
|
|
|
|
bool mOnlyChromeDispatch : 1;
|
2012-12-15 17:26:03 -08:00
|
|
|
|
|
|
|
// If the event is being handled in target phase, returns true.
|
2012-12-28 06:13:18 -08:00
|
|
|
inline bool InTargetPhase() const
|
2012-12-15 17:26:03 -08:00
|
|
|
{
|
|
|
|
return (mInBubblingPhase && mInCapturePhase);
|
|
|
|
}
|
2012-12-15 17:26:03 -08:00
|
|
|
|
|
|
|
inline void Clear()
|
|
|
|
{
|
|
|
|
SetRawFlags(0);
|
|
|
|
}
|
2012-12-28 06:13:18 -08:00
|
|
|
// Get if either the instance's bit or the aOther's bit is true, the
|
|
|
|
// instance's bit becomes true. In other words, this works like:
|
|
|
|
// eventFlags |= aOther;
|
|
|
|
inline void Union(const BaseEventFlags& aOther)
|
2012-12-15 17:26:03 -08:00
|
|
|
{
|
2012-12-28 06:13:18 -08:00
|
|
|
RawFlags rawFlags = GetRawFlags() | aOther.GetRawFlags();
|
|
|
|
SetRawFlags(rawFlags);
|
2012-12-15 17:26:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-12-21 07:07:08 -08:00
|
|
|
typedef uint32_t RawFlags;
|
|
|
|
|
|
|
|
inline void SetRawFlags(RawFlags aRawFlags)
|
2012-12-15 17:26:03 -08:00
|
|
|
{
|
2012-12-28 06:13:18 -08:00
|
|
|
MOZ_STATIC_ASSERT(sizeof(BaseEventFlags) <= sizeof(RawFlags),
|
2012-12-21 07:07:08 -08:00
|
|
|
"mozilla::widget::EventFlags must not be bigger than the RawFlags");
|
2012-12-28 06:13:18 -08:00
|
|
|
memcpy(this, &aRawFlags, sizeof(BaseEventFlags));
|
2012-12-15 17:26:03 -08:00
|
|
|
}
|
2012-12-21 07:07:08 -08:00
|
|
|
inline RawFlags GetRawFlags() const
|
2012-12-15 17:26:03 -08:00
|
|
|
{
|
2012-12-21 07:07:08 -08:00
|
|
|
RawFlags result = 0;
|
2012-12-28 06:13:18 -08:00
|
|
|
memcpy(&result, this, sizeof(BaseEventFlags));
|
2012-12-15 17:26:03 -08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
2012-12-28 06:13:18 -08:00
|
|
|
|
|
|
|
struct EventFlags : public BaseEventFlags
|
|
|
|
{
|
|
|
|
EventFlags()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-15 17:26:03 -08:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* General event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsEvent
|
|
|
|
{
|
|
|
|
protected:
|
2012-11-19 22:05:56 -08:00
|
|
|
nsEvent(bool isTrusted, uint32_t msg, nsEventStructType structType)
|
2007-03-22 10:30:00 -07:00
|
|
|
: eventStructType(structType),
|
|
|
|
message(msg),
|
|
|
|
refPoint(0, 0),
|
2012-04-11 14:55:21 -07:00
|
|
|
lastRefPoint(0, 0),
|
2007-03-22 10:30:00 -07:00
|
|
|
time(0),
|
|
|
|
userType(0)
|
|
|
|
{
|
2008-04-17 15:38:35 -07:00
|
|
|
MOZ_COUNT_CTOR(nsEvent);
|
2012-12-28 06:13:18 -08:00
|
|
|
mFlags.Clear();
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mIsTrusted = isTrusted;
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = true;
|
|
|
|
mFlags.mBubbles = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
nsEvent()
|
|
|
|
{
|
2012-06-19 21:04:06 -07:00
|
|
|
MOZ_COUNT_CTOR(nsEvent);
|
2010-08-17 01:07:42 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsEvent(bool isTrusted, uint32_t msg)
|
2007-03-22 10:30:00 -07:00
|
|
|
: eventStructType(NS_EVENT),
|
|
|
|
message(msg),
|
|
|
|
refPoint(0, 0),
|
2012-04-11 14:55:21 -07:00
|
|
|
lastRefPoint(0, 0),
|
2007-03-22 10:30:00 -07:00
|
|
|
time(0),
|
|
|
|
userType(0)
|
|
|
|
{
|
2008-04-17 15:38:35 -07:00
|
|
|
MOZ_COUNT_CTOR(nsEvent);
|
2012-12-28 06:13:18 -08:00
|
|
|
mFlags.Clear();
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mIsTrusted = isTrusted;
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = true;
|
|
|
|
mFlags.mBubbles = true;
|
2008-04-17 15:38:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~nsEvent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-06-19 21:04:06 -07:00
|
|
|
nsEvent(const nsEvent& aOther)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsEvent);
|
|
|
|
*this = aOther;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// See event struct types
|
2012-11-19 22:05:56 -08:00
|
|
|
nsEventStructType eventStructType;
|
2007-03-22 10:30:00 -07:00
|
|
|
// See GUI MESSAGES,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t message;
|
2010-06-25 14:51:17 -07:00
|
|
|
// Relative to the widget of the event, or if there is no widget then it is
|
|
|
|
// in screen coordinates. Not modified by layout code.
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntPoint refPoint;
|
2012-04-11 14:55:21 -07:00
|
|
|
// The previous refPoint, if known, used to calculate mouse movement deltas.
|
|
|
|
nsIntPoint lastRefPoint;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Elapsed time, in milliseconds, from a platform-specific zero time
|
|
|
|
// to the time the message was created
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t time;
|
2012-12-28 06:13:18 -08:00
|
|
|
// See BaseEventFlags definition for the detail.
|
|
|
|
mozilla::widget::BaseEventFlags mFlags;
|
2012-12-15 17:26:03 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Additional type info for user defined events
|
|
|
|
nsCOMPtr<nsIAtom> userType;
|
|
|
|
// Event targets, needed by DOM Events
|
2011-06-23 19:18:00 -07:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> target;
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> currentTarget;
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> originalTarget;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* General graphic user interface event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsGUIEvent : public nsEvent
|
|
|
|
{
|
|
|
|
protected:
|
2012-11-19 22:05:56 -08:00
|
|
|
nsGUIEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
|
|
|
|
nsEventStructType structType)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsEvent(isTrusted, msg, structType),
|
2012-07-30 07:20:58 -07:00
|
|
|
widget(w), pluginEvent(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
nsGUIEvent()
|
2012-07-30 07:20:58 -07:00
|
|
|
: pluginEvent(nullptr)
|
2010-08-17 01:07:42 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsGUIEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsEvent(isTrusted, msg, NS_GUI_EVENT),
|
2012-07-30 07:20:58 -07:00
|
|
|
widget(w), pluginEvent(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Originator of the event
|
2008-10-27 13:16:23 -07:00
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
|
2009-11-10 13:55:38 -08:00
|
|
|
/// Event for NPAPI plugin
|
|
|
|
void* pluginEvent;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Script error event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsScriptErrorEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScriptErrorEvent(bool isTrusted, uint32_t msg)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
|
2012-07-30 07:20:58 -07:00
|
|
|
lineNr(0), errorMsg(nullptr), fileName(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t lineNr;
|
2007-03-22 10:30:00 -07:00
|
|
|
const PRUnichar* errorMsg;
|
|
|
|
const PRUnichar* fileName;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrollbar event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsScrollbarEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScrollbarEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
|
|
|
|
position(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// ranges between scrollbar 0 and (maxRange - thumbSize). See nsIScrollbar
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t position;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsScrollPortEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum orientType {
|
|
|
|
vertical = 0,
|
|
|
|
horizontal = 1,
|
|
|
|
both = 2
|
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScrollPortEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
|
|
|
|
orient(vertical)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
orientType orient;
|
|
|
|
};
|
|
|
|
|
2009-09-11 16:13:56 -07:00
|
|
|
class nsScrollAreaEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsScrollAreaEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2009-09-11 16:13:56 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_SCROLLAREA_EVENT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect mArea;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsInputEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsInputEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
|
2012-11-19 22:05:56 -08:00
|
|
|
nsEventStructType structType)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, structType),
|
2012-04-24 20:00:02 -07:00
|
|
|
modifiers(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-17 01:07:42 -07:00
|
|
|
nsInputEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsInputEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
|
2012-04-24 20:00:02 -07:00
|
|
|
modifiers(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-04-24 20:00:02 -07:00
|
|
|
// true indicates the shift key is down
|
|
|
|
bool IsShift() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_SHIFT) != 0);
|
|
|
|
}
|
|
|
|
// true indicates the control key is down
|
|
|
|
bool IsControl() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_CONTROL) != 0);
|
|
|
|
}
|
|
|
|
// true indicates the alt key is down
|
|
|
|
bool IsAlt() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_ALT) != 0);
|
|
|
|
}
|
|
|
|
// true indicates the meta key is down (or, on Mac, the Command key)
|
|
|
|
bool IsMeta() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_META) != 0);
|
|
|
|
}
|
2012-07-05 17:42:05 -07:00
|
|
|
// true indicates the win key is down on Windows. Or the Super or Hyper key
|
|
|
|
// is down on Linux.
|
|
|
|
bool IsOS() const
|
2012-04-24 20:00:02 -07:00
|
|
|
{
|
2012-07-05 17:42:05 -07:00
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_OS) != 0);
|
2012-04-24 20:00:02 -07:00
|
|
|
}
|
|
|
|
// true indicates the alt graph key is down
|
|
|
|
// NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah()
|
|
|
|
// return true.
|
|
|
|
bool IsAltGraph() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_ALTGRAPH) != 0);
|
|
|
|
}
|
|
|
|
// true indeicates the CapLock LED is turn on.
|
|
|
|
bool IsCapsLocked() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_CAPSLOCK) != 0);
|
|
|
|
}
|
|
|
|
// true indeicates the NumLock LED is turn on.
|
|
|
|
bool IsNumLocked() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_NUMLOCK) != 0);
|
|
|
|
}
|
|
|
|
// true indeicates the ScrollLock LED is turn on.
|
|
|
|
bool IsScrollLocked() const
|
|
|
|
{
|
2012-07-05 17:42:05 -07:00
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_SCROLLLOCK) != 0);
|
2012-04-24 20:00:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// true indeicates the Fn key is down, but this is not supported by native
|
|
|
|
// key event on any platform.
|
|
|
|
bool IsFn() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_FN) != 0);
|
|
|
|
}
|
|
|
|
// true indeicates the ScrollLock LED is turn on.
|
|
|
|
bool IsSymbolLocked() const
|
|
|
|
{
|
|
|
|
return ((modifiers & mozilla::widget::MODIFIER_SYMBOLLOCK) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitBasicModifiers(bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey)
|
|
|
|
{
|
|
|
|
modifiers = 0;
|
|
|
|
if (aCtrlKey) {
|
|
|
|
modifiers |= mozilla::widget::MODIFIER_CONTROL;
|
|
|
|
}
|
|
|
|
if (aAltKey) {
|
|
|
|
modifiers |= mozilla::widget::MODIFIER_ALT;
|
|
|
|
}
|
|
|
|
if (aShiftKey) {
|
|
|
|
modifiers |= mozilla::widget::MODIFIER_SHIFT;
|
|
|
|
}
|
|
|
|
if (aMetaKey) {
|
|
|
|
modifiers |= mozilla::widget::MODIFIER_META;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::widget::Modifiers modifiers;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mouse event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsMouseEvent_base : public nsInputEvent
|
|
|
|
{
|
2011-06-21 17:32:43 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2011-06-21 17:32:43 -07:00
|
|
|
|
|
|
|
nsMouseEvent_base()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-19 22:05:56 -08:00
|
|
|
nsMouseEvent_base(bool isTrusted, uint32_t msg, nsIWidget *w,
|
|
|
|
nsEventStructType type)
|
2012-04-24 20:00:01 -07:00
|
|
|
: nsInputEvent(isTrusted, msg, w, type), button(0), buttons(0),
|
2012-04-24 20:00:02 -07:00
|
|
|
pressure(0), inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/// The possible related target
|
|
|
|
nsCOMPtr<nsISupports> relatedTarget;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t button;
|
|
|
|
int16_t buttons;
|
2012-04-24 20:00:01 -07:00
|
|
|
|
2008-12-11 15:55:15 -08:00
|
|
|
// Finger or touch pressure of event
|
|
|
|
// ranges between 0.0 and 1.0
|
|
|
|
float pressure;
|
2010-04-06 05:59:24 -07:00
|
|
|
|
2011-08-26 00:43:56 -07:00
|
|
|
// Possible values at nsIDOMMouseEvent
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t inputSource;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsMouseEvent : public nsMouseEvent_base
|
|
|
|
{
|
2011-06-21 17:32:43 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
enum buttonType { eLeftButton = 0, eMiddleButton = 1, eRightButton = 2 };
|
2012-04-24 20:00:01 -07:00
|
|
|
enum buttonsFlag { eLeftButtonFlag = 0x01,
|
|
|
|
eRightButtonFlag = 0x02,
|
|
|
|
eMiddleButtonFlag = 0x04,
|
|
|
|
// typicall, "back" button being left side of 5-button
|
|
|
|
// mice, see "buttons" attribute document of DOM3 Events.
|
|
|
|
e4thButtonFlag = 0x08,
|
|
|
|
// typicall, "forward" button being right side of 5-button
|
|
|
|
// mice, see "buttons" attribute document of DOM3 Events.
|
|
|
|
e5thButtonFlag = 0x10 };
|
2007-03-22 10:30:00 -07:00
|
|
|
enum reasonType { eReal, eSynthesized };
|
|
|
|
enum contextType { eNormal, eContextMenuKey };
|
2008-03-12 15:44:45 -07:00
|
|
|
enum exitType { eChild, eTopLevel };
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-21 17:32:43 -07:00
|
|
|
nsMouseEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-08-27 05:07:27 -07:00
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
|
2012-11-19 22:05:56 -08:00
|
|
|
nsEventStructType structType, reasonType aReason)
|
2008-08-27 05:07:27 -07:00
|
|
|
: nsMouseEvent_base(isTrusted, msg, w, structType),
|
2011-10-17 07:59:28 -07:00
|
|
|
acceptActivation(false), ignoreRootScrollFrame(false),
|
2008-10-28 15:47:37 -07:00
|
|
|
reason(aReason), context(eNormal), exit(eChild), clickCount(0)
|
2008-08-27 05:07:27 -07:00
|
|
|
{
|
2011-09-18 00:45:14 -07:00
|
|
|
switch (msg) {
|
|
|
|
case NS_MOUSE_MOVE:
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = false;
|
2011-09-18 00:45:14 -07:00
|
|
|
break;
|
|
|
|
case NS_MOUSEENTER:
|
|
|
|
case NS_MOUSELEAVE:
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mBubbles = false;
|
|
|
|
mFlags.mCancelable = false;
|
2011-09-18 00:45:14 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2008-08-27 05:07:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMouseEvent(bool isTrusted, uint32_t msg, nsIWidget *w,
|
2007-03-22 10:30:00 -07:00
|
|
|
reasonType aReason, contextType aContext = eNormal)
|
|
|
|
: nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_EVENT),
|
2011-10-17 07:59:28 -07:00
|
|
|
acceptActivation(false), ignoreRootScrollFrame(false),
|
2008-10-28 15:47:37 -07:00
|
|
|
reason(aReason), context(aContext), exit(eChild), clickCount(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-18 00:45:14 -07:00
|
|
|
switch (msg) {
|
|
|
|
case NS_MOUSE_MOVE:
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = false;
|
2011-09-18 00:45:14 -07:00
|
|
|
break;
|
|
|
|
case NS_MOUSEENTER:
|
|
|
|
case NS_MOUSELEAVE:
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mBubbles = false;
|
|
|
|
mFlags.mCancelable = false;
|
2011-09-18 00:45:14 -07:00
|
|
|
break;
|
|
|
|
case NS_CONTEXTMENU:
|
|
|
|
button = (context == eNormal) ? eRightButton : eLeftButton;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2011-09-18 00:45:14 -07:00
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
~nsMouseEvent() {
|
2007-09-18 00:25:49 -07:00
|
|
|
NS_WARN_IF_FALSE(message != NS_CONTEXTMENU ||
|
|
|
|
button ==
|
|
|
|
((context == eNormal) ? eRightButton : eLeftButton),
|
2007-03-22 10:30:00 -07:00
|
|
|
"Wrong button set to NS_CONTEXTMENU event?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/// Special return code for MOUSE_ACTIVATE to signal
|
|
|
|
/// if the target accepts activation (1), or denies it (0)
|
2011-09-28 23:19:26 -07:00
|
|
|
bool acceptActivation;
|
2008-10-27 13:16:23 -07:00
|
|
|
// Whether the event should ignore scroll frame bounds
|
|
|
|
// during dispatch.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ignoreRootScrollFrame;
|
2008-10-27 13:16:23 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
reasonType reason : 4;
|
|
|
|
contextType context : 4;
|
2008-03-12 15:44:45 -07:00
|
|
|
exitType exit;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/// The number of mouse clicks
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t clickCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2008-08-27 05:07:27 -07:00
|
|
|
/**
|
|
|
|
* Drag event
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsDragEvent : public nsMouseEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsDragEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2009-02-17 07:51:12 -08:00
|
|
|
: nsMouseEvent(isTrusted, msg, w, NS_DRAG_EVENT, eReal),
|
2011-10-17 07:59:28 -07:00
|
|
|
userCancelled(false)
|
2008-08-27 05:07:27 -07:00
|
|
|
{
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable =
|
|
|
|
(msg != NS_DRAGDROP_EXIT_SYNTH &&
|
|
|
|
msg != NS_DRAGDROP_LEAVE_SYNTH &&
|
|
|
|
msg != NS_DRAGDROP_END);
|
2008-08-27 05:07:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool userCancelled;
|
2008-08-27 05:07:27 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Keyboard event
|
|
|
|
*/
|
|
|
|
|
2008-04-14 21:16:24 -07:00
|
|
|
struct nsAlternativeCharCode {
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAlternativeCharCode(uint32_t aUnshiftedCharCode,
|
|
|
|
uint32_t aShiftedCharCode) :
|
2008-04-14 21:16:24 -07:00
|
|
|
mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
|
|
|
|
{
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mUnshiftedCharCode;
|
|
|
|
uint32_t mShiftedCharCode;
|
2008-04-14 21:16:24 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsKeyEvent : public nsInputEvent
|
|
|
|
{
|
2011-06-21 17:32:43 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2011-06-21 17:32:43 -07:00
|
|
|
nsKeyEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsKeyEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
|
2012-05-03 01:35:01 -07:00
|
|
|
keyCode(0), charCode(0),
|
|
|
|
location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD), isChar(0)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// see NS_VK codes
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t keyCode;
|
2007-03-22 10:30:00 -07:00
|
|
|
/// OS translated Unicode char
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t charCode;
|
2012-05-03 01:35:01 -07:00
|
|
|
// One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t location;
|
2008-04-14 21:16:24 -07:00
|
|
|
// OS translated Unicode chars which are used for accesskey and accelkey
|
|
|
|
// handling. The handlers will try from first character to last character.
|
|
|
|
nsTArray<nsAlternativeCharCode> alternativeCharCodes;
|
2007-03-22 10:30:00 -07:00
|
|
|
// indicates whether the event signifies a printable character
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isChar;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IME Related Events
|
|
|
|
*/
|
2009-04-22 20:27:12 -07:00
|
|
|
|
|
|
|
struct nsTextRangeStyle
|
|
|
|
{
|
|
|
|
enum {
|
2011-03-31 05:26:49 -07:00
|
|
|
LINESTYLE_NONE = NS_STYLE_TEXT_DECORATION_STYLE_NONE,
|
|
|
|
LINESTYLE_SOLID = NS_STYLE_TEXT_DECORATION_STYLE_SOLID,
|
|
|
|
LINESTYLE_DOTTED = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED,
|
|
|
|
LINESTYLE_DASHED = NS_STYLE_TEXT_DECORATION_STYLE_DASHED,
|
|
|
|
LINESTYLE_DOUBLE = NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE,
|
|
|
|
LINESTYLE_WAVY = NS_STYLE_TEXT_DECORATION_STYLE_WAVY
|
2009-04-22 20:27:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
DEFINED_NONE = 0x00,
|
|
|
|
DEFINED_LINESTYLE = 0x01,
|
|
|
|
DEFINED_FOREGROUND_COLOR = 0x02,
|
|
|
|
DEFINED_BACKGROUND_COLOR = 0x04,
|
|
|
|
DEFINED_UNDERLINE_COLOR = 0x08
|
|
|
|
};
|
|
|
|
|
|
|
|
// Initialize all members, because nsTextRange instances may be compared by
|
|
|
|
// memcomp.
|
2009-05-14 17:45:15 -07:00
|
|
|
nsTextRangeStyle()
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
2009-05-14 17:45:15 -07:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
mDefinedStyles = DEFINED_NONE;
|
|
|
|
mLineStyle = LINESTYLE_NONE;
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsBoldLine = false;
|
2009-05-14 17:45:15 -07:00
|
|
|
mForegroundColor = mBackgroundColor = mUnderlineColor = NS_RGBA(0, 0, 0, 0);
|
2009-04-22 20:27:12 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDefined() const { return mDefinedStyles != DEFINED_NONE; }
|
2009-04-22 20:27:12 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsLineStyleDefined() const
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return (mDefinedStyles & DEFINED_LINESTYLE) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsForegroundColorDefined() const
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return (mDefinedStyles & DEFINED_FOREGROUND_COLOR) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsBackgroundColorDefined() const
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return (mDefinedStyles & DEFINED_BACKGROUND_COLOR) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsUnderlineColorDefined() const
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return (mDefinedStyles & DEFINED_UNDERLINE_COLOR) != 0;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsNoChangeStyle() const
|
2009-05-14 17:45:15 -07:00
|
|
|
{
|
|
|
|
return !IsForegroundColorDefined() && !IsBackgroundColorDefined() &&
|
|
|
|
IsLineStyleDefined() && mLineStyle == LINESTYLE_NONE;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Equals(const nsTextRangeStyle& aOther)
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
if (mDefinedStyles != aOther.mDefinedStyles)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-04-22 20:27:12 -07:00
|
|
|
if (IsLineStyleDefined() && (mLineStyle != aOther.mLineStyle ||
|
|
|
|
!mIsBoldLine != !aOther.mIsBoldLine))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-04-22 20:27:12 -07:00
|
|
|
if (IsForegroundColorDefined() &&
|
|
|
|
(mForegroundColor != aOther.mForegroundColor))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-04-22 20:27:12 -07:00
|
|
|
if (IsBackgroundColorDefined() &&
|
|
|
|
(mBackgroundColor != aOther.mBackgroundColor))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-04-22 20:27:12 -07:00
|
|
|
if (IsUnderlineColorDefined() &&
|
|
|
|
(mUnderlineColor != aOther.mUnderlineColor))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
|
|
|
return true;
|
2009-04-22 20:27:12 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator !=(const nsTextRangeStyle &aOther)
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return !Equals(aOther);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator ==(const nsTextRangeStyle &aOther)
|
2009-04-22 20:27:12 -07:00
|
|
|
{
|
|
|
|
return Equals(aOther);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mDefinedStyles;
|
|
|
|
uint8_t mLineStyle; // DEFINED_LINESTYLE
|
2009-04-22 20:27:12 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBoldLine; // DEFINED_LINESTYLE
|
2009-04-22 20:27:12 -07:00
|
|
|
|
|
|
|
nscolor mForegroundColor; // DEFINED_FOREGROUND_COLOR
|
|
|
|
nscolor mBackgroundColor; // DEFINED_BACKGROUND_COLOR
|
|
|
|
nscolor mUnderlineColor; // DEFINED_UNDERLINE_COLOR
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
struct nsTextRange
|
|
|
|
{
|
|
|
|
nsTextRange()
|
|
|
|
: mStartOffset(0), mEndOffset(0), mRangeType(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mStartOffset;
|
|
|
|
uint32_t mEndOffset;
|
|
|
|
uint32_t mRangeType;
|
2009-04-22 20:27:12 -07:00
|
|
|
|
|
|
|
nsTextRangeStyle mRangeStyle;
|
2013-03-12 20:01:29 -07:00
|
|
|
|
|
|
|
uint32_t Length() const { return mEndOffset - mStartOffset; }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef nsTextRange* nsTextRangeArray;
|
|
|
|
|
|
|
|
class nsTextEvent : public nsInputEvent
|
|
|
|
{
|
2010-08-17 01:07:42 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
2011-08-29 09:26:24 -07:00
|
|
|
friend class mozilla::plugins::PPluginInstanceChild;
|
2010-08-17 01:07:42 -07:00
|
|
|
|
|
|
|
nsTextEvent()
|
|
|
|
{
|
|
|
|
}
|
2010-10-01 07:17:37 -07:00
|
|
|
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t seqno;
|
2010-08-17 01:07:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTextEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
|
2012-07-30 07:20:58 -07:00
|
|
|
rangeCount(0), rangeArray(nullptr), isChar(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-02-10 12:56:51 -08:00
|
|
|
nsString theText;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t rangeCount;
|
2008-12-17 00:05:44 -08:00
|
|
|
// Note that the range array may not specify a caret position; in that
|
|
|
|
// case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
|
|
|
|
// array.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTextRangeArray rangeArray;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isChar;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2011-09-22 02:17:40 -07:00
|
|
|
class nsCompositionEvent : public nsGUIEvent
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-17 01:07:42 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
nsCompositionEvent()
|
|
|
|
{
|
|
|
|
}
|
2010-10-01 07:17:37 -07:00
|
|
|
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t seqno;
|
2010-08-17 01:07:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsCompositionEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2011-09-22 02:17:40 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-22 02:17:40 -07:00
|
|
|
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
|
|
|
// However, it doesn't make sense for us, we cannot cancel composition
|
|
|
|
// when we send compositionstart event.
|
2012-12-15 17:26:03 -08:00
|
|
|
mFlags.mCancelable = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-09-22 02:17:40 -07:00
|
|
|
|
|
|
|
nsString data;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-08-11 18:42:37 -07:00
|
|
|
/**
|
|
|
|
* nsMouseScrollEvent is used for legacy DOM mouse scroll events, i.e.,
|
|
|
|
* DOMMouseScroll and MozMousePixelScroll event. These events are NOT hanbled
|
|
|
|
* by ESM even if widget dispatches them. Use new widget::WheelEvent instead.
|
2008-09-17 04:27:19 -07:00
|
|
|
*/
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsMouseScrollEvent : public nsMouseEvent_base
|
|
|
|
{
|
2011-06-21 17:32:43 -07:00
|
|
|
private:
|
|
|
|
nsMouseScrollEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsMouseScrollEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
|
2012-08-11 18:42:37 -07:00
|
|
|
delta(0), isHorizontal(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t delta;
|
2012-08-11 18:42:37 -07:00
|
|
|
bool isHorizontal;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-08-11 18:42:34 -07:00
|
|
|
/**
|
|
|
|
* WheelEvent is used only for DOM Level 3 WheelEvent (dom::DOMWheelEvent).
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
class WheelEvent : public nsMouseEvent_base
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
WheelEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
WheelEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
|
2012-08-11 18:42:34 -07:00
|
|
|
nsMouseEvent_base(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
|
|
|
|
deltaX(0.0), deltaY(0.0), deltaZ(0.0),
|
2012-08-11 18:42:35 -07:00
|
|
|
deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
|
2012-08-11 18:42:36 -07:00
|
|
|
customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
|
2012-08-11 18:42:36 -07:00
|
|
|
lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
|
2012-08-11 18:42:35 -07:00
|
|
|
overflowDeltaX(0.0), overflowDeltaY(0.0)
|
2012-08-11 18:42:34 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-29 18:05:16 -07:00
|
|
|
// NOTE: deltaX, deltaY and deltaZ may be customized by
|
|
|
|
// mousewheel.*.delta_multiplier_* prefs which are applied by
|
|
|
|
// nsEventStateManager. So, after widget dispatches this event,
|
|
|
|
// these delta values may have different values than before.
|
2012-08-11 18:42:34 -07:00
|
|
|
double deltaX;
|
|
|
|
double deltaY;
|
|
|
|
double deltaZ;
|
|
|
|
|
|
|
|
// Should be one of nsIDOMWheelEvent::DOM_DELTA_*
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t deltaMode;
|
2012-08-11 18:42:35 -07:00
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
// Following members are for internal use only, not for DOM event.
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
// If the delta values are computed from prefs, this value is true.
|
|
|
|
// Otherwise, i.e., they are computed from native events, false.
|
|
|
|
bool customizedByUserPrefs;
|
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
// true if the event is caused by momentum.
|
|
|
|
bool isMomentum;
|
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
// If device event handlers don't know when they should set lineOrPageDeltaX
|
|
|
|
// and lineOrPageDeltaY, this is true. Otherwise, false.
|
|
|
|
// If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events
|
|
|
|
// when accumulated pixel delta values reach a line height.
|
|
|
|
bool isPixelOnlyDevice;
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
// If widget sets lineOrPageDelta, nsEventStateManager will dispatch
|
|
|
|
// NS_MOUSE_SCROLL event for compatibility. Note that the delta value means
|
|
|
|
// pages if the deltaMode is DOM_DELTA_PAGE, otherwise, lines.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t lineOrPageDeltaX;
|
|
|
|
int32_t lineOrPageDeltaY;
|
2012-08-11 18:42:35 -07:00
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
// When the default action for an wheel event is moving history or zooming,
|
|
|
|
// need to chose a delta value for doing it.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetPreferredIntDelta()
|
2012-08-11 18:42:36 -07:00
|
|
|
{
|
|
|
|
if (!lineOrPageDeltaX && !lineOrPageDeltaY) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (lineOrPageDeltaY && !lineOrPageDeltaX) {
|
|
|
|
return lineOrPageDeltaY;
|
|
|
|
}
|
|
|
|
if (lineOrPageDeltaX && !lineOrPageDeltaY) {
|
|
|
|
return lineOrPageDeltaX;
|
|
|
|
}
|
|
|
|
if ((lineOrPageDeltaX < 0 && lineOrPageDeltaY > 0) ||
|
|
|
|
(lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
|
|
|
|
return 0; // We cannot guess the answer in this case.
|
|
|
|
}
|
2013-03-05 15:43:53 -08:00
|
|
|
return (Abs(lineOrPageDeltaX) > Abs(lineOrPageDeltaY)) ?
|
2012-08-11 18:42:36 -07:00
|
|
|
lineOrPageDeltaX : lineOrPageDeltaY;
|
|
|
|
}
|
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
// Scroll type
|
|
|
|
// The default value is SCROLL_DEFAULT, which means nsEventStateManager will
|
|
|
|
// select preferred scroll type automatically.
|
|
|
|
enum ScrollType {
|
|
|
|
SCROLL_DEFAULT,
|
|
|
|
SCROLL_SYNCHRONOUSLY,
|
|
|
|
SCROLL_ASYNCHRONOUSELY,
|
|
|
|
SCROLL_SMOOTHLY
|
|
|
|
};
|
|
|
|
ScrollType scrollType;
|
|
|
|
|
2012-08-29 18:05:16 -07:00
|
|
|
// overflowed delta values for scroll, these values are set by
|
|
|
|
// nsEventStateManger. If the default action of the wheel event isn't scroll,
|
|
|
|
// these values always zero. Otherwise, remaning delta values which are
|
|
|
|
// not used by scroll are set.
|
|
|
|
// NOTE: deltaX, deltaY and deltaZ may be modified by nsEventStateManager.
|
|
|
|
// However, overflowDeltaX and overflowDeltaY indicate unused original
|
|
|
|
// delta values which are not applied the delta_multiplier prefs.
|
|
|
|
// So, if widget wanted to know the actual direction to be scrolled,
|
|
|
|
// it would need to check the deltaX and deltaY.
|
2012-08-11 18:42:35 -07:00
|
|
|
double overflowDeltaX;
|
|
|
|
double overflowDeltaY;
|
2012-08-11 18:42:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-08-13 13:54:09 -07:00
|
|
|
/*
|
|
|
|
* Gesture Notify Event:
|
|
|
|
*
|
|
|
|
* This event is the first event generated when the user touches
|
|
|
|
* the screen with a finger, and it's meant to decide what kind
|
|
|
|
* of action we'll use for that touch interaction.
|
|
|
|
*
|
|
|
|
* The event is dispatched to the layout and based on what is underneath
|
|
|
|
* the initial contact point it's then decided if we should pan
|
|
|
|
* (finger scrolling) or drag the target element.
|
|
|
|
*/
|
|
|
|
class nsGestureNotifyEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum ePanDirection {
|
|
|
|
ePanNone,
|
|
|
|
ePanVertical,
|
|
|
|
ePanHorizontal,
|
|
|
|
ePanBoth
|
|
|
|
};
|
|
|
|
|
|
|
|
ePanDirection panDirection;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool displayPanFeedback;
|
2009-08-13 13:54:09 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsGestureNotifyEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget):
|
2009-08-13 13:54:09 -07:00
|
|
|
nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_GESTURENOTIFY_EVENT),
|
|
|
|
panDirection(ePanNone),
|
2011-10-17 07:59:28 -07:00
|
|
|
displayPanFeedback(false)
|
2009-08-13 13:54:09 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-02-19 23:40:04 -08:00
|
|
|
class nsQueryContentEvent : public nsGUIEvent
|
|
|
|
{
|
2010-08-17 01:07:42 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
nsQueryContentEvent()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mReply.mContentsRoot = nullptr;
|
|
|
|
mReply.mFocusedWidget = nullptr;
|
2010-08-17 01:07:42 -07:00
|
|
|
}
|
|
|
|
|
2008-02-19 23:40:04 -08:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsQueryContentEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget) :
|
2008-02-19 23:40:04 -08:00
|
|
|
nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
|
2011-10-17 07:59:28 -07:00
|
|
|
mSucceeded(false), mWasAsync(false)
|
2008-02-19 23:40:04 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void InitForQueryTextContent(uint32_t aOffset, uint32_t aLength)
|
2008-02-19 23:40:04 -08:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
|
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void InitForQueryCaretRect(uint32_t aOffset)
|
2008-02-19 23:40:04 -08:00
|
|
|
{
|
2009-02-10 12:56:51 -08:00
|
|
|
NS_ASSERTION(message == NS_QUERY_CARET_RECT,
|
2008-02-19 23:40:04 -08:00
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void InitForQueryTextRect(uint32_t aOffset, uint32_t aLength)
|
2008-02-19 23:40:04 -08:00
|
|
|
{
|
2009-02-10 12:56:51 -08:00
|
|
|
NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
|
2008-02-19 23:40:04 -08:00
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
2009-02-10 12:56:51 -08:00
|
|
|
mInput.mLength = aLength;
|
2008-02-19 23:40:04 -08:00
|
|
|
}
|
|
|
|
|
2011-03-01 13:15:23 -08:00
|
|
|
void InitForQueryDOMWidgetHittest(nsIntPoint& aPoint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_DOM_WIDGET_HITTEST,
|
|
|
|
"wrong initializer is called");
|
|
|
|
refPoint = aPoint;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetSelectionStart(void) const
|
2010-08-17 01:07:45 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetSelectionEnd(void) const
|
2010-08-17 01:07:45 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSucceeded;
|
|
|
|
bool mWasAsync;
|
2008-02-19 23:40:04 -08:00
|
|
|
struct {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mOffset;
|
|
|
|
uint32_t mLength;
|
2008-02-19 23:40:04 -08:00
|
|
|
} mInput;
|
|
|
|
struct {
|
|
|
|
void* mContentsRoot;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mOffset;
|
2008-02-19 23:40:04 -08:00
|
|
|
nsString mString;
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect mRect; // Finally, the coordinates is system coordinates.
|
2008-08-11 01:27:59 -07:00
|
|
|
// The return widget has the caret. This is set at all query events.
|
|
|
|
nsIWidget* mFocusedWidget;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mReversed; // true if selection is reversed (end < start)
|
|
|
|
bool mHasSelection; // true if the selection exists
|
|
|
|
bool mWidgetIsHit; // true if DOM element under mouse belongs to widget
|
2009-03-17 19:04:01 -07:00
|
|
|
// used by NS_QUERY_SELECTION_AS_TRANSFERABLE
|
|
|
|
nsCOMPtr<nsITransferable> mTransferable;
|
2008-02-19 23:40:04 -08:00
|
|
|
} mReply;
|
2009-05-14 17:46:24 -07:00
|
|
|
|
|
|
|
enum {
|
2012-09-27 23:57:33 -07:00
|
|
|
NOT_FOUND = UINT32_MAX
|
2009-05-14 17:46:24 -07:00
|
|
|
};
|
2011-07-14 15:12:20 -07:00
|
|
|
|
|
|
|
// values of mComputedScrollAction
|
|
|
|
enum {
|
|
|
|
SCROLL_ACTION_NONE,
|
|
|
|
SCROLL_ACTION_LINE,
|
|
|
|
SCROLL_ACTION_PAGE
|
|
|
|
};
|
2008-02-19 23:40:04 -08:00
|
|
|
};
|
|
|
|
|
2009-10-01 10:53:10 -07:00
|
|
|
class nsFocusEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsFocusEvent(bool isTrusted, uint32_t msg)
|
2009-10-01 10:53:10 -07:00
|
|
|
: nsEvent(isTrusted, msg, NS_FOCUS_EVENT),
|
2011-10-17 07:59:28 -07:00
|
|
|
fromRaise(false),
|
|
|
|
isRefocus(false)
|
2009-10-01 10:53:10 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool fromRaise;
|
|
|
|
bool isRefocus;
|
2009-10-01 10:53:10 -07:00
|
|
|
};
|
|
|
|
|
2009-02-10 12:56:51 -08:00
|
|
|
class nsSelectionEvent : public nsGUIEvent
|
|
|
|
{
|
2010-08-17 01:07:42 -07:00
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
nsSelectionEvent()
|
|
|
|
{
|
|
|
|
}
|
2010-10-01 07:17:37 -07:00
|
|
|
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t seqno;
|
2010-08-17 01:07:42 -07:00
|
|
|
|
2009-02-10 12:56:51 -08:00
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSelectionEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget) :
|
2009-02-10 12:56:51 -08:00
|
|
|
nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_SELECTION_EVENT),
|
2011-10-17 07:59:28 -07:00
|
|
|
mExpandToClusterBoundary(true), mSucceeded(false)
|
2009-02-10 12:56:51 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mOffset; // start offset of selection
|
|
|
|
uint32_t mLength; // length of selection
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mReversed; // selection "anchor" should be in front
|
|
|
|
bool mExpandToClusterBoundary; // cluster-based or character-based
|
|
|
|
bool mSucceeded;
|
2009-02-10 12:56:51 -08:00
|
|
|
};
|
|
|
|
|
2009-08-07 08:11:17 -07:00
|
|
|
class nsContentCommandEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsContentCommandEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aOnlyEnabledCheck = false) :
|
2009-08-07 08:11:17 -07:00
|
|
|
nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
|
2011-09-28 23:19:26 -07:00
|
|
|
mOnlyEnabledCheck(bool(aOnlyEnabledCheck)),
|
2011-10-17 07:59:28 -07:00
|
|
|
mSucceeded(false), mIsEnabled(false)
|
2009-08-07 08:11:17 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-03-10 21:25:29 -08:00
|
|
|
// NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
|
2010-01-10 17:45:45 -08:00
|
|
|
nsCOMPtr<nsITransferable> mTransferable; // [in]
|
2010-03-10 21:25:29 -08:00
|
|
|
|
|
|
|
// NS_CONTENT_COMMAND_SCROLL
|
|
|
|
// for mScroll.mUnit
|
|
|
|
enum {
|
|
|
|
eCmdScrollUnit_Line,
|
|
|
|
eCmdScrollUnit_Page,
|
|
|
|
eCmdScrollUnit_Whole
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScrollInfo {
|
|
|
|
ScrollInfo() :
|
2011-10-17 07:59:28 -07:00
|
|
|
mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
|
2010-03-10 21:25:29 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mAmount; // [in]
|
|
|
|
uint8_t mUnit; // [in]
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsHorizontal; // [in]
|
2010-03-10 21:25:29 -08:00
|
|
|
} mScroll;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mOnlyEnabledCheck; // [in]
|
2009-08-07 08:11:17 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mSucceeded; // [out]
|
|
|
|
bool mIsEnabled; // [out]
|
2009-08-07 08:11:17 -07:00
|
|
|
};
|
|
|
|
|
2011-12-16 16:24:11 -08:00
|
|
|
class nsTouchEvent : public nsInputEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-07-15 19:58:43 -07:00
|
|
|
nsTouchEvent()
|
|
|
|
{
|
|
|
|
}
|
2012-04-04 10:08:53 -07:00
|
|
|
nsTouchEvent(bool isTrusted, nsTouchEvent *aEvent)
|
|
|
|
: nsInputEvent(isTrusted,
|
|
|
|
aEvent->message,
|
|
|
|
aEvent->widget,
|
|
|
|
NS_TOUCH_EVENT)
|
2011-12-16 16:24:11 -08:00
|
|
|
{
|
2012-04-24 20:00:02 -07:00
|
|
|
modifiers = aEvent->modifiers;
|
2012-03-19 14:33:42 -07:00
|
|
|
time = aEvent->time;
|
2011-12-16 16:24:11 -08:00
|
|
|
touches.AppendElements(aEvent->touches);
|
|
|
|
MOZ_COUNT_CTOR(nsTouchEvent);
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTouchEvent(bool isTrusted, uint32_t msg, nsIWidget* w)
|
2011-12-16 16:24:11 -08:00
|
|
|
: nsInputEvent(isTrusted, msg, w, NS_TOUCH_EVENT)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsTouchEvent);
|
|
|
|
}
|
|
|
|
~nsTouchEvent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsTouchEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsCOMPtr<nsIDOMTouch> > touches;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Form event
|
|
|
|
*
|
|
|
|
* We hold the originating form control for form submit and reset events.
|
|
|
|
* originator is a weak pointer (does not hold a strong reference).
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsFormEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsFormEvent(bool isTrusted, uint32_t msg)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsEvent(isTrusted, msg, NS_FORM_EVENT),
|
2012-07-30 07:20:58 -07:00
|
|
|
originator(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent *originator;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command event
|
|
|
|
*
|
|
|
|
* Custom commands for example from the operating system.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsCommandEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
nsCommandEvent(bool isTrusted, nsIAtom* aEventType,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aCommand, nsIWidget* w)
|
|
|
|
: nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
|
|
|
|
{
|
|
|
|
userType = aEventType;
|
|
|
|
command = aCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom> command;
|
|
|
|
};
|
|
|
|
|
2013-03-11 08:49:48 -07:00
|
|
|
/**
|
|
|
|
* Clipboard event
|
|
|
|
*/
|
|
|
|
class nsClipboardEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsClipboardEvent(bool isTrusted, uint32_t msg)
|
|
|
|
: nsEvent(isTrusted, msg, NS_CLIPBOARD_EVENT)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> clipboardData;
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* DOM UIEvent
|
|
|
|
*/
|
|
|
|
class nsUIEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsUIEvent(bool isTrusted, uint32_t msg, int32_t d)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsEvent(isTrusted, msg, NS_UI_EVENT),
|
|
|
|
detail(d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t detail;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2008-10-23 13:15:20 -07:00
|
|
|
/**
|
|
|
|
* Simple gesture event
|
|
|
|
*/
|
2009-02-17 03:49:03 -08:00
|
|
|
class nsSimpleGestureEvent : public nsMouseEvent_base
|
2008-10-23 13:15:20 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsSimpleGestureEvent(bool isTrusted, uint32_t msg, nsIWidget* w,
|
|
|
|
uint32_t directionArg, double deltaArg)
|
2009-02-17 03:49:03 -08:00
|
|
|
: nsMouseEvent_base(isTrusted, msg, w, NS_SIMPLE_GESTURE_EVENT),
|
2013-02-08 16:52:12 -08:00
|
|
|
direction(directionArg), delta(deltaArg), clickCount(0)
|
2008-10-23 13:15:20 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-11 10:42:23 -07:00
|
|
|
nsSimpleGestureEvent(const nsSimpleGestureEvent& other)
|
2012-12-15 17:26:03 -08:00
|
|
|
: nsMouseEvent_base(other.mFlags.mIsTrusted,
|
2011-08-11 10:42:23 -07:00
|
|
|
other.message, other.widget, NS_SIMPLE_GESTURE_EVENT),
|
2013-02-08 16:52:12 -08:00
|
|
|
direction(other.direction), delta(other.delta), clickCount(0)
|
2011-08-11 10:42:23 -07:00
|
|
|
{
|
|
|
|
}
|
2013-02-08 16:52:12 -08:00
|
|
|
|
|
|
|
uint32_t direction; // See nsIDOMSimpleGestureEvent for values
|
|
|
|
double delta; // Delta for magnify and rotate events
|
|
|
|
uint32_t clickCount; // The number of taps for tap events
|
2008-10-23 13:15:20 -07:00
|
|
|
};
|
|
|
|
|
2009-12-23 11:10:31 -08:00
|
|
|
class nsTransitionEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTransitionEvent(bool isTrusted, uint32_t msg,
|
2009-12-23 11:10:31 -08:00
|
|
|
const nsString &propertyNameArg, float elapsedTimeArg)
|
|
|
|
: nsEvent(isTrusted, msg, NS_TRANSITION_EVENT),
|
|
|
|
propertyName(propertyNameArg), elapsedTime(elapsedTimeArg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString propertyName;
|
|
|
|
float elapsedTime;
|
|
|
|
};
|
|
|
|
|
2011-04-11 23:18:44 -07:00
|
|
|
class nsAnimationEvent : public nsEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAnimationEvent(bool isTrusted, uint32_t msg,
|
2011-04-11 23:18:44 -07:00
|
|
|
const nsString &animationNameArg, float elapsedTimeArg)
|
|
|
|
: nsEvent(isTrusted, msg, NS_ANIMATION_EVENT),
|
|
|
|
animationName(animationNameArg), elapsedTime(elapsedTimeArg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString animationName;
|
|
|
|
float elapsedTime;
|
|
|
|
};
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2011-05-10 21:52:44 -07:00
|
|
|
/**
|
|
|
|
* Native event pluginEvent for plugins.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsPluginEvent : public nsGUIEvent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPluginEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
|
2011-05-10 21:52:44 -07:00
|
|
|
: nsGUIEvent(isTrusted, msg, w, NS_PLUGIN_EVENT),
|
2011-10-17 07:59:28 -07:00
|
|
|
retargetToFocusedDocument(false)
|
2011-05-10 21:52:44 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// If TRUE, this event needs to be retargeted to focused document.
|
|
|
|
// Otherwise, never retargeted.
|
|
|
|
// Defaults to false.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool retargetToFocusedDocument;
|
2011-05-10 21:52:44 -07:00
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Event status for D&D Event
|
|
|
|
*/
|
|
|
|
enum nsDragDropEventStatus {
|
|
|
|
/// The event is a enter
|
|
|
|
nsDragDropEventStatus_eDragEntered,
|
|
|
|
/// The event is exit
|
|
|
|
nsDragDropEventStatus_eDragExited,
|
|
|
|
/// The event is drop
|
|
|
|
nsDragDropEventStatus_eDrop
|
|
|
|
};
|
|
|
|
|
2012-07-18 18:28:16 -07:00
|
|
|
#define NS_IS_INPUT_EVENT(evnt) \
|
|
|
|
(((evnt)->eventStructType == NS_INPUT_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_MOUSE_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_KEY_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_TEXT_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_TOUCH_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_DRAG_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_MOUSE_SCROLL_EVENT) || \
|
|
|
|
((evnt)->eventStructType == NS_SIMPLE_GESTURE_EVENT))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_IS_MOUSE_EVENT(evnt) \
|
|
|
|
(((evnt)->message == NS_MOUSE_BUTTON_DOWN) || \
|
|
|
|
((evnt)->message == NS_MOUSE_BUTTON_UP) || \
|
|
|
|
((evnt)->message == NS_MOUSE_CLICK) || \
|
|
|
|
((evnt)->message == NS_MOUSE_DOUBLECLICK) || \
|
|
|
|
((evnt)->message == NS_MOUSE_ENTER) || \
|
|
|
|
((evnt)->message == NS_MOUSE_EXIT) || \
|
|
|
|
((evnt)->message == NS_MOUSE_ACTIVATE) || \
|
|
|
|
((evnt)->message == NS_MOUSE_ENTER_SYNTH) || \
|
|
|
|
((evnt)->message == NS_MOUSE_EXIT_SYNTH) || \
|
2010-06-27 23:04:05 -07:00
|
|
|
((evnt)->message == NS_MOUSE_MOZHITTEST) || \
|
2007-03-22 10:30:00 -07:00
|
|
|
((evnt)->message == NS_MOUSE_MOVE))
|
|
|
|
|
2010-05-12 19:33:16 -07:00
|
|
|
#define NS_IS_MOUSE_EVENT_STRUCT(evnt) \
|
|
|
|
((evnt)->eventStructType == NS_MOUSE_EVENT || \
|
|
|
|
(evnt)->eventStructType == NS_DRAG_EVENT)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_IS_MOUSE_LEFT_CLICK(evnt) \
|
|
|
|
((evnt)->eventStructType == NS_MOUSE_EVENT && \
|
|
|
|
(evnt)->message == NS_MOUSE_CLICK && \
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsMouseEvent*>((evnt))->button == nsMouseEvent::eLeftButton)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_IS_CONTEXT_MENU_KEY(evnt) \
|
|
|
|
((evnt)->eventStructType == NS_MOUSE_EVENT && \
|
|
|
|
(evnt)->message == NS_CONTEXTMENU && \
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsMouseEvent*>((evnt))->context == nsMouseEvent::eContextMenuKey)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_IS_DRAG_EVENT(evnt) \
|
|
|
|
(((evnt)->message == NS_DRAGDROP_ENTER) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_OVER) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_EXIT) || \
|
2008-08-27 05:07:27 -07:00
|
|
|
((evnt)->message == NS_DRAGDROP_DRAGDROP) || \
|
2008-08-25 08:08:28 -07:00
|
|
|
((evnt)->message == NS_DRAGDROP_GESTURE) || \
|
2008-08-27 05:07:27 -07:00
|
|
|
((evnt)->message == NS_DRAGDROP_DRAG) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_END) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_START) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_DROP) || \
|
|
|
|
((evnt)->message == NS_DRAGDROP_LEAVE_SYNTH))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_IS_KEY_EVENT(evnt) \
|
|
|
|
(((evnt)->message == NS_KEY_DOWN) || \
|
|
|
|
((evnt)->message == NS_KEY_PRESS) || \
|
|
|
|
((evnt)->message == NS_KEY_UP))
|
|
|
|
|
|
|
|
#define NS_IS_IME_EVENT(evnt) \
|
|
|
|
(((evnt)->message == NS_TEXT_TEXT) || \
|
|
|
|
((evnt)->message == NS_COMPOSITION_START) || \
|
2011-09-22 02:17:40 -07:00
|
|
|
((evnt)->message == NS_COMPOSITION_END) || \
|
|
|
|
((evnt)->message == NS_COMPOSITION_UPDATE))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-01 10:53:10 -07:00
|
|
|
#define NS_IS_ACTIVATION_EVENT(evnt) \
|
2012-08-15 11:52:42 -07:00
|
|
|
(((evnt)->message == NS_PLUGIN_ACTIVATE) || \
|
2010-11-15 13:12:50 -08:00
|
|
|
((evnt)->message == NS_PLUGIN_FOCUS))
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-19 23:40:04 -08:00
|
|
|
#define NS_IS_QUERY_CONTENT_EVENT(evnt) \
|
2011-05-16 17:23:23 -07:00
|
|
|
((evnt)->eventStructType == NS_QUERY_CONTENT_EVENT)
|
2009-02-10 12:56:51 -08:00
|
|
|
|
|
|
|
#define NS_IS_SELECTION_EVENT(evnt) \
|
|
|
|
(((evnt)->message == NS_SELECTION_SET))
|
2008-02-19 23:40:04 -08:00
|
|
|
|
2009-08-07 08:11:17 -07:00
|
|
|
#define NS_IS_CONTENT_COMMAND_EVENT(evnt) \
|
2010-06-25 14:51:17 -07:00
|
|
|
((evnt)->eventStructType == NS_CONTENT_COMMAND_EVENT)
|
2009-08-07 08:11:17 -07:00
|
|
|
|
2008-12-14 19:54:54 -08:00
|
|
|
#define NS_IS_PLUGIN_EVENT(evnt) \
|
2011-05-10 21:52:44 -07:00
|
|
|
(((evnt)->message == NS_PLUGIN_INPUT_EVENT) || \
|
|
|
|
((evnt)->message == NS_PLUGIN_FOCUS_EVENT))
|
|
|
|
|
|
|
|
#define NS_IS_RETARGETED_PLUGIN_EVENT(evnt) \
|
|
|
|
(NS_IS_PLUGIN_EVENT(evnt) && \
|
|
|
|
(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
|
2008-12-14 19:54:54 -08:00
|
|
|
|
2010-04-20 23:21:46 -07:00
|
|
|
#define NS_IS_NON_RETARGETED_PLUGIN_EVENT(evnt) \
|
2011-05-10 21:52:44 -07:00
|
|
|
(NS_IS_PLUGIN_EVENT(evnt) && \
|
|
|
|
!(static_cast<nsPluginEvent*>(evnt)->retargetToFocusedDocument))
|
2010-04-20 23:21:46 -07:00
|
|
|
|
2009-12-17 10:42:02 -08:00
|
|
|
// Be aware the query content events and the selection events are a part of IME
|
|
|
|
// processing. So, you shouldn't use NS_IS_IME_EVENT macro directly in most
|
|
|
|
// cases, you should use NS_IS_IME_RELATED_EVENT instead.
|
|
|
|
#define NS_IS_IME_RELATED_EVENT(evnt) \
|
|
|
|
(NS_IS_IME_EVENT(evnt) || \
|
2012-08-11 18:42:37 -07:00
|
|
|
NS_IS_QUERY_CONTENT_EVENT(evnt) || \
|
2009-12-17 10:42:02 -08:00
|
|
|
NS_IS_SELECTION_EVENT(evnt))
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Virtual key bindings for keyboard events.
|
|
|
|
* These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.
|
|
|
|
* Really, it would be better if we phased out the NS_VK symbols altogether
|
|
|
|
* in favor of the DOM ones, but at least this way they'll be in sync.
|
|
|
|
*/
|
|
|
|
|
2012-05-17 00:04:16 -07:00
|
|
|
enum {
|
|
|
|
#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode
|
|
|
|
#include "nsVKList.h"
|
|
|
|
#undef NS_DEFINE_VK
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-12-17 00:05:44 -08:00
|
|
|
// IME Constants -- keep in synch with nsIPrivateTextRange.h
|
|
|
|
#define NS_TEXTRANGE_CARETPOSITION 0x01
|
|
|
|
#define NS_TEXTRANGE_RAWINPUT 0x02
|
|
|
|
#define NS_TEXTRANGE_SELECTEDRAWTEXT 0x03
|
|
|
|
#define NS_TEXTRANGE_CONVERTEDTEXT 0x04
|
|
|
|
#define NS_TEXTRANGE_SELECTEDCONVERTEDTEXT 0x05
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-17 10:42:02 -08:00
|
|
|
/**
|
|
|
|
* Whether the event should be handled by the frame of the mouse cursor
|
|
|
|
* position or not. When it should be handled there (e.g., the mouse events),
|
|
|
|
* this returns TRUE.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
inline bool NS_IsEventUsingCoordinates(nsEvent* aEvent)
|
2009-08-07 08:11:17 -07:00
|
|
|
{
|
2009-12-17 10:42:02 -08:00
|
|
|
return !NS_IS_KEY_EVENT(aEvent) && !NS_IS_IME_RELATED_EVENT(aEvent) &&
|
2009-10-01 10:53:10 -07:00
|
|
|
!NS_IS_CONTEXT_MENU_KEY(aEvent) && !NS_IS_ACTIVATION_EVENT(aEvent) &&
|
2011-05-10 21:52:44 -07:00
|
|
|
!NS_IS_PLUGIN_EVENT(aEvent) &&
|
2012-10-16 12:41:21 -07:00
|
|
|
!NS_IS_CONTENT_COMMAND_EVENT(aEvent) &&
|
|
|
|
aEvent->message != NS_PLUGIN_RESOLUTION_CHANGED;
|
2009-08-07 08:11:17 -07:00
|
|
|
}
|
|
|
|
|
2009-12-17 10:42:02 -08:00
|
|
|
/**
|
|
|
|
* Whether the event should be handled by the focused DOM window in the
|
|
|
|
* same top level window's or not. E.g., key events, IME related events
|
|
|
|
* (including the query content events, they are used in IME transaction)
|
|
|
|
* should be handled by the (last) focused window rather than the dispatched
|
|
|
|
* window.
|
|
|
|
*
|
|
|
|
* NOTE: Even if this returns TRUE, the event isn't going to be handled by the
|
|
|
|
* application level active DOM window which is on another top level window.
|
|
|
|
* So, when the event is fired on a deactive window, the event is going to be
|
|
|
|
* handled by the last focused DOM window in the last focused window.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
inline bool NS_IsEventTargetedAtFocusedWindow(nsEvent* aEvent)
|
2009-08-07 08:11:17 -07:00
|
|
|
{
|
2009-12-27 22:26:47 -08:00
|
|
|
return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
|
2011-04-20 16:54:43 -07:00
|
|
|
NS_IS_CONTEXT_MENU_KEY(aEvent) ||
|
2011-05-10 21:52:44 -07:00
|
|
|
NS_IS_CONTENT_COMMAND_EVENT(aEvent) ||
|
|
|
|
NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
|
2009-08-07 08:11:17 -07:00
|
|
|
}
|
|
|
|
|
2010-06-14 22:05:37 -07:00
|
|
|
/**
|
|
|
|
* Whether the event should be handled by the focused content or not. E.g.,
|
|
|
|
* key events, IME related events and other input events which are not handled
|
|
|
|
* by the frame of the mouse cursor position.
|
|
|
|
*
|
|
|
|
* NOTE: Even if this returns TRUE, the event isn't going to be handled by the
|
|
|
|
* application level active DOM window which is on another top level window.
|
|
|
|
* So, when the event is fired on a deactive window, the event is going to be
|
|
|
|
* handled by the last focused DOM element of the last focused DOM window in
|
|
|
|
* the last focused window.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
inline bool NS_IsEventTargetedAtFocusedContent(nsEvent* aEvent)
|
2010-06-14 22:05:37 -07:00
|
|
|
{
|
|
|
|
return NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_RELATED_EVENT(aEvent) ||
|
2011-05-10 21:52:44 -07:00
|
|
|
NS_IS_CONTEXT_MENU_KEY(aEvent) ||
|
|
|
|
NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
|
2010-06-14 22:05:37 -07:00
|
|
|
}
|
|
|
|
|
2012-08-16 18:32:15 -07:00
|
|
|
/**
|
|
|
|
* Whether the event should cause a DOM event.
|
|
|
|
*/
|
|
|
|
inline bool NS_IsAllowedToDispatchDOMEvent(nsEvent* aEvent)
|
|
|
|
{
|
|
|
|
switch (aEvent->eventStructType) {
|
|
|
|
case NS_MOUSE_EVENT:
|
|
|
|
// We want synthesized mouse moves to cause mouseover and mouseout
|
|
|
|
// DOM events (nsEventStateManager::PreHandleEvent), but not mousemove
|
|
|
|
// DOM events.
|
|
|
|
// Synthesized button up events also do not cause DOM events because they
|
|
|
|
// do not have a reliable refPoint.
|
|
|
|
return static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal;
|
|
|
|
|
|
|
|
case NS_WHEEL_EVENT: {
|
|
|
|
// wheel event whose all delta values are zero by user pref applied, it
|
|
|
|
// shouldn't cause a DOM event.
|
|
|
|
mozilla::widget::WheelEvent* wheelEvent =
|
|
|
|
static_cast<mozilla::widget::WheelEvent*>(aEvent);
|
|
|
|
return wheelEvent->deltaX != 0.0 || wheelEvent->deltaY != 0.0 ||
|
|
|
|
wheelEvent->deltaZ != 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsGUIEvent_h__
|