Bug 1456906 [wpt PR 10641] - Subtract scrollbar in PerpendicularContainingBlockLogica...
[gecko.git] / widget / ContentEvents.h
blobd89a10fd0288107836c718304c9e44ab1489b8ef
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
28 public:
29 virtual InternalScrollPortEvent* AsScrollPortEvent() override
31 return this;
34 enum OrientType
36 eVertical,
37 eHorizontal,
38 eBoth
41 InternalScrollPortEvent(bool aIsTrusted, EventMessage aMessage,
42 nsIWidget* aWidget)
43 : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollPortEventClass)
44 , mOrient(eVertical)
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;
57 return result;
60 OrientType mOrient;
62 void AssignScrollPortEventData(const InternalScrollPortEvent& aEvent,
63 bool aCopyTargets)
65 AssignGUIEventData(aEvent, aCopyTargets);
67 mOrient = aEvent.mOrient;
71 /******************************************************************************
72 * mozilla::InternalScrollPortEvent
73 ******************************************************************************/
75 class InternalScrollAreaEvent : public WidgetGUIEvent
77 public:
78 virtual InternalScrollAreaEvent* AsScrollAreaEvent() override
80 return this;
83 InternalScrollAreaEvent(bool aIsTrusted, EventMessage aMessage,
84 nsIWidget* aWidget)
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;
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 * mOriginator is a weak pointer (does not hold a strong reference).
117 ******************************************************************************/
119 class InternalFormEvent : public WidgetEvent
121 public:
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;
137 return result;
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
156 public:
157 virtual InternalClipboardEvent* AsClipboardEvent() override
159 return this;
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;
175 return result;
178 nsCOMPtr<dom::DataTransfer> mClipboardData;
180 void AssignClipboardEventData(const InternalClipboardEvent& aEvent,
181 bool aCopyTargets)
183 AssignEventData(aEvent, aCopyTargets);
185 mClipboardData = aEvent.mClipboardData;
189 /******************************************************************************
190 * mozilla::InternalFocusEvent
191 ******************************************************************************/
193 class InternalFocusEvent : public InternalUIEvent
195 public:
196 virtual InternalFocusEvent* AsFocusEvent() override { return this; }
198 InternalFocusEvent(bool aIsTrusted, EventMessage aMessage)
199 : InternalUIEvent(aIsTrusted, aMessage, eFocusEventClass)
200 , mFromRaise(false)
201 , mIsRefocus(false)
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;
212 return result;
215 bool mFromRaise;
216 bool mIsRefocus;
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
233 public:
234 virtual InternalTransitionEvent* AsTransitionEvent() override
236 return this;
239 InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
240 : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
241 , mElapsedTime(0.0)
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;
258 return result;
261 nsString mPropertyName;
262 nsString mPseudoElement;
263 float mElapsedTime;
265 void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
266 bool aCopyTargets)
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
282 public:
283 virtual InternalAnimationEvent* AsAnimationEvent() override
285 return this;
288 InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
289 : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
290 , mElapsedTime(0.0)
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;
307 return result;
310 nsString mAnimationName;
311 nsString mPseudoElement;
312 float mElapsedTime;
314 void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
315 bool aCopyTargets)
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
331 public:
332 virtual InternalSMILTimeEvent* AsSMILTimeEvent() override
334 return this;
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;
349 return result;
352 void AssignSMILTimeEventData(const InternalSMILTimeEvent& aEvent,
353 bool aCopyTargets)
355 AssignUIEventData(aEvent, aCopyTargets);
360 } // namespace mozilla
362 #endif // mozilla_ContentEvents_h__