Touch.h (3512B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_Touch_h_ 8 #define mozilla_dom_Touch_h_ 9 10 #include "Units.h" 11 #include "mozilla/EventForwards.h" 12 #include "mozilla/MouseEvents.h" 13 #include "mozilla/dom/BindingDeclarations.h" 14 #include "mozilla/dom/TouchBinding.h" 15 #include "nsWrapperCache.h" 16 17 class nsPresContext; 18 19 namespace mozilla::dom { 20 21 class EventTarget; 22 23 class Touch final : public nsISupports, 24 public nsWrapperCache, 25 public WidgetPointerHelper { 26 public: 27 static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal); 28 29 static already_AddRefed<Touch> Constructor(const GlobalObject& aGlobal, 30 const TouchInit& aParam); 31 32 Touch(EventTarget* aTarget, int32_t aIdentifier, int32_t aPageX, 33 int32_t aPageY, int32_t aScreenX, int32_t aScreenY, int32_t aClientX, 34 int32_t aClientY, int32_t aRadiusX, int32_t aRadiusY, 35 float aRotationAngle, float aForce); 36 Touch(int32_t aIdentifier, LayoutDeviceIntPoint aPoint, 37 LayoutDeviceIntPoint aRadius, float aRotationAngle, float aForce); 38 Touch(int32_t aIdentifier, LayoutDeviceIntPoint aPoint, 39 LayoutDeviceIntPoint aRadius, float aRotationAngle, float aForce, 40 int32_t aTiltX, int32_t aTiltY, int32_t aTwist); 41 Touch(const Touch& aOther); 42 43 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 44 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(Touch) 45 46 void InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent); 47 48 // Note, this sets both mOriginalTarget and mTarget. 49 void SetTouchTarget(EventTarget* aTarget); 50 51 bool Equals(Touch* aTouch) const; 52 53 // Update this touch's touch area to be the same as aTouch 54 void SetSameAs(const Touch* aTouch); 55 56 virtual JSObject* WrapObject(JSContext* aCx, 57 JS::Handle<JSObject*> aGivenProto) override; 58 59 nsIGlobalObject* GetParentObject() const; 60 61 // WebIDL 62 int32_t Identifier() const { return mIdentifier; } 63 EventTarget* GetTarget() const; 64 int32_t ScreenX(CallerType aCallerType) const; 65 int32_t ScreenY(CallerType aCallerType) const; 66 int32_t ClientX() const { return mClientPoint.x; } 67 int32_t ClientY() const { return mClientPoint.y; } 68 int32_t PageX() const { return mPagePoint.x; } 69 int32_t PageY() const { return mPagePoint.y; } 70 int32_t RadiusX(CallerType aCallerType) const; 71 int32_t RadiusY(CallerType aCallerType) const; 72 float RotationAngle(CallerType aCallerType) const; 73 float Force(CallerType aCallerType) const; 74 75 EventTarget* GetOriginalTarget() const; 76 77 nsCOMPtr<EventTarget> mOriginalTarget; 78 nsCOMPtr<EventTarget> mTarget; 79 LayoutDeviceIntPoint mRefPoint; 80 bool mChanged; 81 82 // Is this touch instance being suppressed to dispatch touch event to content. 83 // We can't remove touch instance from WidgetTouchEvent::mTouches because we 84 // still need it when dispatching pointer events. 85 bool mIsTouchEventSuppressed; 86 87 uint32_t mMessage; 88 int32_t mIdentifier; 89 CSSIntPoint mPagePoint; 90 CSSIntPoint mClientPoint; 91 CSSIntPoint mScreenPoint; 92 LayoutDeviceIntPoint mRadius; 93 float mRotationAngle; 94 float mForce; 95 96 protected: 97 ~Touch(); 98 99 bool mPointsInitialized; 100 }; 101 102 } // namespace mozilla::dom 103 104 #endif // mozilla_dom_Touch_h_