Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
[gecko.git] / dom / events / TouchEvent.h
blob22c453c1e4e0549ee5eaf755fcf9fc9ab4845b53
1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
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 #ifndef mozilla_dom_TouchEvent_h_
6 #define mozilla_dom_TouchEvent_h_
8 #include "mozilla/dom/Touch.h"
9 #include "mozilla/dom/TouchEventBinding.h"
10 #include "mozilla/dom/UIEvent.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/EventForwards.h"
13 #include "mozilla/TouchEvents.h"
14 #include "nsJSEnvironment.h"
15 #include "nsWrapperCache.h"
17 class nsAString;
19 namespace mozilla {
20 namespace dom {
22 class TouchList MOZ_FINAL : public nsISupports
23 , public nsWrapperCache
25 public:
26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TouchList)
29 TouchList(nsISupports* aParent)
30 : mParent(aParent)
32 SetIsDOMBinding();
33 nsJSContext::LikelyShortLivingObjectCreated();
35 TouchList(nsISupports* aParent,
36 const WidgetTouchEvent::TouchArray& aTouches)
37 : mParent(aParent)
38 , mPoints(aTouches)
40 SetIsDOMBinding();
41 nsJSContext::LikelyShortLivingObjectCreated();
44 void Append(Touch* aPoint)
46 mPoints.AppendElement(aPoint);
49 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
51 nsISupports* GetParentObject() const
53 return mParent;
56 static bool PrefEnabled(JSContext* aCx = nullptr,
57 JSObject* aGlobal = nullptr);
59 uint32_t Length() const
61 return mPoints.Length();
63 Touch* Item(uint32_t aIndex) const
65 return mPoints.SafeElementAt(aIndex);
67 Touch* IndexedGetter(uint32_t aIndex, bool& aFound) const
69 aFound = aIndex < mPoints.Length();
70 if (!aFound) {
71 return nullptr;
73 return mPoints[aIndex];
75 Touch* IdentifiedTouch(int32_t aIdentifier) const;
77 protected:
78 ~TouchList() {}
80 nsCOMPtr<nsISupports> mParent;
81 WidgetTouchEvent::TouchArray mPoints;
84 class TouchEvent : public UIEvent
86 public:
87 TouchEvent(EventTarget* aOwner,
88 nsPresContext* aPresContext,
89 WidgetTouchEvent* aEvent);
91 NS_DECL_ISUPPORTS_INHERITED
92 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TouchEvent, UIEvent)
94 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
96 return TouchEventBinding::Wrap(aCx, this);
99 TouchList* Touches();
100 TouchList* TargetTouches();
101 TouchList* ChangedTouches();
103 bool AltKey();
104 bool MetaKey();
105 bool CtrlKey();
106 bool ShiftKey();
108 void InitTouchEvent(const nsAString& aType,
109 bool aCanBubble,
110 bool aCancelable,
111 nsIDOMWindow* aView,
112 int32_t aDetail,
113 bool aCtrlKey,
114 bool aAltKey,
115 bool aShiftKey,
116 bool aMetaKey,
117 TouchList* aTouches,
118 TouchList* aTargetTouches,
119 TouchList* aChangedTouches,
120 ErrorResult& aRv);
122 static bool PrefEnabled(JSContext* aCx = nullptr,
123 JSObject* aGlobal = nullptr);
125 protected:
126 ~TouchEvent() {}
128 nsRefPtr<TouchList> mTouches;
129 nsRefPtr<TouchList> mTargetTouches;
130 nsRefPtr<TouchList> mChangedTouches;
133 } // namespace dom
134 } // namespace mozilla
136 #endif // mozilla_dom_TouchEvent_h_