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 : // 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 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
29 : NS_DECL_NSIDOMXULCOMMANDEVENT
30 :
31 : // Forward our inherited virtual methods to the base class
32 0 : NS_FORWARD_TO_UIEVENT
33 :
34 0 : virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
35 : {
36 0 : return XULCommandEventBinding::Wrap(aCx, this, aGivenProto);
37 : }
38 :
39 : bool AltKey();
40 : bool CtrlKey();
41 : bool ShiftKey();
42 : bool MetaKey();
43 :
44 0 : already_AddRefed<Event> GetSourceEvent()
45 : {
46 : RefPtr<Event> e =
47 0 : mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr;
48 0 : return e.forget();
49 : }
50 :
51 0 : void InitCommandEvent(const nsAString& aType,
52 : bool aCanBubble, bool aCancelable,
53 : nsGlobalWindow* aView,
54 : int32_t aDetail,
55 : bool aCtrlKey, bool aAltKey,
56 : bool aShiftKey, bool aMetaKey,
57 : Event* aSourceEvent)
58 : {
59 0 : InitCommandEvent(aType, aCanBubble, aCancelable, aView->AsInner(),
60 : aDetail, aCtrlKey, aAltKey, aShiftKey, aMetaKey,
61 0 : aSourceEvent);
62 0 : }
63 :
64 : protected:
65 0 : ~XULCommandEvent() {}
66 :
67 : nsCOMPtr<nsIDOMEvent> mSourceEvent;
68 : };
69 :
70 : } // namespace dom
71 : } // namespace mozilla
72 :
73 : already_AddRefed<mozilla::dom::XULCommandEvent>
74 : NS_NewDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
75 : nsPresContext* aPresContext,
76 : mozilla::WidgetInputEvent* aEvent);
77 :
78 : #endif // mozilla_dom_XULCommandEvent_h_
|