Line data Source code
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 "mozilla/Attributes.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 : #include "Units.h"
17 :
18 : class nsPresContext;
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : class EventTarget;
24 :
25 : class Touch final : public nsISupports
26 : , public nsWrapperCache
27 : , public WidgetPointerHelper
28 : {
29 : public:
30 : static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
31 :
32 : static already_AddRefed<Touch> Constructor(const GlobalObject& aGlobal,
33 : const TouchInit& aParam,
34 : ErrorResult& aRv);
35 :
36 : Touch(EventTarget* aTarget,
37 : int32_t aIdentifier,
38 : int32_t aPageX,
39 : int32_t aPageY,
40 : int32_t aScreenX,
41 : int32_t aScreenY,
42 : int32_t aClientX,
43 : int32_t aClientY,
44 : int32_t aRadiusX,
45 : int32_t aRadiusY,
46 : float aRotationAngle,
47 : float aForce);
48 : Touch(int32_t aIdentifier,
49 : LayoutDeviceIntPoint aPoint,
50 : LayoutDeviceIntPoint aRadius,
51 : float aRotationAngle,
52 : float aForce);
53 : Touch(const Touch& aOther);
54 :
55 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
56 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Touch)
57 :
58 : void InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent);
59 :
60 : void SetTarget(EventTarget* aTarget);
61 :
62 : bool Equals(Touch* aTouch);
63 :
64 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
65 :
66 : nsIGlobalObject* GetParentObject();
67 :
68 : // WebIDL
69 0 : int32_t Identifier() const { return mIdentifier; }
70 : EventTarget* GetTarget() const;
71 : int32_t ScreenX(CallerType aCallerType) const;
72 : int32_t ScreenY(CallerType aCallerType) const;
73 0 : int32_t ClientX() const { return mClientPoint.x; }
74 0 : int32_t ClientY() const { return mClientPoint.y; }
75 0 : int32_t PageX() const { return mPagePoint.x; }
76 0 : int32_t PageY() const { return mPagePoint.y; }
77 0 : int32_t RadiusX() const { return mRadius.x; }
78 0 : int32_t RadiusY() const { return mRadius.y; }
79 0 : float RotationAngle() const { return mRotationAngle; }
80 0 : float Force() const { return mForce; }
81 :
82 : nsCOMPtr<EventTarget> mTarget;
83 : LayoutDeviceIntPoint mRefPoint;
84 : bool mChanged;
85 : uint32_t mMessage;
86 : int32_t mIdentifier;
87 : CSSIntPoint mPagePoint;
88 : CSSIntPoint mClientPoint;
89 : CSSIntPoint mScreenPoint;
90 : LayoutDeviceIntPoint mRadius;
91 : float mRotationAngle;
92 : float mForce;
93 : protected:
94 : ~Touch();
95 :
96 : bool mPointsInitialized;
97 : };
98 :
99 : } // namespace dom
100 : } // namespace mozilla
101 :
102 : #endif // mozilla_dom_Touch_h_
|