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"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2013-07-10 13:53:53 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2011-04-26 16:30:17 +04:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:26:38 +03:00
|
|
|
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
|
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
|
|
|
}
|
|
|
|
|
2018-05-25 18:02:59 +03:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
mPoints.Clear();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-12-29 16:46:18 +03:00
|
|
|
already_AddRefed<TouchList>
|
|
|
|
CopyTouches(const Sequence<OwningNonNull<Touch>>& aTouches);
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchList* Touches();
|
2018-05-25 18:02:59 +03:00
|
|
|
// TargetTouches() populates mTargetTouches from widget event's touch list.
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchList* TargetTouches();
|
2018-05-25 18:02:59 +03:00
|
|
|
// GetExistingTargetTouches just returns the existing target touches list.
|
|
|
|
TouchList* GetExistingTargetTouches()
|
|
|
|
{
|
|
|
|
return mTargetTouches;
|
|
|
|
}
|
2014-02-28 18:58:42 +04:00
|
|
|
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,
|
2017-11-07 01:52:14 +03:00
|
|
|
nsGlobalWindowInner* aView,
|
2013-04-16 00:33:46 +04:00
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
2014-02-28 18:58:42 +04:00
|
|
|
TouchList* aTouches,
|
|
|
|
TouchList* aTargetTouches,
|
2015-11-13 03:09:42 +03:00
|
|
|
TouchList* aChangedTouches);
|
2013-04-16 00:33:46 +04:00
|
|
|
|
2018-06-14 00:52:19 +03:00
|
|
|
static bool PlatformSupportsTouch();
|
2016-07-18 17:26:38 +03:00
|
|
|
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
|
|
|
|
static bool PrefEnabled(nsIDocShell* aDocShell);
|
2014-07-09 01:23:17 +04:00
|
|
|
|
2018-04-04 22:32:19 +03:00
|
|
|
static already_AddRefed<TouchEvent> Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const TouchEventInit& aParam,
|
|
|
|
ErrorResult& aRv);
|
2015-12-29 16:46:18 +03:00
|
|
|
|
2011-04-26 16:30:17 +04:00
|
|
|
protected:
|
2014-07-09 01:23:17 +04:00
|
|
|
~TouchEvent() {}
|
|
|
|
|
2018-05-25 18:02:59 +03:00
|
|
|
void AssignTouchesToWidgetEvent(TouchList* aList, bool aCheckDuplicates);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TouchList> mTouches;
|
|
|
|
RefPtr<TouchList> mTargetTouches;
|
|
|
|
RefPtr<TouchList> mChangedTouches;
|
2011-04-26 16:30:17 +04:00
|
|
|
};
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<mozilla::dom::TouchEvent>
|
|
|
|
NS_NewDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
mozilla::WidgetTouchEvent* aEvent);
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
#endif // mozilla_dom_TouchEvent_h_
|