dom/events/XULCommandEvent.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5ded8d42bc7b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 // This class implements a XUL "command" event. See nsIDOMXULCommandEvent.idl
8
9 #ifndef mozilla_dom_XULCommandEvent_h_
10 #define mozilla_dom_XULCommandEvent_h_
11
12 #include "mozilla/dom/UIEvent.h"
13 #include "mozilla/dom/XULCommandEventBinding.h"
14 #include "nsIDOMXULCommandEvent.h"
15
16 namespace mozilla {
17 namespace dom {
18
19 class XULCommandEvent : public UIEvent,
20 public nsIDOMXULCommandEvent
21 {
22 public:
23 XULCommandEvent(EventTarget* aOwner,
24 nsPresContext* aPresContext,
25 WidgetInputEvent* aEvent);
26
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
29 NS_DECL_NSIDOMXULCOMMANDEVENT
30
31 // Forward our inherited virtual methods to the base class
32 NS_FORWARD_TO_UIEVENT
33
34 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
35 {
36 return XULCommandEventBinding::Wrap(aCx, this);
37 }
38
39 bool AltKey();
40 bool CtrlKey();
41 bool ShiftKey();
42 bool MetaKey();
43
44 already_AddRefed<Event> GetSourceEvent()
45 {
46 nsRefPtr<Event> e =
47 mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr;
48 return e.forget();
49 }
50
51 void InitCommandEvent(const nsAString& aType,
52 bool aCanBubble, bool aCancelable,
53 nsIDOMWindow* aView,
54 int32_t aDetail,
55 bool aCtrlKey, bool aAltKey,
56 bool aShiftKey, bool aMetaKey,
57 Event* aSourceEvent,
58 ErrorResult& aRv)
59 {
60 aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aView, aDetail,
61 aCtrlKey, aAltKey, aShiftKey, aMetaKey,
62 aSourceEvent);
63 }
64
65 protected:
66 nsCOMPtr<nsIDOMEvent> mSourceEvent;
67 };
68
69 } // namespace dom
70 } // namespace mozilla
71
72 #endif // mozilla_dom_XULCommandEvent_h_

mercurial