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 const WidgetEventTime
* aTime
= nullptr)
35 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollPortEventClass
,
39 virtual WidgetEvent
* Duplicate() const override
{
40 MOZ_ASSERT(mClass
== eScrollPortEventClass
,
41 "Duplicate() must be overridden by sub class");
42 // Not copying widget, it is a weak reference.
43 InternalScrollPortEvent
* result
=
44 new InternalScrollPortEvent(false, mMessage
, nullptr, this);
45 result
->AssignScrollPortEventData(*this, true);
46 result
->mFlags
= mFlags
;
52 void AssignScrollPortEventData(const InternalScrollPortEvent
& aEvent
,
54 AssignGUIEventData(aEvent
, aCopyTargets
);
56 mOrient
= aEvent
.mOrient
;
60 /******************************************************************************
61 * mozilla::InternalScrollPortEvent
62 ******************************************************************************/
64 class InternalScrollAreaEvent
: public WidgetGUIEvent
{
66 virtual InternalScrollAreaEvent
* AsScrollAreaEvent() override
{ return this; }
68 InternalScrollAreaEvent(bool aIsTrusted
, EventMessage aMessage
,
70 const WidgetEventTime
* aTime
= nullptr)
71 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollAreaEventClass
,
74 virtual WidgetEvent
* Duplicate() const override
{
75 MOZ_ASSERT(mClass
== eScrollAreaEventClass
,
76 "Duplicate() must be overridden by sub class");
77 // Not copying widget, it is a weak reference.
78 InternalScrollAreaEvent
* result
=
79 new InternalScrollAreaEvent(false, mMessage
, nullptr, this);
80 result
->AssignScrollAreaEventData(*this, true);
81 result
->mFlags
= mFlags
;
87 void AssignScrollAreaEventData(const InternalScrollAreaEvent
& aEvent
,
89 AssignGUIEventData(aEvent
, aCopyTargets
);
95 /******************************************************************************
96 * mozilla::InternalFormEvent
98 * We hold the originating form control for form submit and reset events.
99 * mOriginator is a weak pointer (does not hold a strong reference).
100 ******************************************************************************/
102 class InternalFormEvent
: public WidgetEvent
{
104 virtual InternalFormEvent
* AsFormEvent() override
{ return this; }
106 InternalFormEvent(bool aIsTrusted
, EventMessage aMessage
,
107 const WidgetEventTime
* aTime
= nullptr)
108 : WidgetEvent(aIsTrusted
, aMessage
, eFormEventClass
, aTime
),
109 mOriginator(nullptr) {}
111 virtual WidgetEvent
* Duplicate() const override
{
112 MOZ_ASSERT(mClass
== eFormEventClass
,
113 "Duplicate() must be overridden by sub class");
114 InternalFormEvent
* result
= new InternalFormEvent(false, mMessage
, this);
115 result
->AssignFormEventData(*this, true);
116 result
->mFlags
= mFlags
;
120 nsIContent
* mOriginator
;
122 void AssignFormEventData(const InternalFormEvent
& aEvent
, bool aCopyTargets
) {
123 AssignEventData(aEvent
, aCopyTargets
);
125 // Don't copy mOriginator due to a weak pointer.
129 /******************************************************************************
130 * mozilla::InternalClipboardEvent
131 ******************************************************************************/
133 class InternalClipboardEvent
: public WidgetEvent
{
135 virtual InternalClipboardEvent
* AsClipboardEvent() override
{ return this; }
137 InternalClipboardEvent(bool aIsTrusted
, EventMessage aMessage
,
138 const WidgetEventTime
* aTime
= nullptr)
139 : WidgetEvent(aIsTrusted
, aMessage
, eClipboardEventClass
, aTime
) {}
141 virtual WidgetEvent
* Duplicate() const override
{
142 MOZ_ASSERT(mClass
== eClipboardEventClass
,
143 "Duplicate() must be overridden by sub class");
144 InternalClipboardEvent
* result
=
145 new InternalClipboardEvent(false, mMessage
, this);
146 result
->AssignClipboardEventData(*this, true);
147 result
->mFlags
= mFlags
;
151 nsCOMPtr
<dom::DataTransfer
> mClipboardData
;
153 void AssignClipboardEventData(const InternalClipboardEvent
& aEvent
,
155 AssignEventData(aEvent
, aCopyTargets
);
157 mClipboardData
= aEvent
.mClipboardData
;
161 /******************************************************************************
162 * mozilla::InternalFocusEvent
163 ******************************************************************************/
165 class InternalFocusEvent
: public InternalUIEvent
{
167 virtual InternalFocusEvent
* AsFocusEvent() override
{ return this; }
169 InternalFocusEvent(bool aIsTrusted
, EventMessage aMessage
,
170 const WidgetEventTime
* aTime
= nullptr)
171 : InternalUIEvent(aIsTrusted
, aMessage
, eFocusEventClass
, aTime
),
175 virtual WidgetEvent
* Duplicate() const override
{
176 MOZ_ASSERT(mClass
== eFocusEventClass
,
177 "Duplicate() must be overridden by sub class");
178 InternalFocusEvent
* result
= new InternalFocusEvent(false, mMessage
, this);
179 result
->AssignFocusEventData(*this, true);
180 result
->mFlags
= mFlags
;
187 void AssignFocusEventData(const InternalFocusEvent
& aEvent
,
189 AssignUIEventData(aEvent
, aCopyTargets
);
191 mFromRaise
= aEvent
.mFromRaise
;
192 mIsRefocus
= aEvent
.mIsRefocus
;
196 /******************************************************************************
197 * mozilla::InternalTransitionEvent
198 ******************************************************************************/
200 class InternalTransitionEvent
: public WidgetEvent
{
202 virtual InternalTransitionEvent
* AsTransitionEvent() override
{ return this; }
204 InternalTransitionEvent(bool aIsTrusted
, EventMessage aMessage
,
205 const WidgetEventTime
* aTime
= nullptr)
206 : WidgetEvent(aIsTrusted
, aMessage
, eTransitionEventClass
, aTime
),
209 InternalTransitionEvent(const InternalTransitionEvent
& aOther
) = delete;
210 InternalTransitionEvent
& operator=(const InternalTransitionEvent
& aOther
) =
212 InternalTransitionEvent(InternalTransitionEvent
&& aOther
) = default;
213 InternalTransitionEvent
& operator=(InternalTransitionEvent
&& aOther
) =
216 virtual WidgetEvent
* Duplicate() const override
{
217 MOZ_ASSERT(mClass
== eTransitionEventClass
,
218 "Duplicate() must be overridden by sub class");
219 InternalTransitionEvent
* result
=
220 new InternalTransitionEvent(false, mMessage
, this);
221 result
->AssignTransitionEventData(*this, true);
222 result
->mFlags
= mFlags
;
226 nsString mPropertyName
;
227 nsString mPseudoElement
;
230 void AssignTransitionEventData(const InternalTransitionEvent
& aEvent
,
232 AssignEventData(aEvent
, aCopyTargets
);
234 mPropertyName
= aEvent
.mPropertyName
;
235 mElapsedTime
= aEvent
.mElapsedTime
;
236 mPseudoElement
= aEvent
.mPseudoElement
;
240 /******************************************************************************
241 * mozilla::InternalAnimationEvent
242 ******************************************************************************/
244 class InternalAnimationEvent
: public WidgetEvent
{
246 virtual InternalAnimationEvent
* AsAnimationEvent() override
{ return this; }
248 InternalAnimationEvent(bool aIsTrusted
, EventMessage aMessage
,
249 const WidgetEventTime
* aTime
= nullptr)
250 : WidgetEvent(aIsTrusted
, aMessage
, eAnimationEventClass
, aTime
),
253 InternalAnimationEvent(const InternalAnimationEvent
& aOther
) = delete;
254 InternalAnimationEvent
& operator=(const InternalAnimationEvent
& aOther
) =
256 InternalAnimationEvent(InternalAnimationEvent
&& aOther
) = default;
257 InternalAnimationEvent
& operator=(InternalAnimationEvent
&& aOther
) = default;
259 virtual WidgetEvent
* Duplicate() const override
{
260 MOZ_ASSERT(mClass
== eAnimationEventClass
,
261 "Duplicate() must be overridden by sub class");
262 InternalAnimationEvent
* result
=
263 new InternalAnimationEvent(false, mMessage
, this);
264 result
->AssignAnimationEventData(*this, true);
265 result
->mFlags
= mFlags
;
269 nsString mAnimationName
;
270 nsString mPseudoElement
;
273 void AssignAnimationEventData(const InternalAnimationEvent
& aEvent
,
275 AssignEventData(aEvent
, aCopyTargets
);
277 mAnimationName
= aEvent
.mAnimationName
;
278 mElapsedTime
= aEvent
.mElapsedTime
;
279 mPseudoElement
= aEvent
.mPseudoElement
;
283 /******************************************************************************
284 * mozilla::InternalSMILTimeEvent
285 ******************************************************************************/
287 class InternalSMILTimeEvent
: public InternalUIEvent
{
289 virtual InternalSMILTimeEvent
* AsSMILTimeEvent() override
{ return this; }
291 InternalSMILTimeEvent(bool aIsTrusted
, EventMessage aMessage
,
292 const WidgetEventTime
* aTime
= nullptr)
293 : InternalUIEvent(aIsTrusted
, aMessage
, eSMILTimeEventClass
, aTime
) {}
295 virtual WidgetEvent
* Duplicate() const override
{
296 MOZ_ASSERT(mClass
== eSMILTimeEventClass
,
297 "Duplicate() must be overridden by sub class");
298 InternalSMILTimeEvent
* result
=
299 new InternalSMILTimeEvent(false, mMessage
, this);
300 result
->AssignSMILTimeEventData(*this, true);
301 result
->mFlags
= mFlags
;
305 void AssignSMILTimeEventData(const InternalSMILTimeEvent
& aEvent
,
307 AssignUIEventData(aEvent
, aCopyTargets
);
311 } // namespace mozilla
313 #endif // mozilla_ContentEvents_h__