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/. */
|
2014-02-28 06:58:42 -08:00
|
|
|
#ifndef mozilla_dom_TouchEvent_h_
|
|
|
|
#define mozilla_dom_TouchEvent_h_
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
#include "mozilla/dom/Touch.h"
|
|
|
|
#include "mozilla/dom/TouchEventBinding.h"
|
|
|
|
#include "mozilla/dom/UIEvent.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"
|
2014-02-28 06:58:43 -08:00
|
|
|
#include "nsTArray.h"
|
2013-07-10 02:53:53 -07:00
|
|
|
#include "nsWrapperCache.h"
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2013-08-29 14:18:25 -07:00
|
|
|
class nsAString;
|
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-07-10 02:53:09 -07:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
class TouchList MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
2011-04-26 05:30:17 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-02-28 06:58:42 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TouchList)
|
2011-12-16 16:24:11 -08:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
TouchList(nsISupports* aParent)
|
2013-07-10 02:53:53 -07:00
|
|
|
: mParent(aParent)
|
2013-03-07 10:53:19 -08:00
|
|
|
{
|
2013-07-10 02:53:53 -07:00
|
|
|
SetIsDOMBinding();
|
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
2014-02-28 06:58:42 -08:00
|
|
|
TouchList(nsISupports* aParent,
|
|
|
|
const nsTArray<nsRefPtr<Touch> >& aTouches)
|
2013-07-10 02:53:53 -07:00
|
|
|
: 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
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-07-10 02:53:53 -07:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:42 -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;
|
2014-02-28 06:58:42 -08:00
|
|
|
nsTArray<nsRefPtr<Touch> > mPoints;
|
2011-04-26 05:30:17 -07:00
|
|
|
};
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
class TouchEvent : public UIEvent
|
2011-04-26 05:30:17 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-28 06:58:42 -08:00
|
|
|
TouchEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetTouchEvent* aEvent);
|
2011-04-26 05:30:17 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-02-28 06:58:43 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TouchEvent, UIEvent)
|
2011-04-26 05:30:17 -07:00
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
2013-04-15 13:33:46 -07:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return TouchEventBinding::Wrap(aCx, this);
|
2013-04-15 13:33:46 -07:00
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
TouchList* Touches();
|
|
|
|
TouchList* TargetTouches();
|
|
|
|
TouchList* 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,
|
2014-02-28 06:58:42 -08:00
|
|
|
TouchList* aTouches,
|
|
|
|
TouchList* aTargetTouches,
|
|
|
|
TouchList* aChangedTouches,
|
|
|
|
ErrorResult& aRv);
|
2013-04-15 13:33:46 -07:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
static bool PrefEnabled(JSContext* aCx = nullptr,
|
|
|
|
JSObject* aGlobal = nullptr);
|
2011-04-26 05:30:17 -07:00
|
|
|
protected:
|
2014-02-28 06:58:42 -08:00
|
|
|
nsRefPtr<TouchList> mTouches;
|
|
|
|
nsRefPtr<TouchList> mTargetTouches;
|
|
|
|
nsRefPtr<TouchList> mChangedTouches;
|
2011-04-26 05:30:17 -07:00
|
|
|
};
|
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TouchEvent_h_
|