Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/DeviceMotionEvent.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_DeviceMotionEvent_h_
8
#define mozilla_dom_DeviceMotionEvent_h_
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/dom/DeviceMotionEventBinding.h"
12
#include "mozilla/dom/Event.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
class DeviceRotationRate final : public nsWrapperCache
18
{
19
public:
20
  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
21
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
22
23
  DeviceRotationRate(DeviceMotionEvent* aOwner,
24
                     const Nullable<double>& aAlpha,
25
                     const Nullable<double>& aBeta,
26
                     const Nullable<double>& aGamma);
27
28
  DeviceMotionEvent* GetParentObject() const
29
0
  {
30
0
    return mOwner;
31
0
  }
32
33
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
34
0
  {
35
0
    return DeviceRotationRate_Binding::Wrap(aCx, this, aGivenProto);
36
0
  }
37
38
0
  Nullable<double> GetAlpha() const { return mAlpha; }
39
0
  Nullable<double> GetBeta() const { return mBeta; }
40
0
  Nullable<double> GetGamma() const { return mGamma; }
41
42
private:
43
  ~DeviceRotationRate();
44
45
protected:
46
  RefPtr<DeviceMotionEvent> mOwner;
47
  Nullable<double> mAlpha, mBeta, mGamma;
48
};
49
50
class DeviceAcceleration final : public nsWrapperCache
51
{
52
public:
53
  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
54
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
55
56
  DeviceAcceleration(DeviceMotionEvent* aOwner,
57
                     const Nullable<double>& aX,
58
                     const Nullable<double>& aY,
59
                     const Nullable<double>& aZ);
60
61
  DeviceMotionEvent* GetParentObject() const
62
0
  {
63
0
    return mOwner;
64
0
  }
65
66
  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
67
0
  {
68
0
    return DeviceAcceleration_Binding::Wrap(aCx, this, aGivenProto);
69
0
  }
70
71
0
  Nullable<double> GetX() const { return mX; }
72
0
  Nullable<double> GetY() const { return mY; }
73
0
  Nullable<double> GetZ() const { return mZ; }
74
75
private:
76
  ~DeviceAcceleration();
77
78
protected:
79
  RefPtr<DeviceMotionEvent> mOwner;
80
  Nullable<double> mX, mY, mZ;
81
};
82
83
class DeviceMotionEvent final : public Event
84
{
85
public:
86
87
  DeviceMotionEvent(EventTarget* aOwner,
88
                    nsPresContext* aPresContext,
89
                    WidgetEvent* aEvent)
90
    : Event(aOwner, aPresContext, aEvent)
91
0
  {
92
0
  }
93
94
  NS_DECL_ISUPPORTS_INHERITED
95
96
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, Event)
97
98
  virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
99
0
  {
100
0
    return DeviceMotionEvent_Binding::Wrap(aCx, this, aGivenProto);
101
0
  }
102
103
  DeviceAcceleration* GetAcceleration() const
104
0
  {
105
0
    return mAcceleration;
106
0
  }
107
108
  DeviceAcceleration* GetAccelerationIncludingGravity() const
109
0
  {
110
0
    return mAccelerationIncludingGravity;
111
0
  }
112
113
  DeviceRotationRate* GetRotationRate() const
114
0
  {
115
0
    return mRotationRate;
116
0
  }
117
118
  Nullable<double> GetInterval() const
119
0
  {
120
0
    return mInterval;
121
0
  }
122
123
  void InitDeviceMotionEvent(
124
         const nsAString& aType,
125
         bool aCanBubble,
126
         bool aCancelable,
127
         const DeviceAccelerationInit& aAcceleration,
128
         const DeviceAccelerationInit& aAccelerationIncludingGravity,
129
         const DeviceRotationRateInit& aRotationRate,
130
         const Nullable<double>& aInterval);
131
132
  void InitDeviceMotionEvent(
133
         const nsAString& aType,
134
         bool aCanBubble,
135
         bool aCancelable,
136
         const DeviceAccelerationInit& aAcceleration,
137
         const DeviceAccelerationInit& aAccelerationIncludingGravity,
138
         const DeviceRotationRateInit& aRotationRate,
139
         const Nullable<double>& aInterval,
140
         const Nullable<uint64_t>& aTimeStamp);
141
142
  static already_AddRefed<DeviceMotionEvent>
143
  Constructor(const GlobalObject& aGlobal,
144
              const nsAString& aType,
145
              const DeviceMotionEventInit& aEventInitDict,
146
              ErrorResult& aRv);
147
148
protected:
149
0
  ~DeviceMotionEvent() {}
150
151
  RefPtr<DeviceAcceleration> mAcceleration;
152
  RefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
153
  RefPtr<DeviceRotationRate> mRotationRate;
154
  Nullable<double> mInterval;
155
};
156
157
} // namespace dom
158
} // namespace mozilla
159
160
already_AddRefed<mozilla::dom::DeviceMotionEvent>
161
NS_NewDOMDeviceMotionEvent(mozilla::dom::EventTarget* aOwner,
162
                           nsPresContext* aPresContext,
163
                           mozilla::WidgetEvent* aEvent);
164
165
#endif // mozilla_dom_DeviceMotionEvent_h_