Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/ContentEvents.h
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#ifndef mozilla_ContentEvents_h__
7
#define mozilla_ContentEvents_h__
8
9
#include <stdint.h>
10
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"
17
18
class nsIContent;
19
20
namespace mozilla {
21
22
/******************************************************************************
23
 * mozilla::InternalScrollPortEvent
24
 ******************************************************************************/
25
26
class InternalScrollPortEvent : public WidgetGUIEvent
27
{
28
public:
29
  virtual InternalScrollPortEvent* AsScrollPortEvent() override
30
0
  {
31
0
    return this;
32
0
  }
33
34
  enum OrientType
35
  {
36
    eVertical,
37
    eHorizontal,
38
    eBoth
39
  };
40
41
  InternalScrollPortEvent(bool aIsTrusted, EventMessage aMessage,
42
                          nsIWidget* aWidget)
43
    : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollPortEventClass)
44
    , mOrient(eVertical)
45
0
  {
46
0
  }
47
48
  virtual WidgetEvent* Duplicate() const override
49
0
  {
50
0
    MOZ_ASSERT(mClass == eScrollPortEventClass,
51
0
               "Duplicate() must be overridden by sub class");
52
0
    // Not copying widget, it is a weak reference.
53
0
    InternalScrollPortEvent* result =
54
0
      new InternalScrollPortEvent(false, mMessage, nullptr);
55
0
    result->AssignScrollPortEventData(*this, true);
56
0
    result->mFlags = mFlags;
57
0
    return result;
58
0
  }
59
60
  OrientType mOrient;
61
62
  void AssignScrollPortEventData(const InternalScrollPortEvent& aEvent,
63
                                 bool aCopyTargets)
64
0
  {
65
0
    AssignGUIEventData(aEvent, aCopyTargets);
66
0
67
0
    mOrient = aEvent.mOrient;
68
0
  }
69
};
70
71
/******************************************************************************
72
 * mozilla::InternalScrollPortEvent
73
 ******************************************************************************/
74
75
class InternalScrollAreaEvent : public WidgetGUIEvent
76
{
77
public:
78
  virtual InternalScrollAreaEvent* AsScrollAreaEvent() override
79
0
  {
80
0
    return this;
81
0
  }
82
83
  InternalScrollAreaEvent(bool aIsTrusted, EventMessage aMessage,
84
                          nsIWidget* aWidget)
85
    : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eScrollAreaEventClass)
86
0
  {
87
0
  }
88
89
  virtual WidgetEvent* Duplicate() const override
90
0
  {
91
0
    MOZ_ASSERT(mClass == eScrollAreaEventClass,
92
0
               "Duplicate() must be overridden by sub class");
93
0
    // Not copying widget, it is a weak reference.
94
0
    InternalScrollAreaEvent* result =
95
0
      new InternalScrollAreaEvent(false, mMessage, nullptr);
96
0
    result->AssignScrollAreaEventData(*this, true);
97
0
    result->mFlags = mFlags;
98
0
    return result;
99
0
  }
100
101
  nsRect mArea;
102
103
  void AssignScrollAreaEventData(const InternalScrollAreaEvent& aEvent,
104
                                 bool aCopyTargets)
105
0
  {
106
0
    AssignGUIEventData(aEvent, aCopyTargets);
107
0
108
0
    mArea = aEvent.mArea;
109
0
  }
110
};
111
112
/******************************************************************************
113
 * mozilla::InternalFormEvent
114
 *
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
 ******************************************************************************/
118
119
class InternalFormEvent : public WidgetEvent
120
{
121
public:
122
0
  virtual InternalFormEvent* AsFormEvent() override { return this; }
123
124
  InternalFormEvent(bool aIsTrusted, EventMessage aMessage)
125
    : WidgetEvent(aIsTrusted, aMessage, eFormEventClass)
126
    , mOriginator(nullptr)
127
0
  {
128
0
  }
129
130
  virtual WidgetEvent* Duplicate() const override
131
0
  {
132
0
    MOZ_ASSERT(mClass == eFormEventClass,
133
0
               "Duplicate() must be overridden by sub class");
134
0
    InternalFormEvent* result = new InternalFormEvent(false, mMessage);
135
0
    result->AssignFormEventData(*this, true);
136
0
    result->mFlags = mFlags;
137
0
    return result;
138
0
  }
139
140
  nsIContent* mOriginator;
141
142
  void AssignFormEventData(const InternalFormEvent& aEvent, bool aCopyTargets)
143
0
  {
144
0
    AssignEventData(aEvent, aCopyTargets);
145
0
146
0
    // Don't copy mOriginator due to a weak pointer.
147
0
  }
148
};
149
150
/******************************************************************************
151
 * mozilla::InternalClipboardEvent
152
 ******************************************************************************/
