2011-04-26 05:30:17 -07:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-04-26 05:30:17 -07:00
|
|
|
#ifndef nsDOMTouchEvent_h_
|
|
|
|
#define nsDOMTouchEvent_h_
|
|
|
|
|
|
|
|
#include "nsDOMUIEvent.h"
|
2011-12-16 16:24:11 -08:00
|
|
|
#include "nsTArray.h"
|
2012-06-18 19:30:09 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-17 23:10:26 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-03-07 10:53:19 -08:00
|
|
|
#include "nsJSEnvironment.h"
|
2013-10-17 23:10:26 -07:00
|
|
|
#include "mozilla/dom/Touch.h"
|
2013-04-15 13:33:46 -07:00
|
|
|
#include "mozilla/dom/TouchEventBinding.h"
|
2013-07-10 02:53:53 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2013-09-25 04:21:16 -07:00
|
|
|
|
2013-08-29 14:18:25 -07:00
|
|
|
class nsAString;
|
|
|
|
|
2013-08-04 21:51:21 -07:00
|
|
|
class nsDOMTouchList MOZ_FINAL : public nsISupports
|
2013-07-10 02:53:53 -07:00
|
|
|
, public nsWrapperCache
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
2013-07-10 02:53:09 -07:00
|
|
|
typedef mozilla::dom::Touch Touch;
|
|
|
|
|
2011-04-26 05:30:17 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-07-10 02:53:53 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTouchList)
|
2011-12-16 16:24:11 -08:00
|
|
|
|
2013-07-10 02:53:53 -07:00
|
|
|
nsDOMTouchList(nsISupports* aParent)
|
|
|
|
: mParent(aParent)
|
2013-03-07 10:53:19 -08:00
|
|
|
{
|
2013-07-10 02:53:53 -07:00
|
|
|
SetIsDOMBinding();
|
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
|
|
|
nsDOMTouchList(nsISupports* aParent,
|
|
|
|
const nsTArray< nsRefPtr<Touch> >& aTouches)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mPoints(aTouches)
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
2013-03-07 10:53:19 -08:00
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
2012-05-03 10:01:49 -07:00
|
|
|
|
2013-07-10 02:53:09 -07:00
|
|
|
void Append(Touch* aPoint)
|
2012-04-24 07:51:56 -07:00
|
|
|
{
|
2012-08-02 10:41:42 -07:00
|
|
|
mPoints.AppendElement(aPoint);
|
2012-04-24 07:51:56 -07:00
|
|
|
}
|
2012-05-03 10:01:49 -07:00
|
|
|
|
2013-07-10 02:53:53 -07:00
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
2014-02-06 10:28:14 -08:00
|
|
|
static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
|
2013-07-10 02:53:53 -07:00
|
|
|
|
|
|
|
uint32_t Length() const
|
|
|
|
{
|
|
|
|
return mPoints.Length();
|
|
|
|
}
|
|
|
|
Touch* Item(uint32_t aIndex) const
|
|
|
|
{
|
|
|
|
return mPoints.SafeElementAt(aIndex);
|
|
|
|
}
|
|
|
|
Touch* IndexedGetter(uint32_t aIndex, bool& aFound) const
|
2012-05-03 10:01:49 -07:00
|
|
|
{
|
2013-07-10 02:53:53 -07:00
|
|
|
aFound = aIndex < mPoints.Length();
|
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mPoints[aIndex];
|
2012-05-03 10:01:49 -07:00
|
|
|
}
|
2013-07-10 02:53:53 -07:00
|
|
|
Touch* IdentifiedTouch(int32_t aIdentifier) const;
|
2012-05-03 10:01:49 -07:00
|
|
|
|
2011-04-26 05:30:17 -07:00
|
|
|
protected:
|
2013-07-10 02:53:53 -07:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2013-07-10 02:53:09 -07:00
|
|
|
nsTArray< nsRefPtr<Touch> > mPoints;
|
2011-04-26 05:30:17 -07:00
|
|
|
};
|
|
|
|
|
2013-08-04 21:51:21 -07:00
|
|
|
class nsDOMTouchEvent : public nsDOMUIEvent
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
|
2013-09-26 23:20:57 -07:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetTouchEvent* aEvent);
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
|
|
|
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
2013-08-04 21:51:21 -07:00
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
2013-04-15 13:33:46 -07:00
|
|
|
{
|
|
|
|
return mozilla::dom::TouchEventBinding::Wrap(aCx, aScope, this);
|
|
|
|
}
|
|
|
|
|
2013-04-25 23:48:00 -07:00
|
|
|
nsDOMTouchList* Touches();
|
|
|
|
nsDOMTouchList* TargetTouches();
|
|
|
|
nsDOMTouchList* ChangedTouches();
|
2013-04-15 13:33:46 -07:00
|
|
|
|
2013-10-17 23:10:26 -07:00
|
|
|
bool AltKey();
|
|
|
|
bool MetaKey();
|
|
|
|
bool CtrlKey();
|
|
|
|
bool ShiftKey();
|
2013-04-15 13:33:46 -07:00
|
|
|
|
|
|
|
void InitTouchEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* aView,
|
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
2013-08-04 21:51:21 -07:00
|
|
|
nsDOMTouchList* aTouches,
|
|
|
|
nsDOMTouchList* aTargetTouches,
|
|
|
|
nsDOMTouchList* aChangedTouches,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2013-04-15 13:33:46 -07:00
|
|
|
|
2014-02-06 10:28:14 -08:00
|
|
|
static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
|
2011-04-26 05:30:17 -07:00
|
|
|
protected:
|
2013-04-25 23:48:00 -07:00
|
|
|
nsRefPtr<nsDOMTouchList> mTouches;
|
|
|
|
nsRefPtr<nsDOMTouchList> mTargetTouches;
|
|
|
|
nsRefPtr<nsDOMTouchList> mChangedTouches;
|
2011-04-26 05:30:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsDOMTouchEvent_h_) */
|