author Masayuki Nakano <>
Tue, 01 Oct 2013 16:23:02 +0900
changeset 149435 e88b33939f5058ba29b2ccad47d8cecfa3a4a549
parent 129891 1b1381894c4402d105cf59e45078bd9573facd01
child 151323 bc72b42bcf7644385188e115b123fd7a2d345b37
permissions -rw-r--r--
Bug 920377 part.26 Get rid of nsInputEvent r=roc

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

// This class implements a XUL "command" event.  See nsIDOMXULCommandEvent.idl

#ifndef nsDOMXULCommandEvent_h_
#define nsDOMXULCommandEvent_h_

#include "nsDOMUIEvent.h"
#include "nsIDOMXULCommandEvent.h"
#include "mozilla/dom/XULCommandEventBinding.h"

class nsDOMXULCommandEvent : public nsDOMUIEvent,
                             public nsIDOMXULCommandEvent
  nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
                       nsPresContext* aPresContext,
                       mozilla::WidgetInputEvent* aEvent);


  // Forward our inherited virtual methods to the base class

  virtual JSObject* WrapObject(JSContext* aCx,
                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
    return mozilla::dom::XULCommandEventBinding::Wrap(aCx, aScope, this);

  bool AltKey()
    return Event()->IsAlt();

  bool CtrlKey()
    return Event()->IsControl();

  bool ShiftKey()
    return Event()->IsShift();

  bool MetaKey()
    return Event()->IsMeta();

  already_AddRefed<nsDOMEvent> GetSourceEvent()
    nsRefPtr<nsDOMEvent> e =
      mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr;
    return e.forget();

  void InitCommandEvent(const nsAString& aType,
                        bool aCanBubble, bool aCancelable,
                        nsIDOMWindow* aView,
                        int32_t aDetail,
                        bool aCtrlKey, bool aAltKey,
                        bool aShiftKey, bool aMetaKey,
                        nsDOMEvent* aSourceEvent,
                        mozilla::ErrorResult& aRv)
    aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aView, aDetail,
                           aCtrlKey, aAltKey, aShiftKey, aMetaKey,

  // Convenience accessor for the event
  mozilla::WidgetInputEvent* Event() {
    return static_cast<mozilla::WidgetInputEvent*>(mEvent);

  nsCOMPtr<nsIDOMEvent> mSourceEvent;

#endif  // nsDOMXULCommandEvent_h_