153
154
class InternalClipboardEvent : public WidgetEvent
155
{
156
public:
157
  virtual InternalClipboardEvent* AsClipboardEvent() override
158
0
  {
159
0
    return this;
160
0
  }
161
162
  InternalClipboardEvent(bool aIsTrusted, EventMessage aMessage)
163
    : WidgetEvent(aIsTrusted, aMessage, eClipboardEventClass)
164
0
  {
165
0
  }
166
167
  virtual WidgetEvent* Duplicate() const override
168
0
  {
169
0
    MOZ_ASSERT(mClass == eClipboardEventClass,
170
0
               "Duplicate() must be overridden by sub class");
171
0
    InternalClipboardEvent* result =
172
0
      new InternalClipboardEvent(false, mMessage);
173
0
    result->AssignClipboardEventData(*this, true);
174
0
    result->mFlags = mFlags;
175
0
    return result;
176
0
  }
177
178
  nsCOMPtr<dom::DataTransfer> mClipboardData;
179
180
  void AssignClipboardEventData(const InternalClipboardEvent& aEvent,
181
                                bool aCopyTargets)
182
0
  {
183
0
    AssignEventData(aEvent, aCopyTargets);
184
0
185
0
    mClipboardData = aEvent.mClipboardData;
186
0
  }
187
};
188
189
/******************************************************************************
190
 * mozilla::InternalFocusEvent
191
 ******************************************************************************/
192
193
class InternalFocusEvent : public InternalUIEvent
194
{
195
public:
196
0
  virtual InternalFocusEvent* AsFocusEvent() override { return this; }
197
198
  InternalFocusEvent(bool aIsTrusted, EventMessage aMessage)
199
    : InternalUIEvent(aIsTrusted, aMessage, eFocusEventClass)
200
    , mFromRaise(false)
201
    , mIsRefocus(false)
202
0
  {
203
0
  }
204
205
  virtual WidgetEvent* Duplicate() const override
206
0
  {
207
0
    MOZ_ASSERT(mClass == eFocusEventClass,
208
0
               "Duplicate() must be overridden by sub class");
209
0
    InternalFocusEvent* result = new InternalFocusEvent(false, mMessage);
210
0
    result->AssignFocusEventData(*this, true);
211
0
    result->mFlags = mFlags;
212
0
    return result;
213
0
  }
214
215
  bool mFromRaise;
216
  bool mIsRefocus;
217
218
  void AssignFocusEventData(const InternalFocusEvent& aEvent, bool aCopyTargets)
219
0
  {
220
0
    AssignUIEventData(aEvent, aCopyTargets);
221
0
222
0
    mFromRaise = aEvent.mFromRaise;
223
0
    mIsRefocus = aEvent.mIsRefocus;
224
0
  }
225
};
226
227
/******************************************************************************
228
 * mozilla::InternalTransitionEvent
229
 ******************************************************************************/
