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"
16 #include "nsStringGlue.h"
22 /******************************************************************************
23 * mozilla::InternalScrollPortEvent
24 ******************************************************************************/
26 class InternalScrollPortEvent
: public WidgetGUIEvent
29 virtual InternalScrollPortEvent
* AsScrollPortEvent() MOZ_OVERRIDE
41 InternalScrollPortEvent(bool aIsTrusted
, uint32_t aMessage
,
43 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollPortEventClass
)
48 virtual WidgetEvent
* Duplicate() const MOZ_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, message
, nullptr);
55 result
->AssignScrollPortEventData(*this, true);
56 result
->mFlags
= mFlags
;
62 void AssignScrollPortEventData(const InternalScrollPortEvent
& aEvent
,
65 AssignGUIEventData(aEvent
, aCopyTargets
);
67 orient
= aEvent
.orient
;
71 /******************************************************************************
72 * mozilla::InternalScrollPortEvent
73 ******************************************************************************/
75 class InternalScrollAreaEvent
: public WidgetGUIEvent
78 virtual InternalScrollAreaEvent
* AsScrollAreaEvent() MOZ_OVERRIDE
83 InternalScrollAreaEvent(bool aIsTrusted
, uint32_t aMessage
,
85 : WidgetGUIEvent(aIsTrusted
, aMessage
, aWidget
, eScrollAreaEventClass
)
89 virtual WidgetEvent
* Duplicate() const MOZ_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, message
, 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 * originator is a weak pointer (does not hold a strong reference).
117 ******************************************************************************/
119 class InternalFormEvent
: public WidgetEvent
122 virtual InternalFormEvent
* AsFormEvent() MOZ_OVERRIDE
{ return this; }
124 InternalFormEvent(bool aIsTrusted
, uint32_t aMessage
)
125 : WidgetEvent(aIsTrusted
, aMessage
, eFormEventClass
)
126 , originator(nullptr)
130 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
132 MOZ_ASSERT(mClass
== eFormEventClass
,
133 "Duplicate() must be overridden by sub class");
134 InternalFormEvent
* result
= new InternalFormEvent(false, message
);
135 result
->AssignFormEventData(*this, true);
136 result
->mFlags
= mFlags
;
140 nsIContent
*originator
;
142 void AssignFormEventData(const InternalFormEvent
& aEvent
, bool aCopyTargets
)
144 AssignEventData(aEvent
, aCopyTargets
);
146 // Don't copy originator due to a weak pointer.
150 /******************************************************************************
151 * mozilla::InternalClipboardEvent
152 ******************************************************************************/
154 class InternalClipboardEvent
: public WidgetEvent
157 virtual InternalClipboardEvent
* AsClipboardEvent() MOZ_OVERRIDE
162 InternalClipboardEvent(bool aIsTrusted
, uint32_t aMessage
)
163 : WidgetEvent(aIsTrusted
, aMessage
, eClipboardEventClass
)
167 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
169 MOZ_ASSERT(mClass
== eClipboardEventClass
,
170 "Duplicate() must be overridden by sub class");
171 InternalClipboardEvent
* result
= new InternalClipboardEvent(false, message
);
172 result
->AssignClipboardEventData(*this, true);
173 result
->mFlags
= mFlags
;
177 nsCOMPtr
<dom::DataTransfer
> clipboardData
;
179 void AssignClipboardEventData(const InternalClipboardEvent
& aEvent
,
182 AssignEventData(aEvent
, aCopyTargets
);
184 clipboardData
= aEvent
.clipboardData
;
188 /******************************************************************************
189 * mozilla::InternalFocusEvent
190 ******************************************************************************/
192 class InternalFocusEvent
: public InternalUIEvent
195 virtual InternalFocusEvent
* AsFocusEvent() MOZ_OVERRIDE
{ return this; }
197 InternalFocusEvent(bool aIsTrusted
, uint32_t aMessage
)
198 : InternalUIEvent(aIsTrusted
, aMessage
, eFocusEventClass
)
204 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
206 MOZ_ASSERT(mClass
== eFocusEventClass
,
207 "Duplicate() must be overridden by sub class");
208 InternalFocusEvent
* result
= new InternalFocusEvent(false, message
);
209 result
->AssignFocusEventData(*this, true);
210 result
->mFlags
= mFlags
;
214 /// The possible related target
215 nsCOMPtr
<dom::EventTarget
> relatedTarget
;
220 void AssignFocusEventData(const InternalFocusEvent
& aEvent
, bool aCopyTargets
)
222 AssignUIEventData(aEvent
, aCopyTargets
);
224 relatedTarget
= aCopyTargets
? aEvent
.relatedTarget
: nullptr;
225 fromRaise
= aEvent
.fromRaise
;
226 isRefocus
= aEvent
.isRefocus
;
230 /******************************************************************************
231 * mozilla::InternalTransitionEvent
232 ******************************************************************************/
234 class InternalTransitionEvent
: public WidgetEvent
237 virtual InternalTransitionEvent
* AsTransitionEvent() MOZ_OVERRIDE
242 InternalTransitionEvent(bool aIsTrusted
, uint32_t aMessage
)
243 : WidgetEvent(aIsTrusted
, aMessage
, eTransitionEventClass
)
246 mFlags
.mCancelable
= false;
249 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
251 MOZ_ASSERT(mClass
== eTransitionEventClass
,
252 "Duplicate() must be overridden by sub class");
253 InternalTransitionEvent
* result
=
254 new InternalTransitionEvent(false, message
);
255 result
->AssignTransitionEventData(*this, true);
256 result
->mFlags
= mFlags
;
260 nsString propertyName
;
262 nsString pseudoElement
;
264 void AssignTransitionEventData(const InternalTransitionEvent
& aEvent
,
267 AssignEventData(aEvent
, aCopyTargets
);
269 propertyName
= aEvent
.propertyName
;
270 elapsedTime
= aEvent
.elapsedTime
;
271 pseudoElement
= aEvent
.pseudoElement
;
275 /******************************************************************************
276 * mozilla::InternalAnimationEvent
277 ******************************************************************************/
279 class InternalAnimationEvent
: public WidgetEvent
282 virtual InternalAnimationEvent
* AsAnimationEvent() MOZ_OVERRIDE
287 InternalAnimationEvent(bool aIsTrusted
, uint32_t aMessage
)
288 : WidgetEvent(aIsTrusted
, aMessage
, eAnimationEventClass
)
291 mFlags
.mCancelable
= false;
294 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
296 MOZ_ASSERT(mClass
== eAnimationEventClass
,
297 "Duplicate() must be overridden by sub class");
298 InternalAnimationEvent
* result
= new InternalAnimationEvent(false, message
);
299 result
->AssignAnimationEventData(*this, true);
300 result
->mFlags
= mFlags
;
304 nsString animationName
;
306 nsString pseudoElement
;
308 void AssignAnimationEventData(const InternalAnimationEvent
& aEvent
,
311 AssignEventData(aEvent
, aCopyTargets
);
313 animationName
= aEvent
.animationName
;
314 elapsedTime
= aEvent
.elapsedTime
;
315 pseudoElement
= aEvent
.pseudoElement
;
319 /******************************************************************************
320 * mozilla::InternalSVGZoomEvent
321 ******************************************************************************/
323 class InternalSVGZoomEvent
: public WidgetGUIEvent
326 virtual InternalSVGZoomEvent
* AsSVGZoomEvent() MOZ_OVERRIDE
{ return this; }
328 InternalSVGZoomEvent(bool aIsTrusted
, uint32_t aMessage
)
329 : WidgetGUIEvent(aIsTrusted
, aMessage
, nullptr, eSVGZoomEventClass
)
331 mFlags
.mCancelable
= false;
334 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
336 MOZ_ASSERT(mClass
== eSVGZoomEventClass
,
337 "Duplicate() must be overridden by sub class");
338 // Not copying widget, it is a weak reference.
339 InternalSVGZoomEvent
* result
= new InternalSVGZoomEvent(false, message
);
340 result
->AssignSVGZoomEventData(*this, true);
341 result
->mFlags
= mFlags
;
345 void AssignSVGZoomEventData(const InternalSVGZoomEvent
& aEvent
,
348 AssignGUIEventData(aEvent
, aCopyTargets
);
352 /******************************************************************************
353 * mozilla::InternalSMILTimeEvent
354 ******************************************************************************/
356 class InternalSMILTimeEvent
: public InternalUIEvent
359 virtual InternalSMILTimeEvent
* AsSMILTimeEvent() MOZ_OVERRIDE
364 InternalSMILTimeEvent(bool aIsTrusted
, uint32_t aMessage
)
365 : InternalUIEvent(aIsTrusted
, aMessage
, eSMILTimeEventClass
)
367 mFlags
.mBubbles
= false;
368 mFlags
.mCancelable
= false;
371 virtual WidgetEvent
* Duplicate() const MOZ_OVERRIDE
373 MOZ_ASSERT(mClass
== eSMILTimeEventClass
,
374 "Duplicate() must be overridden by sub class");
375 InternalSMILTimeEvent
* result
= new InternalSMILTimeEvent(false, message
);
376 result
->AssignSMILTimeEventData(*this, true);
377 result
->mFlags
= mFlags
;
381 void AssignSMILTimeEventData(const InternalSMILTimeEvent
& aEvent
,
384 AssignUIEventData(aEvent
, aCopyTargets
);
389 } // namespace mozilla
391 #endif // mozilla_ContentEvents_h__