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"
22 class TouchList MOZ_FINAL
: public nsISupports
23 , public nsWrapperCache
26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TouchList
)
29 TouchList(nsISupports
* aParent
)
33 nsJSContext::LikelyShortLivingObjectCreated();
35 TouchList(nsISupports
* aParent
,
36 const WidgetTouchEvent::TouchArray
& aTouches
)
41 nsJSContext::LikelyShortLivingObjectCreated();
44 void Append(Touch
* aPoint
)
46 mPoints
.AppendElement(aPoint
);
49 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
51 nsISupports
* GetParentObject() const
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();
73 return mPoints
[aIndex
];
75 Touch
* IdentifiedTouch(int32_t aIdentifier
) const;
80 nsCOMPtr
<nsISupports
> mParent
;
81 WidgetTouchEvent::TouchArray mPoints
;
84 class TouchEvent
: public UIEvent
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);
100 TouchList
* TargetTouches();
101 TouchList
* ChangedTouches();
108 void InitTouchEvent(const nsAString
& aType
,
118 TouchList
* aTargetTouches
,
119 TouchList
* aChangedTouches
,
122 static bool PrefEnabled(JSContext
* aCx
= nullptr,
123 JSObject
* aGlobal
= nullptr);
128 nsRefPtr
<TouchList
> mTouches
;
129 nsRefPtr
<TouchList
> mTargetTouches
;
130 nsRefPtr
<TouchList
> mChangedTouches
;
134 } // namespace mozilla
136 #endif // mozilla_dom_TouchEvent_h_