tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

XULCommandEvent.h (2154B)


      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 XULCommandEvent.webidl
      8 
      9 #ifndef mozilla_dom_XULCommandEvent_h_
     10 #define mozilla_dom_XULCommandEvent_h_
     11 
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/dom/UIEvent.h"
     14 #include "mozilla/dom/XULCommandEventBinding.h"
     15 
     16 namespace mozilla::dom {
     17 
     18 class XULCommandEvent : public UIEvent {
     19 public:
     20  XULCommandEvent(EventTarget* aOwner, nsPresContext* aPresContext,
     21                  WidgetInputEvent* aEvent);
     22 
     23  NS_DECL_ISUPPORTS_INHERITED
     24  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent)
     25 
     26  virtual JSObject* WrapObjectInternal(
     27      JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override {
     28    return XULCommandEvent_Binding::Wrap(aCx, this, aGivenProto);
     29  }
     30 
     31  virtual XULCommandEvent* AsXULCommandEvent() override { return this; }
     32 
     33  bool AltKey();
     34  bool CtrlKey();
     35  bool ShiftKey();
     36  bool MetaKey();
     37  uint16_t InputSource();
     38  int16_t Button() { return mButton; }
     39 
     40  already_AddRefed<Event> GetSourceEvent() {
     41    RefPtr<Event> e = mSourceEvent;
     42    return e.forget();
     43  }
     44 
     45  void InitCommandEvent(const nsAString& aType, bool aCanBubble,
     46                        bool aCancelable, nsGlobalWindowInner* aView,
     47                        int32_t aDetail, bool aCtrlKey, bool aAltKey,
     48                        bool aShiftKey, bool aMetaKey, int16_t aButton,
     49                        Event* aSourceEvent, uint16_t aInputSource,
     50                        ErrorResult& aRv);
     51 
     52 protected:
     53  ~XULCommandEvent() = default;
     54 
     55  RefPtr<Event> mSourceEvent;
     56  uint16_t mInputSource;
     57  int16_t mButton = 0;
     58 };
     59 
     60 }  // namespace mozilla::dom
     61 
     62 already_AddRefed<mozilla::dom::XULCommandEvent> NS_NewDOMXULCommandEvent(
     63    mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
     64    mozilla::WidgetInputEvent* aEvent);
     65 
     66 #endif  // mozilla_dom_XULCommandEvent_h_