XULCommandEvent.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*- Mode: C++; tab-width: 8; 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. // This class implements a XUL "command" event. See nsIDOMXULCommandEvent.idl
  6. #ifndef mozilla_dom_XULCommandEvent_h_
  7. #define mozilla_dom_XULCommandEvent_h_
  8. #include "mozilla/dom/UIEvent.h"
  9. #include "mozilla/dom/XULCommandEventBinding.h"
  10. #include "nsIDOMXULCommandEvent.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class XULCommandEvent : public UIEvent,
  14. public nsIDOMXULCommandEvent
  15. {
  16. public:
  17. XULCommandEvent(EventTarget* aOwner,
  18. nsPresContext* aPresContext,
  19. WidgetInputEvent* aEvent);
  20. NS_DECL_ISUPPORTS_INHERITED
  21. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
  22. NS_DECL_NSIDOMXULCOMMANDEVENT
  23. // Forward our inherited virtual methods to the base class
  24. NS_FORWARD_TO_UIEVENT
  25. virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
  26. {
  27. return XULCommandEventBinding::Wrap(aCx, this, aGivenProto);
  28. }
  29. bool AltKey();
  30. bool CtrlKey();
  31. bool ShiftKey();
  32. bool MetaKey();
  33. already_AddRefed<Event> GetSourceEvent()
  34. {
  35. RefPtr<Event> e =
  36. mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr;
  37. return e.forget();
  38. }
  39. void InitCommandEvent(const nsAString& aType,
  40. bool aCanBubble, bool aCancelable,
  41. nsGlobalWindow* aView,
  42. int32_t aDetail,
  43. bool aCtrlKey, bool aAltKey,
  44. bool aShiftKey, bool aMetaKey,
  45. Event* aSourceEvent)
  46. {
  47. InitCommandEvent(aType, aCanBubble, aCancelable, aView->AsInner(),
  48. aDetail, aCtrlKey, aAltKey, aShiftKey, aMetaKey,
  49. aSourceEvent);
  50. }
  51. protected:
  52. ~XULCommandEvent() {}
  53. nsCOMPtr<nsIDOMEvent> mSourceEvent;
  54. };
  55. } // namespace dom
  56. } // namespace mozilla
  57. already_AddRefed<mozilla::dom::XULCommandEvent>
  58. NS_NewDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
  59. nsPresContext* aPresContext,
  60. mozilla::WidgetInputEvent* aEvent);
  61. #endif // mozilla_dom_XULCommandEvent_h_