Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / dom / events / Touch.h
blob815d6a1b05d721f30daafdae51fb04f88a011b38
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/. */
7 #ifndef mozilla_dom_Touch_h_
8 #define mozilla_dom_Touch_h_
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"
18 class nsPresContext;
20 namespace mozilla::dom {
22 class EventTarget;
24 class Touch final : public nsISupports,
25 public nsWrapperCache,
26 public WidgetPointerHelper {
27 public:
28 static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
30 static already_AddRefed<Touch> Constructor(const GlobalObject& aGlobal,
31 const TouchInit& aParam);
33 Touch(EventTarget* aTarget, int32_t aIdentifier, int32_t aPageX,
34 int32_t aPageY, int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
35 int32_t aClientY, int32_t aRadiusX, int32_t aRadiusY,
36 float aRotationAngle, float aForce);
37 Touch(int32_t aIdentifier, LayoutDeviceIntPoint aPoint,
38 LayoutDeviceIntPoint aRadius, float aRotationAngle, float aForce);
39 Touch(const Touch& aOther);
41 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
42 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Touch)
44 void InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent);
46 // Note, this sets both mOriginalTarget and mTarget.
47 void SetTouchTarget(EventTarget* aTarget);
49 bool Equals(Touch* aTouch) const;
51 // Update this touch's touch area to be the same as aTouch
52 void SetSameAs(const Touch* aTouch);
54 virtual JSObject* WrapObject(JSContext* aCx,
55 JS::Handle<JSObject*> aGivenProto) override;
57 nsIGlobalObject* GetParentObject();
59 // WebIDL
60 int32_t Identifier() const { return mIdentifier; }
61 EventTarget* GetTarget() const;
62 int32_t ScreenX(CallerType aCallerType) const;
63 int32_t ScreenY(CallerType aCallerType) const;
64 int32_t ClientX() const { return mClientPoint.x; }
65 int32_t ClientY() const { return mClientPoint.y; }
66 int32_t PageX() const { return mPagePoint.x; }
67 int32_t PageY() const { return mPagePoint.y; }
68 int32_t RadiusX(CallerType aCallerType) const;
69 int32_t RadiusY(CallerType aCallerType) const;
70 float RotationAngle(CallerType aCallerType) const;
71 float Force(CallerType aCallerType) const;
73 nsCOMPtr<EventTarget> mOriginalTarget;
74 nsCOMPtr<EventTarget> mTarget;
75 LayoutDeviceIntPoint mRefPoint;
76 bool mChanged;
78 // Is this touch instance being suppressed to dispatch touch event to content.
79 // We can't remove touch instance from WidgetTouchEvent::mTouches because we
80 // still need it when dispatching pointer events.
81 bool mIsTouchEventSuppressed;
83 uint32_t mMessage;
84 int32_t mIdentifier;
85 CSSIntPoint mPagePoint;
86 CSSIntPoint mClientPoint;
87 CSSIntPoint mScreenPoint;
88 LayoutDeviceIntPoint mRadius;
89 float mRotationAngle;
90 float mForce;
92 protected:
93 ~Touch();
95 bool mPointsInitialized;
98 } // namespace mozilla::dom
100 #endif // mozilla_dom_Touch_h_