Bug 1863873 - Block ability to perform audio decoding outside of Utility on release...
[gecko.git] / dom / events / MouseEvent.h
blob0695c1e264b4797b33aa54830c6124e7aa501ba9
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 {
18 public:
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 {
33 return Button() + 1;
36 already_AddRefed<nsIScreen> GetScreen();
38 // In CSS coords.
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; }
61 bool CtrlKey();
62 bool ShiftKey();
63 bool AltKey();
64 bool MetaKey();
65 int16_t Button();
66 uint16_t Buttons();
67 already_AddRefed<EventTarget> GetRelatedTarget();
68 void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
69 nsGlobalWindowInner* aView, int32_t aDetail,
70 int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
71 int32_t aClientY, bool aCtrlKey, bool aAltKey,
72 bool aShiftKey, bool aMetaKey, uint16_t aButton,
73 EventTarget* aRelatedTarget);
75 void InitializeExtraMouseEventDictionaryMembers(const MouseEventInit& aParam);
77 bool GetModifierState(const nsAString& aKeyArg) {
78 return GetModifierStateInternal(aKeyArg);
80 static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal,
81 const nsAString& aType,
82 const MouseEventInit& aParam);
83 int32_t MovementX() { return GetMovementPoint().x; }
84 int32_t MovementY() { return GetMovementPoint().y; }
85 float MozPressure() const;
86 uint16_t InputSource() const;
87 void InitNSMouseEvent(const nsAString& aType, bool aCanBubble,
88 bool aCancelable, nsGlobalWindowInner* aView,
89 int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
90 int32_t aClientX, int32_t aClientY, bool aCtrlKey,
91 bool aAltKey, bool aShiftKey, bool aMetaKey,
92 uint16_t aButton, EventTarget* aRelatedTarget,
93 float aPressure, uint16_t aInputSource);
94 void PreventClickEvent();
95 bool ClickEventPrevented();
97 protected:
98 ~MouseEvent() = default;
100 void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
101 nsGlobalWindowInner* aView, int32_t aDetail,
102 int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
103 int32_t aClientY, int16_t aButton,
104 EventTarget* aRelatedTarget,
105 const nsAString& aModifiersList);
108 } // namespace mozilla::dom
110 already_AddRefed<mozilla::dom::MouseEvent> NS_NewDOMMouseEvent(
111 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
112 mozilla::WidgetMouseEvent* aEvent);
114 #endif // mozilla_dom_MouseEvent_h_