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"
18 namespace mozilla::dom
{
20 struct PointerEventInit
;
22 class PointerEvent
: public MouseEvent
{
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
);
45 float TangentialPressure();
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
);
56 ~PointerEvent() = default;
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_