Bumping manifests a=b2g-bump
[gecko.git] / widget / ContentEvents.h
blob5e2aea0b34a6957df123869868e6f7a459a5c56a
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__
9 #include <stdint.h>
11 #include "mozilla/BasicEvents.h"
12 #include "mozilla/dom/DataTransfer.h"
13 #include "mozilla/dom/EventTarget.h"
14 #include "nsCOMPtr.h"
15 #include "nsRect.h"
16 #include "nsStringGlue.h"
18 class nsIContent;
20 namespace mozilla {
22 /******************************************************************************
23 * mozilla::InternalScrollPortEvent
24 ******************************************************************************/
26 class InternalScrollPortEvent : public WidgetGUIEvent
28 public:
29 virtual InternalScrollPortEvent* AsScrollPortEvent() MOZ_OVERRIDE
31 return this;
34 enum orientType
36 vertical = 0,
37 horizontal = 1,
38 both = 2
41 InternalScrollPortEvent(bool aIsTrusted, uint32_t aMessage,
42 nsIWidget* aWidget)
43 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollPortEventClass)
44 , orient(vertical)
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;
57 return result;
60 orientType orient;
62 void AssignScrollPortEventData(const InternalScrollPortEvent& aEvent,
63 bool aCopyTargets)
65 AssignGUIEventData(aEvent, aCopyTargets);
67 orient = aEvent.orient;
71 /******************************************************************************
72 * mozilla::InternalScrollPortEvent
73 ******************************************************************************/
75 class InternalScrollAreaEvent : public WidgetGUIEvent
77 public:
78 virtual InternalScrollAreaEvent* AsScrollAreaEvent() MOZ_OVERRIDE
80 return this;
83 InternalScrollAreaEvent(bool aIsTrusted, uint32_t aMessage,
84 nsIWidget* aWidget)
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;
98 return result;
101 nsRect mArea;
103 void AssignScrollAreaEventData(const InternalScrollAreaEvent& aEvent,
104 bool aCopyTargets)
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
121 public:
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;
137 return result;
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
156 public:
157 virtual InternalClipboardEvent* AsClipboardEvent() MOZ_OVERRIDE
159 return this;
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;
174 return result;
177 nsCOMPtr<dom::DataTransfer> clipboardData;
179 void AssignClipboardEventData(const InternalClipboardEvent& aEvent,
180 bool aCopyTargets)
182 AssignEventData(aEvent, aCopyTargets);
184 clipboardData = aEvent.clipboardData;
188 /******************************************************************************
189 * mozilla::InternalFocusEvent
190 ******************************************************************************/
192 class InternalFocusEvent : public InternalUIEvent
194 public:
195 virtual InternalFocusEvent* AsFocusEvent() MOZ_OVERRIDE { return this; }
197 InternalFocusEvent(bool aIsTrusted, uint32_t aMessage)
198 : InternalUIEvent(aIsTrusted, aMessage, eFocusEventClass)
199 , fromRaise(false)
200 , isRefocus(false)
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;
211 return result;
214 /// The possible related target
215 nsCOMPtr<dom::EventTarget> relatedTarget;
217 bool fromRaise;
218 bool isRefocus;
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
236 public:
237 virtual InternalTransitionEvent* AsTransitionEvent() MOZ_OVERRIDE
239 return this;
242 InternalTransitionEvent(bool aIsTrusted, uint32_t aMessage)
243 : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
244 , elapsedTime(0.0)
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;
257 return result;
260 nsString propertyName;
261 float elapsedTime;
262 nsString pseudoElement;
264 void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
265 bool aCopyTargets)
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
281 public:
282 virtual InternalAnimationEvent* AsAnimationEvent() MOZ_OVERRIDE
284 return this;
287 InternalAnimationEvent(bool aIsTrusted, uint32_t aMessage)
288 : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
289 , elapsedTime(0.0)
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;
301 return result;
304 nsString animationName;
305 float elapsedTime;
306 nsString pseudoElement;
308 void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
309 bool aCopyTargets)
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
325 public:
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;
342 return result;
345 void AssignSVGZoomEventData(const InternalSVGZoomEvent& aEvent,
346 bool aCopyTargets)
348 AssignGUIEventData(aEvent, aCopyTargets);
352 /******************************************************************************
353 * mozilla::InternalSMILTimeEvent
354 ******************************************************************************/
356 class InternalSMILTimeEvent : public InternalUIEvent
358 public:
359 virtual InternalSMILTimeEvent* AsSMILTimeEvent() MOZ_OVERRIDE
361 return this;
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;
378 return result;
381 void AssignSMILTimeEventData(const InternalSMILTimeEvent& aEvent,
382 bool aCopyTargets)
384 AssignUIEventData(aEvent, aCopyTargets);
389 } // namespace mozilla
391 #endif // mozilla_ContentEvents_h__