2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 18:58:42 +04:00
|
|
|
#ifndef mozilla_dom_TouchEvent_h_
|
|
|
|
#define mozilla_dom_TouchEvent_h_
|
2011-04-26 16:30:17 +04:00
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
#include "mozilla/dom/Touch.h"
|
|
|
|
#include "mozilla/dom/TouchEventBinding.h"
|
|
|
|
#include "mozilla/dom/UIEvent.h"
|
2012-06-19 06:30:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-18 10:10:26 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2014-07-09 20:17:05 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
2013-03-07 22:53:19 +04:00
|
|
|
#include "nsJSEnvironment.h"
|
2013-07-10 13:53:53 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2011-04-26 16:30:17 +04:00
|
|
|
|
2013-08-30 01:18:25 +04:00
|
|
|
class nsAString;
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-07-10 13:53:09 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TouchList final : public nsISupports
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsWrapperCache
|
2014-02-28 18:58:42 +04:00
|
|
|
{
|
2011-04-26 16:30:17 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2014-02-28 18:58:42 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TouchList)
|
2011-12-17 04:24:11 +04:00
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit TouchList(nsISupports* aParent)
|
2013-07-10 13:53:53 +04:00
|
|
|
: mParent(aParent)
|
2013-03-07 22:53:19 +04:00
|
|
|
{
|
2013-07-10 13:53:53 +04:00
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchList(nsISupports* aParent,
|
2014-07-09 20:17:05 +04:00
|
|
|
const WidgetTouchEvent::TouchArray& aTouches)
|
2013-07-10 13:53:53 +04:00
|
|
|
: mParent(aParent)
|
|
|
|
, mPoints(aTouches)
|
|
|
|
{
|
2013-03-07 22:53:19 +04:00
|
|
|
nsJSContext::LikelyShortLivingObjectCreated();
|
|
|
|
}
|
2012-05-03 21:01:49 +04:00
|
|
|
|
2013-07-10 13:53:09 +04:00
|
|
|
void Append(Touch* aPoint)
|
2012-04-24 18:51:56 +04:00
|
|
|
{
|
2012-08-02 21:41:42 +04:00
|
|
|
mPoints.AppendElement(aPoint);
|
2012-04-24 18:51:56 +04:00
|
|
|
}
|
2012-05-03 21:01:49 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-07-10 13:53:53 +04:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
static bool PrefEnabled(JSContext* aCx = nullptr,
|
|
|
|
JSObject* aGlobal = nullptr);
|
2013-07-10 13:53:53 +04: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 21:01:49 +04:00
|
|
|
{
|
2013-07-10 13:53:53 +04:00
|
|
|
aFound = aIndex < mPoints.Length();
|
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mPoints[aIndex];
|
2012-05-03 21:01:49 +04:00
|
|
|
}
|
2013-07-10 13:53:53 +04:00
|
|
|
Touch* IdentifiedTouch(int32_t aIdentifier) const;
|
2012-05-03 21:01:49 +04:00
|
|
|
|
2011-04-26 16:30:17 +04:00
|
|
|
protected:
|
2014-06-23 23:56:07 +04:00
|
|
|
~TouchList() {}
|
|
|
|
|
2013-07-10 13:53:53 +04:00
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2014-07-09 20:17:05 +04:00
|
|
|
WidgetTouchEvent::TouchArray mPoints;
|
2011-04-26 16:30:17 +04:00
|
|
|
};
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
class TouchEvent : public UIEvent
|
2011-04-26 16:30:17 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetTouchEvent* aEvent);
|
2011-04-26 16:30:17 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TouchEvent, UIEvent)
|
2011-04-26 16:30:17 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
2013-04-16 00:33:46 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return TouchEventBinding::Wrap(aCx, this, aGivenProto);
|
2013-04-16 00:33:46 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchList* Touches();
|
|
|
|
TouchList* TargetTouches();
|
|
|
|
TouchList* ChangedTouches();
|
2013-04-16 00:33:46 +04:00
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool AltKey();
|
|
|
|
bool MetaKey();
|
|
|
|
bool CtrlKey();
|
|
|
|
bool ShiftKey();
|
2013-04-16 00:33:46 +04: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 18:58:42 +04:00
|
|
|
TouchList* aTouches,
|
|
|
|
TouchList* aTargetTouches,
|
|
|
|
TouchList* aChangedTouches,
|
|
|
|
ErrorResult& aRv);
|
2013-04-16 00:33:46 +04:00
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
static bool PrefEnabled(JSContext* aCx = nullptr,
|
|
|
|
JSObject* aGlobal = nullptr);
|
2014-07-09 01:23:17 +04:00
|
|
|
|
2011-04-26 16:30:17 +04:00
|
|
|
protected:
|
2014-07-09 01:23:17 +04:00
|
|
|
~TouchEvent() {}
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
nsRefPtr<TouchList> mTouches;
|
|
|
|
nsRefPtr<TouchList> mTargetTouches;
|
|
|
|
nsRefPtr<TouchList> mChangedTouches;
|
2011-04-26 16:30:17 +04:00
|
|
|
};
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TouchEvent_h_
|