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_ContentEvents_h__
7 #define mozilla_ContentEvents_h__
11 #include "mozilla/BasicEvents.h"
12 #include "mozilla/dom/DataTransfer.h"
13 #include "mozilla/dom/EventTarget.h"
22 /******************************************************************************
23 * mozilla::InternalScrollPortEvent
24 ******************************************************************************/
26 class InternalScrollPortEvent
: public WidgetGUIEvent
{
28 virtual InternalScrollPortEvent
* AsScrollPortEvent() override
{ return this; }
30 enum OrientType
{ eVertical
, eHorizontal
, eBoth
};
32 InternalScrollPortEvent(bool aIsTrusted
, EventMessage aMessage
,
34 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollPortEventClass
),
37 virtual WidgetEvent
* Duplicate() const override
{
38 MOZ_ASSERT(mClass
== eScrollPortEventClass
,
39 "Duplicate() must be overridden by sub class");
40 // Not copying widget, it is a weak reference.
41 InternalScrollPortEvent
* result
=
42 new InternalScrollPortEvent(false, mMessage
, nullptr);
43 result
->AssignScrollPortEventData(*this, true);
44 result
->mFlags
= mFlags
;
50 void AssignScrollPortEventData(const InternalScrollPortEvent
& aEvent
,
52 AssignGUIEventData(aEvent
, aCopyTargets
);
54 mOrient
= aEvent
.mOrient
;
58 /******************************************************************************
59 * mozilla::InternalScrollPortEvent
60 ******************************************************************************/
62 class InternalScrollAreaEvent
: public WidgetGUIEvent
{
64 virtual InternalScrollAreaEvent
* AsScrollAreaEvent() override
{ return this; }
66 InternalScrollAreaEvent(bool aIsTrusted
, EventMessage aMessage
,
68 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollAreaEventClass
) {}
70 virtual WidgetEvent
* Duplicate() const override
{
71 MOZ_ASSERT(mClass
== eScrollAreaEventClass
,
72 "Duplicate() must be overridden by sub class");
73 // Not copying widget, it is a weak reference.
74 InternalScrollAreaEvent
* result
=
75 new InternalScrollAreaEvent(false, mMessage
, nullptr);
76 result
->AssignScrollAreaEventData(*this, true);
77 result
->mFlags
= mFlags
;
83 void AssignScrollAreaEventData(const InternalScrollAreaEvent
& aEvent
,
85 AssignGUIEventData(aEvent
, aCopyTargets
);
91 /******************************************************************************
92 * mozilla::InternalFormEvent
94 * We hold the originating form control for form submit and reset events.
95 * mOriginator is a weak pointer (does not hold a strong reference).
96 ******************************************************************************/
98 class InternalFormEvent
: public WidgetEvent
{
100 virtual InternalFormEvent
* AsFormEvent() override
{ return this; }
102 InternalFormEvent(bool aIsTrusted
, EventMessage aMessage
)
103 : WidgetEvent(aIsTrusted
, aMessage
, eFormEventClass
),
104 mOriginator(nullptr) {}
106 virtual WidgetEvent
* Duplicate() const override
{
107 MOZ_ASSERT(mClass
== eFormEventClass
,
108 "Duplicate() must be overridden by sub class");
109 InternalFormEvent
* result
= new InternalFormEvent(false, mMessage
);
110 result
->AssignFormEventData(*this, true);
111 result
->mFlags
= mFlags
;
115 nsIContent
* mOriginator
;
117 void AssignFormEventData(const InternalFormEvent
& aEvent
, bool aCopyTargets
) {
118 AssignEventData(aEvent
, aCopyTargets
);
120 // Don't copy mOriginator due to a weak pointer.
124 /******************************************************************************
125 * mozilla::InternalClipboardEvent
126 ******************************************************************************/
128 class InternalClipboardEvent
: public WidgetEvent
{
130 virtual InternalClipboardEvent
* AsClipboardEvent() override
{ return this; }
132 InternalClipboardEvent(bool aIsTrusted
, EventMessage aMessage
)
133 : WidgetEvent(aIsTrusted
, aMessage
, eClipboardEventClass
) {}
135 virtual WidgetEvent
* Duplicate() const override
{
136 MOZ_ASSERT(mClass
== eClipboardEventClass
,
137 "Duplicate() must be overridden by sub class");
138 InternalClipboardEvent
* result
=
139 new InternalClipboardEvent(false, mMessage
);
140 result
->AssignClipboardEventData(*this, true);
141 result
->mFlags
= mFlags
;
145 nsCOMPtr
<dom::DataTransfer
> mClipboardData
;
147 void AssignClipboardEventData(const InternalClipboardEvent
& aEvent
,
149 AssignEventData(aEvent
, aCopyTargets
);
151 mClipboardData
= aEvent
.mClipboardData
;
155 /******************************************************************************
156 * mozilla::InternalFocusEvent
157 ******************************************************************************/
159 class InternalFocusEvent
: public InternalUIEvent
{
161 virtual InternalFocusEvent
* AsFocusEvent() override
{ return this; }
163 InternalFocusEvent(bool aIsTrusted
, EventMessage aMessage
)
164 : InternalUIEvent(aIsTrusted
, aMessage
, eFocusEventClass
),
168 virtual WidgetEvent
* Duplicate() const override
{
169 MOZ_ASSERT(mClass
== eFocusEventClass
,
170 "Duplicate() must be overridden by sub class");
171 InternalFocusEvent
* result
= new InternalFocusEvent(false, mMessage
);
172 result
->AssignFocusEventData(*this, true);
173 result
->mFlags
= mFlags
;
180 void AssignFocusEventData(const InternalFocusEvent
& aEvent
,
182 AssignUIEventData(aEvent
, aCopyTargets
);
184 mFromRaise
= aEvent
.mFromRaise
;
185 mIsRefocus
= aEvent
.mIsRefocus
;
189 /******************************************************************************
190 * mozilla::InternalTransitionEvent
191 ******************************************************************************/
193 class InternalTransitionEvent
: public WidgetEvent
{
195 virtual InternalTransitionEvent
* AsTransitionEvent() override
{ return this; }
197 InternalTransitionEvent(bool aIsTrusted
, EventMessage aMessage
)
198 : WidgetEvent(aIsTrusted
, aMessage
, eTransitionEventClass
),
201 InternalTransitionEvent(const InternalTransitionEvent
& aOther
) = delete;
202 InternalTransitionEvent
& operator=(const InternalTransitionEvent
& aOther
) =
204 InternalTransitionEvent(InternalTransitionEvent
&& aOther
) = default;
205 InternalTransitionEvent
& operator=(InternalTransitionEvent
&& aOther
) =
208 virtual WidgetEvent
* Duplicate() const override
{
209 MOZ_ASSERT(mClass
== eTransitionEventClass
,
210 "Duplicate() must be overridden by sub class");
211 InternalTransitionEvent
* result
=
212 new InternalTransitionEvent(false, mMessage
);
213 result
->AssignTransitionEventData(*this, true);
214 result
->mFlags
= mFlags
;
218 nsString mPropertyName
;
219 nsString mPseudoElement
;
222 void AssignTransitionEventData(const InternalTransitionEvent
& aEvent
,
224 AssignEventData(aEvent
, aCopyTargets
);
226 mPropertyName
= aEvent
.mPropertyName
;
227 mElapsedTime
= aEvent
.mElapsedTime
;
228 mPseudoElement
= aEvent
.mPseudoElement
;
232 /******************************************************************************
233 * mozilla::InternalAnimationEvent
234 ******************************************************************************/
236 class InternalAnimationEvent
: public WidgetEvent
{
238 virtual InternalAnimationEvent
* AsAnimationEvent() override
{ return this; }
240 InternalAnimationEvent(bool aIsTrusted
, EventMessage aMessage
)
241 : WidgetEvent(aIsTrusted
, aMessage
, eAnimationEventClass
),
244 InternalAnimationEvent(const InternalAnimationEvent
& aOther
) = delete;
245 InternalAnimationEvent
& operator=(const InternalAnimationEvent
& aOther
) =
247 InternalAnimationEvent(InternalAnimationEvent
&& aOther
) = default;
248 InternalAnimationEvent
& operator=(InternalAnimationEvent
&& aOther
) = default;
250 virtual WidgetEvent
* Duplicate() const override
{
251 MOZ_ASSERT(mClass
== eAnimationEventClass
,
252 "Duplicate() must be overridden by sub class");
253 InternalAnimationEvent
* result
=
254 new InternalAnimationEvent(false, mMessage
);
255 result
->AssignAnimationEventData(*this, true);
256 result
->mFlags
= mFlags
;
260 nsString mAnimationName
;
261 nsString mPseudoElement
;
264 void AssignAnimationEventData(const InternalAnimationEvent
& aEvent
,
266 AssignEventData(aEvent
, aCopyTargets
);
268 mAnimationName
= aEvent
.mAnimationName
;
269 mElapsedTime
= aEvent
.mElapsedTime
;
270 mPseudoElement
= aEvent
.mPseudoElement
;
274 /******************************************************************************
275 * mozilla::InternalSMILTimeEvent
276 ******************************************************************************/
278 class InternalSMILTimeEvent
: public InternalUIEvent
{
280 virtual InternalSMILTimeEvent
* AsSMILTimeEvent() override
{ return this; }
282 InternalSMILTimeEvent(bool aIsTrusted
, EventMessage aMessage
)
283 : InternalUIEvent(aIsTrusted
, aMessage
, eSMILTimeEventClass
) {}
285 virtual WidgetEvent
* Duplicate() const override
{
286 MOZ_ASSERT(mClass
== eSMILTimeEventClass
,
287 "Duplicate() must be overridden by sub class");
288 InternalSMILTimeEvent
* result
= new InternalSMILTimeEvent(false, mMessage
);
289 result
->AssignSMILTimeEventData(*this, true);
290 result
->mFlags
= mFlags
;
294 void AssignSMILTimeEventData(const InternalSMILTimeEvent
& aEvent
,
296 AssignUIEventData(aEvent
, aCopyTargets
);
300 } // namespace mozilla
302 #endif // mozilla_ContentEvents_h__