Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / events / PointerEvent.h
blobb2c8de7d13e7a56e51cdab93b613f6720c6a3dbf
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 * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
9 #ifndef mozilla_dom_PointerEvent_h_
10 #define mozilla_dom_PointerEvent_h_
12 #include "mozilla/dom/MouseEvent.h"
13 #include "mozilla/dom/PointerEventBinding.h"
14 #include "mozilla/Maybe.h"
16 class nsPresContext;
18 namespace mozilla::dom {
20 struct PointerEventInit;
22 class PointerEvent : public MouseEvent {
23 public:
24 PointerEvent(EventTarget* aOwner, nsPresContext* aPresContext,
25 WidgetPointerEvent* aEvent);
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PointerEvent, MouseEvent)
30 virtual JSObject* WrapObjectInternal(
31 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
33 static already_AddRefed<PointerEvent> Constructor(
34 const GlobalObject& aGlobal, const nsAString& aType,
35 const PointerEventInit& aParam);
37 static already_AddRefed<PointerEvent> Constructor(
38 EventTarget* aOwner, const nsAString& aType,
39 const PointerEventInit& aParam);
41 int32_t PointerId();
42 int32_t Width();
43 int32_t Height();
44 float Pressure();
45 float TangentialPressure();
46 int32_t TiltX();
47 int32_t TiltY();
48 int32_t Twist();
49 bool IsPrimary();
50 void GetPointerType(nsAString& aPointerType);
51 static bool EnableGetCoalescedEvents(JSContext* aCx, JSObject* aGlobal);
52 void GetCoalescedEvents(nsTArray<RefPtr<PointerEvent>>& aPointerEvents);
53 void GetPredictedEvents(nsTArray<RefPtr<PointerEvent>>& aPointerEvents);
55 protected:
56 ~PointerEvent() = default;
58 private:
59 // This method returns the boolean to indicate whether spoofing pointer
60 // event for fingerprinting resistance.
61 bool ShouldResistFingerprinting();
63 nsTArray<RefPtr<PointerEvent>> mCoalescedEvents;
64 nsTArray<RefPtr<PointerEvent>> mPredictedEvents;
66 // This is used to store the pointerType assigned from constructor.
67 Maybe<nsString> mPointerType;
70 void ConvertPointerTypeToString(uint16_t aPointerTypeSrc,
71 nsAString& aPointerTypeDest);
73 } // namespace mozilla::dom
75 already_AddRefed<mozilla::dom::PointerEvent> NS_NewDOMPointerEvent(
76 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
77 mozilla::WidgetPointerEvent* aEvent);
79 #endif // mozilla_dom_PointerEvent_h_