1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_MiscEvents_h__
7 #define mozilla_MiscEvents_h__
11 #include "mozilla/BasicEvents.h"
14 #include "nsITransferable.h"
18 /******************************************************************************
19 * mozilla::WidgetContentCommandEvent
20 ******************************************************************************/
22 class WidgetContentCommandEvent
: public WidgetGUIEvent
25 virtual WidgetContentCommandEvent
* AsContentCommandEvent() MOZ_OVERRIDE
30 WidgetContentCommandEvent(bool aIsTrusted
, uint32_t aMessage
,
32 bool aOnlyEnabledCheck
= false)
33 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eContentCommandEventClass
)
34 , mOnlyEnabledCheck(aOnlyEnabledCheck
)
40 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
42 // This event isn't an internal event of any DOM event.
43 NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
44 "WidgetQueryContentEvent needs to support Duplicate()");
45 MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
49 // NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
50 nsCOMPtr
<nsITransferable
> mTransferable
; // [in]
52 // NS_CONTENT_COMMAND_SCROLL
64 mAmount(0), mUnit(eCmdScrollUnit_Line
), mIsHorizontal(false)
68 int32_t mAmount
; // [in]
69 uint8_t mUnit
; // [in]
70 bool mIsHorizontal
; // [in]
73 bool mOnlyEnabledCheck
; // [in]
75 bool mSucceeded
; // [out]
76 bool mIsEnabled
; // [out]
78 void AssignContentCommandEventData(const WidgetContentCommandEvent
& aEvent
,
81 AssignGUIEventData(aEvent
, aCopyTargets
);
83 mScroll
= aEvent
.mScroll
;
84 mOnlyEnabledCheck
= aEvent
.mOnlyEnabledCheck
;
85 mSucceeded
= aEvent
.mSucceeded
;
86 mIsEnabled
= aEvent
.mIsEnabled
;
90 /******************************************************************************
91 * mozilla::WidgetCommandEvent
93 * This sends a command to chrome. If you want to request what is performed
94 * in focused content, you should use WidgetContentCommandEvent instead.
96 * XXX Should be |WidgetChromeCommandEvent|?
97 ******************************************************************************/
99 class WidgetCommandEvent
: public WidgetGUIEvent
102 virtual WidgetCommandEvent
* AsCommandEvent() MOZ_OVERRIDE
{ return this; }
104 WidgetCommandEvent(bool aIsTrusted
, nsIAtom
* aEventType
,
105 nsIAtom
* aCommand
, nsIWidget
* aWidget
)
106 : WidgetGUIEvent(aIsTrusted
, NS_USER_DEFINED_EVENT
, aWidget
,
110 userType
= aEventType
;
113 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
115 MOZ_ASSERT(mClass
== eCommandEventClass
,
116 "Duplicate() must be overridden by sub class");
117 // Not copying widget, it is a weak reference.
118 WidgetCommandEvent
* result
=
119 new WidgetCommandEvent(false, userType
, command
, nullptr);
120 result
->AssignCommandEventData(*this, true);
121 result
->mFlags
= mFlags
;
125 nsCOMPtr
<nsIAtom
> command
;
127 // XXX Not tested by test_assign_event_data.html
128 void AssignCommandEventData(const WidgetCommandEvent
& aEvent
,
131 AssignGUIEventData(aEvent
, aCopyTargets
);
133 // command must have been initialized with the constructor.
137 /******************************************************************************
138 * mozilla::WidgetPluginEvent
140 * This event delivers only a native event to focused plugin.
141 ******************************************************************************/
143 class WidgetPluginEvent
: public WidgetGUIEvent
146 virtual WidgetPluginEvent
* AsPluginEvent() MOZ_OVERRIDE
{ return this; }
148 WidgetPluginEvent(bool aIsTrusted
, uint32_t aMessage
, nsIWidget
* aWidget
)
149 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, ePluginEventClass
)
150 , retargetToFocusedDocument(false)
154 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
156 // NOTE: PluginEvent has to be dispatched to nsIFrame::HandleEvent().
157 // So, this event needs to support Duplicate().
158 MOZ_ASSERT(mClass
== ePluginEventClass
,
159 "Duplicate() must be overridden by sub class");
160 // Not copying widget, it is a weak reference.
161 WidgetPluginEvent
* result
= new WidgetPluginEvent(false, message
, nullptr);
162 result
->AssignPluginEventData(*this, true);
163 result
->mFlags
= mFlags
;
167 // If true, this event needs to be retargeted to focused document.
168 // Otherwise, never retargeted. Defaults to false.
169 bool retargetToFocusedDocument
;
171 void AssignPluginEventData(const WidgetPluginEvent
& aEvent
,
174 AssignGUIEventData(aEvent
, aCopyTargets
);
176 retargetToFocusedDocument
= aEvent
.retargetToFocusedDocument
;
180 } // namespace mozilla
182 #endif // mozilla_MiscEvents_h__