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
29 virtual InternalScrollPortEvent
* AsScrollPortEvent() override
41 InternalScrollPortEvent(bool aIsTrusted
, EventMessage aMessage
,
43 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollPortEventClass
)
48 virtual WidgetEvent
* Duplicate() const override
50 MOZ_ASSERT(mClass
== eScrollPortEventClass
,
51 "Duplicate() must be overridden by sub class");
52 // Not copying widget, it is a weak reference.
53 InternalScrollPortEvent
* result
=
54 new InternalScrollPortEvent(false, mMessage
, nullptr);
55 result
->AssignScrollPortEventData(*this, true);
56 result
->mFlags
= mFlags
;
62 void AssignScrollPortEventData(const InternalScrollPortEvent
& aEvent
,
65 AssignGUIEventData(aEvent
, aCopyTargets
);
67 mOrient
= aEvent
.mOrient
;
71 /******************************************************************************
72 * mozilla::InternalScrollPortEvent
73 ******************************************************************************/
75 class InternalScrollAreaEvent
: public WidgetGUIEvent
78 virtual InternalScrollAreaEvent
* AsScrollAreaEvent() override
83 InternalScrollAreaEvent(bool aIsTrusted
, EventMessage aMessage
,
85 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollAreaEventClass
)
89 virtual WidgetEvent
* Duplicate() const override
91 MOZ_ASSERT(mClass
== eScrollAreaEventClass
,
92 "Duplicate() must be overridden by sub class");
93 // Not copying widget, it is a weak reference.
94 InternalScrollAreaEvent
* result
=
95 new InternalScrollAreaEvent(false, mMessage
, nullptr);
96 result
->AssignScrollAreaEventData(*this, true);
97 result
->mFlags
= mFlags
;
103 void AssignScrollAreaEventData(const InternalScrollAreaEvent
& aEvent
,
106 AssignGUIEventData(aEvent
, aCopyTargets
);
108 mArea
= aEvent
.mArea
;
112 /******************************************************************************
113 * mozilla::InternalFormEvent
115 * We hold the originating form control for form submit and reset events.
116 * mOriginator is a weak pointer (does not hold a strong reference).
117 ******************************************************************************/
119 class InternalFormEvent
: public WidgetEvent
122 virtual InternalFormEvent
* AsFormEvent() override
{ return this; }
124 InternalFormEvent(bool aIsTrusted
, EventMessage aMessage
)
125 : WidgetEvent(aIsTrusted
, aMessage
, eFormEventClass
)
126 , mOriginator(nullptr)
130 virtual WidgetEvent
* Duplicate() const override
132 MOZ_ASSERT(mClass
== eFormEventClass
,
133 "Duplicate() must be overridden by sub class");
134 InternalFormEvent
* result
= new InternalFormEvent(false, mMessage
);
135 result
->AssignFormEventData(*this, true);
136 result
->mFlags
= mFlags
;
140 nsIContent
* mOriginator
;
142 void AssignFormEventData(const InternalFormEvent
& aEvent
, bool aCopyTargets
)
144 AssignEventData(aEvent
, aCopyTargets
);
146 // Don't copy mOriginator due to a weak pointer.
150 /******************************************************************************
151 * mozilla::InternalClipboardEvent
152 ******************************************************************************/
154 class InternalClipboardEvent
: public WidgetEvent
157 virtual InternalClipboardEvent
* AsClipboardEvent() override
162 InternalClipboardEvent(bool aIsTrusted
, EventMessage aMessage
)
163 : WidgetEvent(aIsTrusted
, aMessage
, eClipboardEventClass
)
167 virtual WidgetEvent
* Duplicate() const override
169 MOZ_ASSERT(mClass
== eClipboardEventClass
,
170 "Duplicate() must be overridden by sub class");
171 InternalClipboardEvent
* result
=
172 new InternalClipboardEvent(false, mMessage
);
173 result
->AssignClipboardEventData(*this, true);
174 result
->mFlags
= mFlags
;
178 nsCOMPtr
<dom::DataTransfer
> mClipboardData
;
180 void AssignClipboardEventData(const InternalClipboardEvent
& aEvent
,
183 AssignEventData(aEvent
, aCopyTargets
);
185 mClipboardData
= aEvent
.mClipboardData
;
189 /******************************************************************************
190 * mozilla::InternalFocusEvent
191 ******************************************************************************/
193 class InternalFocusEvent
: public InternalUIEvent
196 virtual InternalFocusEvent
* AsFocusEvent() override
{ return this; }
198 InternalFocusEvent(bool aIsTrusted
, EventMessage aMessage
)
199 : InternalUIEvent(aIsTrusted
, aMessage
, eFocusEventClass
)
205 virtual WidgetEvent
* Duplicate() const override
207 MOZ_ASSERT(mClass
== eFocusEventClass
,
208 "Duplicate() must be overridden by sub class");
209 InternalFocusEvent
* result
= new InternalFocusEvent(false, mMessage
);
210 result
->AssignFocusEventData(*this, true);
211 result
->mFlags
= mFlags
;
218 void AssignFocusEventData(const InternalFocusEvent
& aEvent
, bool aCopyTargets
)
220 AssignUIEventData(aEvent
, aCopyTargets
);
222 mFromRaise
= aEvent
.mFromRaise
;
223 mIsRefocus
= aEvent
.mIsRefocus
;
227 /******************************************************************************
228 * mozilla::InternalTransitionEvent
229 ******************************************************************************/
231 class InternalTransitionEvent
: public WidgetEvent
234 virtual InternalTransitionEvent
* AsTransitionEvent() override
239 InternalTransitionEvent(bool aIsTrusted
, EventMessage aMessage
)
240 : WidgetEvent(aIsTrusted
, aMessage
, eTransitionEventClass
)
245 InternalTransitionEvent(const InternalTransitionEvent
& aOther
) = delete;
246 InternalTransitionEvent
& operator=(const InternalTransitionEvent
& aOther
) = delete;
247 InternalTransitionEvent(InternalTransitionEvent
&& aOther
) = default;
248 InternalTransitionEvent
& operator=(InternalTransitionEvent
&& aOther
) = default;
250 virtual WidgetEvent
* Duplicate() const override
252 MOZ_ASSERT(mClass
== eTransitionEventClass
,
253 "Duplicate() must be overridden by sub class");
254 InternalTransitionEvent
* result
=
255 new InternalTransitionEvent(false, mMessage
);
256 result
->AssignTransitionEventData(*this, true);
257 result
->mFlags
= mFlags
;
261 nsString mPropertyName
;
262 nsString mPseudoElement
;
265 void AssignTransitionEventData(const InternalTransitionEvent
& aEvent
,
268 AssignEventData(aEvent
, aCopyTargets
);
270 mPropertyName
= aEvent
.mPropertyName
;
271 mElapsedTime
= aEvent
.mElapsedTime
;
272 mPseudoElement
= aEvent
.mPseudoElement
;
276 /******************************************************************************
277 * mozilla::InternalAnimationEvent
278 ******************************************************************************/
280 class InternalAnimationEvent
: public WidgetEvent
283 virtual InternalAnimationEvent
* AsAnimationEvent() override
288 InternalAnimationEvent(bool aIsTrusted
, EventMessage aMessage
)
289 : WidgetEvent(aIsTrusted
, aMessage
, eAnimationEventClass
)
294 InternalAnimationEvent(const InternalAnimationEvent
& aOther
) = delete;
295 InternalAnimationEvent
& operator=(const InternalAnimationEvent
& aOther
) = delete;
296 InternalAnimationEvent(InternalAnimationEvent
&& aOther
) = default;
297 InternalAnimationEvent
& operator=(InternalAnimationEvent
&& aOther
) = default;
299 virtual WidgetEvent
* Duplicate() const override
301 MOZ_ASSERT(mClass
== eAnimationEventClass
,
302 "Duplicate() must be overridden by sub class");
303 InternalAnimationEvent
* result
=
304 new InternalAnimationEvent(false, mMessage
);
305 result
->AssignAnimationEventData(*this, true);
306 result
->mFlags
= mFlags
;
310 nsString mAnimationName
;
311 nsString mPseudoElement
;
314 void AssignAnimationEventData(const InternalAnimationEvent
& aEvent
,
317 AssignEventData(aEvent
, aCopyTargets
);
319 mAnimationName
= aEvent
.mAnimationName
;
320 mElapsedTime
= aEvent
.mElapsedTime
;
321 mPseudoElement
= aEvent
.mPseudoElement
;
325 /******************************************************************************
326 * mozilla::InternalSMILTimeEvent
327 ******************************************************************************/
329 class InternalSMILTimeEvent
: public InternalUIEvent
332 virtual InternalSMILTimeEvent
* AsSMILTimeEvent() override
337 InternalSMILTimeEvent(bool aIsTrusted
, EventMessage aMessage
)
338 : InternalUIEvent(aIsTrusted
, aMessage
, eSMILTimeEventClass
)
342 virtual WidgetEvent
* Duplicate() const override
344 MOZ_ASSERT(mClass
== eSMILTimeEventClass
,
345 "Duplicate() must be overridden by sub class");
346 InternalSMILTimeEvent
* result
= new InternalSMILTimeEvent(false, mMessage
);
347 result
->AssignSMILTimeEventData(*this, true);
348 result
->mFlags
= mFlags
;
352 void AssignSMILTimeEventData(const InternalSMILTimeEvent
& aEvent
,
355 AssignUIEventData(aEvent
, aCopyTargets
);
360 } // namespace mozilla
362 #endif // mozilla_ContentEvents_h__