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"
|
|
|
|
#include "nsIDOMTouchEvent.h"
|
|
|
|
#include "nsString.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-03-07 10:53:19 -08:00
|
|
|
#include "nsJSEnvironment.h"
|
2013-04-15 13:33:46 -07:00
|
|
|
#include "mozilla/dom/TouchEventBinding.h"
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2012-08-10 11:01:16 -07:00
|
|
|
class nsDOMTouchList MOZ_FINAL : public nsIDOMTouchList
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2012-08-02 10:41:42 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchList)
|
2011-04-26 05:30:17 -07:00
|
|
|
NS_DECL_NSIDOMTOUCHLIST
|
2011-12-16 16:24:11 -08:00
|
|
|
|
2013-03-07 10:53:19 -08:00
|
|
|
nsDOMTouchList()
|
|
|
|
{
|
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
2012-08-02 10:41:42 -07:00
|
|
|
nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches);
|
2012-05-03 10:01:49 -07:00
|
|
|
|
2012-08-02 10:41:42 -07:00
|
|
|
void Append(nsIDOMTouch* 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
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIDOMTouch* GetItemAt(uint32_t aIndex)
|
2012-05-03 10:01:49 -07:00
|
|
|
{
|
2012-08-12 03:43:47 -07:00
|
|
|
return mPoints.SafeElementAt(aIndex, nullptr);
|
2012-05-03 10:01:49 -07:00
|
|
|
}
|
|
|
|
|
2011-04-26 05:30:17 -07:00
|
|
|
protected:
|
2011-12-16 16:24:11 -08:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMTouch> > mPoints;
|
2011-04-26 05:30:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsDOMTouchEvent : public nsDOMUIEvent,
|
|
|
|
public nsIDOMTouchEvent
|
|
|
|
{
|
|
|
|
public:
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext, nsTouchEvent* aEvent);
|
2011-04-26 05:30:17 -07:00
|
|
|
virtual ~nsDOMTouchEvent();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
|
|
|
|
NS_DECL_NSIDOMTOUCHEVENT
|
|
|
|
|
|
|
|
NS_FORWARD_TO_NSDOMUIEVENT
|
|
|
|
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
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
|
|
|
|
|
|
|
bool AltKey()
|
|
|
|
{
|
|
|
|
return static_cast<nsInputEvent*>(mEvent)->IsAlt();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MetaKey()
|
|
|
|
{
|
|
|
|
return static_cast<nsInputEvent*>(mEvent)->IsMeta();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CtrlKey()
|
|
|
|
{
|
|
|
|
return static_cast<nsInputEvent*>(mEvent)->IsControl();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShiftKey()
|
|
|
|
{
|
|
|
|
return static_cast<nsInputEvent*>(mEvent)->IsShift();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitTouchEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* aView,
|
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
nsIDOMTouchList* aTouches,
|
|
|
|
nsIDOMTouchList* aTargetTouches,
|
|
|
|
nsIDOMTouchList* aChangedTouches,
|
|
|
|
mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = InitTouchEvent(aType, aCanBubble, aCancelable, aView, aDetail,
|
|
|
|
aCtrlKey, aAltKey, aShiftKey, aMetaKey,
|
|
|
|
aTouches, aTargetTouches, aChangedTouches);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool PrefEnabled();
|
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_) */
|