Bumping manifests a=b2g-bump
[gecko.git] / dom / events / SimpleGestureEvent.cpp
blob2c81c4057c7b8ff37dd0611a84e336c5cdc47bb7
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 #include "mozilla/dom/SimpleGestureEvent.h"
7 #include "mozilla/TouchEvents.h"
8 #include "prtime.h"
10 namespace mozilla {
11 namespace dom {
13 SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
14 nsPresContext* aPresContext,
15 WidgetSimpleGestureEvent* aEvent)
16 : MouseEvent(aOwner, aPresContext,
17 aEvent ? aEvent :
18 new WidgetSimpleGestureEvent(false, 0, nullptr))
20 NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
21 "event type mismatch");
23 if (aEvent) {
24 mEventIsInternal = false;
25 } else {
26 mEventIsInternal = true;
27 mEvent->time = PR_Now();
28 mEvent->refPoint.x = mEvent->refPoint.y = 0;
29 static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
30 nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
34 NS_IMPL_ADDREF_INHERITED(SimpleGestureEvent, MouseEvent)
35 NS_IMPL_RELEASE_INHERITED(SimpleGestureEvent, MouseEvent)
37 NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
38 NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
39 NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
41 /* attribute unsigned long allowedDirections; */
42 uint32_t
43 SimpleGestureEvent::AllowedDirections()
45 return mEvent->AsSimpleGestureEvent()->allowedDirections;
48 NS_IMETHODIMP
49 SimpleGestureEvent::GetAllowedDirections(uint32_t* aAllowedDirections)
51 NS_ENSURE_ARG_POINTER(aAllowedDirections);
52 *aAllowedDirections = AllowedDirections();
53 return NS_OK;
56 NS_IMETHODIMP
57 SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
59 mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
60 return NS_OK;
63 /* readonly attribute unsigned long direction; */
64 uint32_t
65 SimpleGestureEvent::Direction()
67 return mEvent->AsSimpleGestureEvent()->direction;
70 NS_IMETHODIMP
71 SimpleGestureEvent::GetDirection(uint32_t* aDirection)
73 NS_ENSURE_ARG_POINTER(aDirection);
74 *aDirection = Direction();
75 return NS_OK;
78 /* readonly attribute float delta; */
79 double
80 SimpleGestureEvent::Delta()
82 return mEvent->AsSimpleGestureEvent()->delta;
85 NS_IMETHODIMP
86 SimpleGestureEvent::GetDelta(double* aDelta)
88 NS_ENSURE_ARG_POINTER(aDelta);
89 *aDelta = Delta();
90 return NS_OK;
93 /* readonly attribute unsigned long clickCount; */
94 uint32_t
95 SimpleGestureEvent::ClickCount()
97 return mEvent->AsSimpleGestureEvent()->clickCount;
100 NS_IMETHODIMP
101 SimpleGestureEvent::GetClickCount(uint32_t* aClickCount)
103 NS_ENSURE_ARG_POINTER(aClickCount);
104 *aClickCount = ClickCount();
105 return NS_OK;
108 NS_IMETHODIMP
109 SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
110 bool aCanBubbleArg,
111 bool aCancelableArg,
112 nsIDOMWindow* aViewArg,
113 int32_t aDetailArg,
114 int32_t aScreenX,
115 int32_t aScreenY,
116 int32_t aClientX,
117 int32_t aClientY,
118 bool aCtrlKeyArg,
119 bool aAltKeyArg,
120 bool aShiftKeyArg,
121 bool aMetaKeyArg,
122 uint16_t aButton,
123 nsIDOMEventTarget* aRelatedTarget,
124 uint32_t aAllowedDirectionsArg,
125 uint32_t aDirectionArg,
126 double aDeltaArg,
127 uint32_t aClickCountArg)
129 nsresult rv =
130 MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
131 aViewArg, aDetailArg,
132 aScreenX, aScreenY, aClientX, aClientY,
133 aCtrlKeyArg, aAltKeyArg, aShiftKeyArg,
134 aMetaKeyArg, aButton, aRelatedTarget);
135 NS_ENSURE_SUCCESS(rv, rv);
137 WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
138 simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
139 simpleGestureEvent->direction = aDirectionArg;
140 simpleGestureEvent->delta = aDeltaArg;
141 simpleGestureEvent->clickCount = aClickCountArg;
143 return NS_OK;
146 } // namespace dom
147 } // namespace mozilla
149 using namespace mozilla;
150 using namespace mozilla::dom;
152 nsresult
153 NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
154 EventTarget* aOwner,
155 nsPresContext* aPresContext,
156 WidgetSimpleGestureEvent* aEvent)
158 SimpleGestureEvent* it = new SimpleGestureEvent(aOwner, aPresContext, aEvent);
159 NS_ADDREF(it);
160 *aInstancePtrResult = static_cast<Event*>(it);
161 return NS_OK;