230
231
class InternalTransitionEvent : public WidgetEvent
232
{
233
public:
234
  virtual InternalTransitionEvent* AsTransitionEvent() override
235
0
  {
236
0
    return this;
237
0
  }
238
239
  InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
240
    : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
241
    , mElapsedTime(0.0)
242
0
  {
243
0
  }
244
245
  InternalTransitionEvent(const InternalTransitionEvent& aOther) = delete;
246
  InternalTransitionEvent& operator=(const InternalTransitionEvent& aOther) = delete;
247
0
  InternalTransitionEvent(InternalTransitionEvent&& aOther) = default;
248
  InternalTransitionEvent& operator=(InternalTransitionEvent&& aOther) = default;
249
250
  virtual WidgetEvent* Duplicate() const override
251
0
  {
252
0
    MOZ_ASSERT(mClass == eTransitionEventClass,
253
0
               "Duplicate() must be overridden by sub class");
254
0
    InternalTransitionEvent* result =
255
0
      new InternalTransitionEvent(false, mMessage);
256
0
    result->AssignTransitionEventData(*this, true);
257
0
    result->mFlags = mFlags;
258
0
    return result;
259
0
  }
260
261
  nsString mPropertyName;
262
  nsString mPseudoElement;
263
  float mElapsedTime;
264
265
  void AssignTransitionEventData(const InternalTransitionEvent& aEvent,
266
                                 bool aCopyTargets)
267
0
  {
268
0
    AssignEventData(aEvent, aCopyTargets);
269
0
270
0
    mPropertyName = aEvent.mPropertyName;
271
0
    mElapsedTime = aEvent.mElapsedTime;
272
0
    mPseudoElement = aEvent.mPseudoElement;
273
0
  }
274
};
275
276
/******************************************************************************
277
 * mozilla::InternalAnimationEvent
278
 ******************************************************************************/
279
280
class InternalAnimationEvent : public WidgetEvent
281
{
282
public:
283
  virtual InternalAnimationEvent* AsAnimationEvent() override
284
0
  {
285
0
    return this;
286
0
  }
287
288
  InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
289
    : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
290
    , mElapsedTime(0.0)
291
0
  {
292
0
  }
293
294
  InternalAnimationEvent(const InternalAnimationEvent& aOther) = delete;
295
  InternalAnimationEvent& operator=(const InternalAnimationEvent& aOther) = delete;
296
0
  InternalAnimationEvent(InternalAnimationEvent&& aOther) = default;
297
  InternalAnimationEvent& operator=(InternalAnimationEvent&& aOther) = default;
298
299
  virtual WidgetEvent* Duplicate() const override
300
0
  {
301
0
    MOZ_ASSERT(mClass == eAnimationEventClass,
302
0
               "Duplicate() must be overridden by sub class");
303
0
    InternalAnimationEvent* result =
304
0
      new InternalAnimationEvent(false, mMessage);
305
0
    result->AssignAnimationEventData(*this, true);
306
0
    result->mFlags = mFlags;
307
0
    return result;
308
0
  }
309
310
  nsString mAnimationName;
311
  nsString mPseudoElement;
312
  float mElapsedTime;
313
314
  void AssignAnimationEventData(const InternalAnimationEvent& aEvent,
315
                                bool aCopyTargets)
316
0
  {
317
0
    AssignEventData(aEvent, aCopyTargets);
318
0
319
0
    mAnimationName = aEvent.mAnimationName;
320
0
    mElapsedTime = aEvent.mElapsedTime;
321
0
    mPseudoElement = aEvent.mPseudoElement;
322
0
  }
323
};
324
325
/******************************************************************************
326
 * mozilla::InternalSMILTimeEvent
327
 ******************************************************************************/
328
329
class InternalSMILTimeEvent : public InternalUIEvent
330
{
331
public:
332
  virtual InternalSMILTimeEvent* AsSMILTimeEvent() override
333
0
  {
334
0
    return this;
335
0
  }
336
337
  InternalSMILTimeEvent(bool aIsTrusted, EventMessage aMessage)
338
    : InternalUIEvent(aIsTrusted, aMessage, eSMILTimeEventClass)
339
0
  {
340
0
  }
341
342
  virtual WidgetEvent* Duplicate() const override
343
0
  {
344
0
    MOZ_ASSERT(mClass == eSMILTimeEventClass,
345
0
               "Duplicate() must be overridden by sub class");
346
0
    InternalSMILTimeEvent* result = new InternalSMILTimeEvent(false, mMessage);
347
0
    result->AssignSMILTimeEventData(*this, true);
348
0
    result->mFlags = mFlags;
349
0
    return result;
350
0
  }
351
352
  void AssignSMILTimeEventData(const InternalSMILTimeEvent& aEvent,
353
                               bool aCopyTargets)
354
0
  {
355
0
    AssignUIEventData(aEvent, aCopyTargets);
356
0
  }
357
};
358
359
360
} // namespace mozilla
361
362
#endif // mozilla_ContentEvents_h__