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_MouseEvent_h_
8 : #define mozilla_dom_MouseEvent_h_
9 :
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/UIEvent.h"
12 : #include "mozilla/dom/MouseEventBinding.h"
13 : #include "mozilla/EventForwards.h"
14 : #include "nsIDOMMouseEvent.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class MouseEvent : public UIEvent,
20 : public nsIDOMMouseEvent
21 : {
22 : public:
23 : MouseEvent(EventTarget* aOwner,
24 : nsPresContext* aPresContext,
25 : WidgetMouseEventBase* aEvent);
26 :
27 : NS_DECL_ISUPPORTS_INHERITED
28 :
29 : // nsIDOMMouseEvent Interface
30 : NS_DECL_NSIDOMMOUSEEVENT
31 :
32 : // Forward to base class
33 25 : NS_FORWARD_TO_UIEVENT
34 :
35 4 : virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
36 : {
37 4 : return MouseEventBinding::Wrap(aCx, this, aGivenProto);
38 : }
39 :
40 : // Web IDL binding methods
41 0 : virtual uint32_t Which() override
42 : {
43 0 : return Button() + 1;
44 : }
45 :
46 : int32_t ScreenX(CallerType aCallerType);
47 : int32_t ScreenY(CallerType aCallerType);
48 : int32_t ClientX();
49 : int32_t ClientY();
50 : int32_t OffsetX();
51 : int32_t OffsetY();
52 : bool CtrlKey();
53 : bool ShiftKey();
54 : bool AltKey();
55 : bool MetaKey();
56 : int16_t Button();
57 : uint16_t Buttons();
58 : already_AddRefed<EventTarget> GetRelatedTarget();
59 : void GetRegion(nsAString& aRegion);
60 : void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
61 : nsGlobalWindow* aView, int32_t aDetail, int32_t aScreenX,
62 : int32_t aScreenY, int32_t aClientX, int32_t aClientY,
63 : bool aCtrlKey, bool aAltKey, bool aShiftKey,
64 : bool aMetaKey, uint16_t aButton,
65 : EventTarget* aRelatedTarget);
66 :
67 : void InitializeExtraMouseEventDictionaryMembers(const MouseEventInit& aParam);
68 :
69 0 : bool GetModifierState(const nsAString& aKeyArg)
70 : {
71 0 : return GetModifierStateInternal(aKeyArg);
72 : }
73 : static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal,
74 : const nsAString& aType,
75 : const MouseEventInit& aParam,
76 : ErrorResult& aRv);
77 0 : int32_t MovementX()
78 : {
79 0 : return GetMovementPoint().x;
80 : }
81 0 : int32_t MovementY()
82 : {
83 0 : return GetMovementPoint().y;
84 : }
85 : float MozPressure() const;
86 : bool HitCluster() const;
87 : uint16_t MozInputSource() const;
88 : void InitNSMouseEvent(const nsAString& aType,
89 : bool aCanBubble, bool aCancelable,
90 : nsGlobalWindow* aView, int32_t aDetail,
91 : int32_t aScreenX, int32_t aScreenY,
92 : int32_t aClientX, int32_t aClientY,
93 : bool aCtrlKey, bool aAltKey, bool aShiftKey,
94 : bool aMetaKey, uint16_t aButton,
95 : EventTarget* aRelatedTarget,
96 : float aPressure, uint16_t aInputSource);
97 :
98 : protected:
99 3 : ~MouseEvent() {}
100 :
101 : void InitMouseEvent(const nsAString& aType,
102 : bool aCanBubble,
103 : bool aCancelable,
104 : nsGlobalWindow* aView,
105 : int32_t aDetail,
106 : int32_t aScreenX,
107 : int32_t aScreenY,
108 : int32_t aClientX,
109 : int32_t aClientY,
110 : int16_t aButton,
111 : EventTarget* aRelatedTarget,
112 : const nsAString& aModifiersList);
113 : };
114 :
115 : } // namespace dom
116 : } // namespace mozilla
117 :
118 : #define NS_FORWARD_TO_MOUSEEVENT \
119 : NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \
120 : NS_FORWARD_TO_UIEVENT
121 :
122 : already_AddRefed<mozilla::dom::MouseEvent>
123 : NS_NewDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
124 : nsPresContext* aPresContext,
125 : mozilla::WidgetMouseEvent* aEvent);
126 :
127 : #endif // mozilla_dom_MouseEvent_h_
|