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_MouseEvent_h_
8 #define mozilla_dom_MouseEvent_h_
10 #include "mozilla/dom/BindingDeclarations.h"
11 #include "mozilla/dom/UIEvent.h"
12 #include "mozilla/dom/MouseEventBinding.h"
13 #include "mozilla/EventForwards.h"
15 namespace mozilla::dom
{
17 class MouseEvent
: public UIEvent
{
19 MouseEvent(EventTarget
* aOwner
, nsPresContext
* aPresContext
,
20 WidgetMouseEventBase
* aEvent
);
22 NS_INLINE_DECL_REFCOUNTING_INHERITED(MouseEvent
, UIEvent
)
24 virtual JSObject
* WrapObjectInternal(
25 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) override
{
26 return MouseEvent_Binding::Wrap(aCx
, this, aGivenProto
);
29 virtual MouseEvent
* AsMouseEvent() override
{ return this; }
31 // Web IDL binding methods
32 virtual uint32_t Which(CallerType aCallerType
) override
{
36 already_AddRefed
<nsIScreen
> GetScreen();
39 CSSIntPoint
ScreenPoint(CallerType
) const;
40 int32_t ScreenX(CallerType aCallerType
) const {
41 return ScreenPoint(aCallerType
).x
;
43 int32_t ScreenY(CallerType aCallerType
) const {
44 return ScreenPoint(aCallerType
).y
;
46 LayoutDeviceIntPoint
ScreenPointLayoutDevicePix() const;
47 DesktopIntPoint
ScreenPointDesktopPix() const;
49 CSSIntPoint
PagePoint() const;
50 int32_t PageX() const { return PagePoint().x
; }
51 int32_t PageY() const { return PagePoint().y
; }
53 CSSIntPoint
ClientPoint() const;
54 int32_t ClientX() const { return ClientPoint().x
; }
55 int32_t ClientY() const { return ClientPoint().y
; }
57 CSSIntPoint
OffsetPoint() const;
58 int32_t OffsetX() const { return OffsetPoint().x
; }
59 int32_t OffsetY() const { return OffsetPoint().y
; }
67 already_AddRefed
<EventTarget
> GetRelatedTarget();
68 void GetRegion(nsAString
& aRegion
);
69 void InitMouseEvent(const nsAString
& aType
, bool aCanBubble
, bool aCancelable
,
70 nsGlobalWindowInner
* aView
, int32_t aDetail
,
71 int32_t aScreenX
, int32_t aScreenY
, int32_t aClientX
,
72 int32_t aClientY
, bool aCtrlKey
, bool aAltKey
,
73 bool aShiftKey
, bool aMetaKey
, uint16_t aButton
,
74 EventTarget
* aRelatedTarget
);
76 void InitializeExtraMouseEventDictionaryMembers(const MouseEventInit
& aParam
);
78 bool GetModifierState(const nsAString
& aKeyArg
) {
79 return GetModifierStateInternal(aKeyArg
);
81 static already_AddRefed
<MouseEvent
> Constructor(const GlobalObject
& aGlobal
,
82 const nsAString
& aType
,
83 const MouseEventInit
& aParam
);
84 int32_t MovementX() { return GetMovementPoint().x
; }
85 int32_t MovementY() { return GetMovementPoint().y
; }
86 float MozPressure() const;
87 uint16_t MozInputSource() const;
88 void InitNSMouseEvent(const nsAString
& aType
, bool aCanBubble
,
89 bool aCancelable
, nsGlobalWindowInner
* aView
,
90 int32_t aDetail
, int32_t aScreenX
, int32_t aScreenY
,
91 int32_t aClientX
, int32_t aClientY
, bool aCtrlKey
,
92 bool aAltKey
, bool aShiftKey
, bool aMetaKey
,
93 uint16_t aButton
, EventTarget
* aRelatedTarget
,
94 float aPressure
, uint16_t aInputSource
);
95 void PreventClickEvent();
96 bool ClickEventPrevented();
99 ~MouseEvent() = default;
101 void InitMouseEvent(const nsAString
& aType
, bool aCanBubble
, bool aCancelable
,
102 nsGlobalWindowInner
* aView
, int32_t aDetail
,
103 int32_t aScreenX
, int32_t aScreenY
, int32_t aClientX
,
104 int32_t aClientY
, int16_t aButton
,
105 EventTarget
* aRelatedTarget
,
106 const nsAString
& aModifiersList
);
109 } // namespace mozilla::dom
111 already_AddRefed
<mozilla::dom::MouseEvent
> NS_NewDOMMouseEvent(
112 mozilla::dom::EventTarget
* aOwner
, nsPresContext
* aPresContext
,
113 mozilla::WidgetMouseEvent
* aEvent
);
115 #endif // mozilla_dom_MouseEvent_h_