dom/events/KeyboardEvent.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:67c3e564b861
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef mozilla_dom_KeyboardEvent_h_
7 #define mozilla_dom_KeyboardEvent_h_
8
9 #include "mozilla/dom/UIEvent.h"
10 #include "mozilla/dom/KeyboardEventBinding.h"
11 #include "mozilla/EventForwards.h"
12 #include "nsIDOMKeyEvent.h"
13
14 namespace mozilla {
15 namespace dom {
16
17 class KeyboardEvent : public UIEvent,
18 public nsIDOMKeyEvent
19 {
20 public:
21 KeyboardEvent(EventTarget* aOwner,
22 nsPresContext* aPresContext,
23 WidgetKeyboardEvent* aEvent);
24
25 NS_DECL_ISUPPORTS_INHERITED
26
27 // nsIDOMKeyEvent Interface
28 NS_DECL_NSIDOMKEYEVENT
29
30 // Forward to base class
31 NS_FORWARD_TO_UIEVENT
32
33 static already_AddRefed<KeyboardEvent> Constructor(
34 const GlobalObject& aGlobal,
35 const nsAString& aType,
36 const KeyboardEventInit& aParam,
37 ErrorResult& aRv);
38
39 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
40 {
41 return KeyboardEventBinding::Wrap(aCx, this);
42 }
43
44 bool AltKey();
45 bool CtrlKey();
46 bool ShiftKey();
47 bool MetaKey();
48
49 bool GetModifierState(const nsAString& aKey)
50 {
51 return GetModifierStateInternal(aKey);
52 }
53
54 bool Repeat();
55 bool IsComposing();
56 uint32_t CharCode();
57 uint32_t KeyCode();
58 virtual uint32_t Which() MOZ_OVERRIDE;
59 uint32_t Location();
60
61 void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
62 nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
63 bool aShiftKey, bool aMetaKey,
64 uint32_t aKeyCode, uint32_t aCharCode,
65 ErrorResult& aRv)
66 {
67 aRv = InitKeyEvent(aType, aCanBubble, aCancelable, aView,
68 aCtrlKey, aAltKey, aShiftKey,aMetaKey,
69 aKeyCode, aCharCode);
70 }
71
72 private:
73 // True, if the instance is created with Constructor().
74 bool mInitializedByCtor;
75 // If the instance is created with Constructor(), which may have independent
76 // value. mInitializedWhichValue stores it. I.e., this is invalid when
77 // mInitializedByCtor is false.
78 uint32_t mInitialzedWhichValue;
79 };
80
81 } // namespace dom
82 } // namespace mozilla
83
84 #endif // mozilla_dom_KeyboardEvent_h_

mercurial