Bug 1830741 - Add tests for mach try perf comparators. r=perftest-reviewers,Alexandru...
[gecko.git] / widget / ContentEvents.h
blobaee229c823f83ef6729e59f4d8d79f7e1f1e7012
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 "nsString.h"
18 class nsIContent;
20 namespace mozilla {
22 /******************************************************************************
23 * mozilla::InternalScrollPortEvent
24 ******************************************************************************/
26 class InternalScrollPortEvent : public WidgetGUIEvent {
27 public:
28 virtual InternalScrollPortEvent* AsScrollPortEvent() override { return this; }
30 enum OrientType { eVertical, eHorizontal, eBoth };
32 InternalScrollPortEvent(bool aIsTrusted, EventMessage aMessage,
33 nsIWidget* aWidget)
34 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollPortEventClass),
35 mOrient(eVertical) {}
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;
45 return result;
48 OrientType mOrient;
50 void AssignScrollPortEventData(const InternalScrollPortEvent& aEvent,
51 bool aCopyTargets) {
52 AssignGUIEventData(aEvent, aCopyTargets);
54 mOrient = aEvent.mOrient;
58 /******************************************************************************
59 * mozilla::InternalScrollPortEvent
60 ******************************************************************************/
62 class InternalScrollAreaEvent : public WidgetGUIEvent {
63 public:
64 virtual InternalScrollAreaEvent* AsScrollAreaEvent() override { return this; }
66 InternalScrollAreaEvent(bool aIsTrusted, EventMessage aMessage,
67 nsIWidget* aWidget)
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;
78 return result;
81 nsRect mArea;
83 void AssignScrollAreaEventData(const InternalScrollAreaEvent& aEvent,
84 bool aCopyTargets) {
85 AssignGUIEventData(aEvent, aCopyTargets);
87 mArea = aEvent.mArea;
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 {
99 public:
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;
112 return result;
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 {
129 public:
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;
142 return result;
145 nsCOMPtr<dom::DataTransfer> mClipboardData;
147 void AssignClipboardEventData(const InternalClipboardEvent& aEvent,
148 bool aCopyTargets) {
149 AssignEventData(aEvent, aCopyTargets);
151 mClipboardData = aEvent.mClipboardData;
155 /******************************************************************************
156 * mozilla::InternalFocusEvent
157 ******************************************************************************/
159 class InternalFocusEvent : public InternalUIEvent {
160 public:
161 virtual InternalFocusEvent* AsFocusEvent() override { return this; }
163 InternalFocusEvent(bool aIsTrusted, EventMessage aMessage)
164 : InternalUIEvent(aIsTrusted, aMessage, eFocusEventClass),
165 mFromRaise(false),
166 mIsRefocus(false) {}
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;
174 return result;
177 bool mFromRaise;
178 bool mIsRefocus;
180 void AssignFocusEventData(const InternalFocusEvent& aEvent,
181 bool aCopyTargets) {
182 AssignUIEventData(aEvent, aCopyTargets);
184 mFromRaise = aEvent.mFromRaise;
185 mIsRefocus = aEvent.mIsRefocus;
189 /******************************************************************************
190 * mozilla::InternalTransitionEvent
191 ******************************************************************************/
193 class InternalTransitionEvent : public WidgetEvent {
194 public:
195 virtual InternalTransitionEvent* AsTransitionEvent() override { return this; }
197 InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
198 : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass),
199 mElapsedTime(0.0) {}
201 InternalTransitionEvent(const InternalTransitionEvent& aOther) = delete;
202 InternalTransitionEvent& operator=(const InternalTransitionEvent& aOther) =
203 delete;
204 InternalTransitionEvent(InternalTransitionEvent&& aOther) = default;
205 InternalTransitionEvent& operator=(InternalTransitionEvent&& aOther) =
206 default;
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;
215 return result;
218 nsString mPropertyName;
219 nsString mPseudoElement;
220 float mElapsedTime;
222 void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
223 bool aCopyTargets) {
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 {
237 public:
238 virtual InternalAnimationEvent* AsAnimationEvent() override { return this; }
240 InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
241 : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass),
242 mElapsedTime(0.0) {}
244 InternalAnimationEvent(const InternalAnimationEvent& aOther) = delete;
245 InternalAnimationEvent& operator=(const InternalAnimationEvent& aOther) =
246 delete;
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;
257 return result;
260 nsString mAnimationName;
261 nsString mPseudoElement;
262 float mElapsedTime;
264 void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
265 bool aCopyTargets) {
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 {
279 public:
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;
291 return result;
294 void AssignSMILTimeEventData(const InternalSMILTimeEvent& aEvent,
295 bool aCopyTargets) {
296 AssignUIEventData(aEvent, aCopyTargets);
300 } // namespace mozilla
302 #endif // mozilla_ContentEvents_h__