/work/obj-fuzz/dist/include/mozilla/dom/UIEvent.h
Line | Count | Source (jump to first uncovered line) |
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_UIEvent_h_ |
8 | | #define mozilla_dom_UIEvent_h_ |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/Event.h" |
12 | | #include "mozilla/dom/UIEventBinding.h" |
13 | | #include "nsDeviceContext.h" |
14 | | #include "nsLayoutUtils.h" |
15 | | #include "nsPresContext.h" |
16 | | |
17 | | class nsINode; |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | class UIEvent : public Event |
23 | | { |
24 | | public: |
25 | | UIEvent(EventTarget* aOwner, |
26 | | nsPresContext* aPresContext, |
27 | | WidgetGUIEvent* aEvent); |
28 | | |
29 | | NS_DECL_ISUPPORTS_INHERITED |
30 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, Event) |
31 | | |
32 | | void DuplicatePrivateData() override; |
33 | | void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; |
34 | | bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; |
35 | | |
36 | | static already_AddRefed<UIEvent> Constructor(const GlobalObject& aGlobal, |
37 | | const nsAString& aType, |
38 | | const UIEventInit& aParam, |
39 | | ErrorResult& aRv); |
40 | | |
41 | | virtual JSObject* |
42 | | WrapObjectInternal(JSContext* aCx, |
43 | | JS::Handle<JSObject*> aGivenProto) override |
44 | 0 | { |
45 | 0 | return UIEvent_Binding::Wrap(aCx, this, aGivenProto); |
46 | 0 | } |
47 | | |
48 | | UIEvent* AsUIEvent() override |
49 | 0 | { |
50 | 0 | return this; |
51 | 0 | } |
52 | | |
53 | | void InitUIEvent(const nsAString& typeArg, |
54 | | bool canBubbleArg, |
55 | | bool cancelableArg, |
56 | | nsGlobalWindowInner* viewArg, |
57 | | int32_t detailArg); |
58 | | |
59 | | nsPIDOMWindowOuter* GetView() const |
60 | 0 | { |
61 | 0 | return mView; |
62 | 0 | } |
63 | | |
64 | | int32_t Detail() const |
65 | 0 | { |
66 | 0 | return mDetail; |
67 | 0 | } |
68 | | |
69 | | int32_t LayerX() const |
70 | 0 | { |
71 | 0 | return GetLayerPoint().x; |
72 | 0 | } |
73 | | |
74 | | int32_t LayerY() const |
75 | 0 | { |
76 | 0 | return GetLayerPoint().y; |
77 | 0 | } |
78 | | |
79 | | int32_t PageX() const; |
80 | | int32_t PageY() const; |
81 | | |
82 | | virtual uint32_t Which(CallerType aCallerType = CallerType::System) |
83 | 0 | { |
84 | 0 | MOZ_ASSERT(mEvent->mClass != eKeyboardEventClass, |
85 | 0 | "Key events should override Which()"); |
86 | 0 | MOZ_ASSERT(mEvent->mClass != eMouseEventClass, |
87 | 0 | "Mouse events should override Which()"); |
88 | 0 | return 0; |
89 | 0 | } |
90 | | |
91 | | already_AddRefed<nsINode> GetRangeParent(); |
92 | | |
93 | | int32_t RangeOffset() const; |
94 | | |
95 | | protected: |
96 | 0 | ~UIEvent() {} |
97 | | |
98 | | // Internal helper functions |
99 | | nsIntPoint GetMovementPoint(); |
100 | | nsIntPoint GetLayerPoint() const; |
101 | | |
102 | | nsCOMPtr<nsPIDOMWindowOuter> mView; |
103 | | int32_t mDetail; |
104 | | CSSIntPoint mClientPoint; |
105 | | // Screenpoint is mEvent->mRefPoint. |
106 | | nsIntPoint mLayerPoint; |
107 | | CSSIntPoint mPagePoint; |
108 | | nsIntPoint mMovementPoint; |
109 | | bool mIsPointerLocked; |
110 | | CSSIntPoint mLastClientPoint; |
111 | | |
112 | | static Modifiers ComputeModifierState(const nsAString& aModifiersList); |
113 | | bool GetModifierStateInternal(const nsAString& aKey); |
114 | | void InitModifiers(const EventModifierInit& aParam); |
115 | | }; |
116 | | |
117 | | } // namespace dom |
118 | | } // namespace mozilla |
119 | | |
120 | | already_AddRefed<mozilla::dom::UIEvent> |
121 | | NS_NewDOMUIEvent(mozilla::dom::EventTarget* aOwner, |
122 | | nsPresContext* aPresContext, |
123 | | mozilla::WidgetGUIEvent* aEvent); |
124 | | |
125 | | #endif // mozilla_dom_UIEvent_h_ |