1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/XULCommandEvent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +// This class implements a XUL "command" event. See nsIDOMXULCommandEvent.idl 1.11 + 1.12 +#ifndef mozilla_dom_XULCommandEvent_h_ 1.13 +#define mozilla_dom_XULCommandEvent_h_ 1.14 + 1.15 +#include "mozilla/dom/UIEvent.h" 1.16 +#include "mozilla/dom/XULCommandEventBinding.h" 1.17 +#include "nsIDOMXULCommandEvent.h" 1.18 + 1.19 +namespace mozilla { 1.20 +namespace dom { 1.21 + 1.22 +class XULCommandEvent : public UIEvent, 1.23 + public nsIDOMXULCommandEvent 1.24 +{ 1.25 +public: 1.26 + XULCommandEvent(EventTarget* aOwner, 1.27 + nsPresContext* aPresContext, 1.28 + WidgetInputEvent* aEvent); 1.29 + 1.30 + NS_DECL_ISUPPORTS_INHERITED 1.31 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULCommandEvent, UIEvent) 1.32 + NS_DECL_NSIDOMXULCOMMANDEVENT 1.33 + 1.34 + // Forward our inherited virtual methods to the base class 1.35 + NS_FORWARD_TO_UIEVENT 1.36 + 1.37 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE 1.38 + { 1.39 + return XULCommandEventBinding::Wrap(aCx, this); 1.40 + } 1.41 + 1.42 + bool AltKey(); 1.43 + bool CtrlKey(); 1.44 + bool ShiftKey(); 1.45 + bool MetaKey(); 1.46 + 1.47 + already_AddRefed<Event> GetSourceEvent() 1.48 + { 1.49 + nsRefPtr<Event> e = 1.50 + mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr; 1.51 + return e.forget(); 1.52 + } 1.53 + 1.54 + void InitCommandEvent(const nsAString& aType, 1.55 + bool aCanBubble, bool aCancelable, 1.56 + nsIDOMWindow* aView, 1.57 + int32_t aDetail, 1.58 + bool aCtrlKey, bool aAltKey, 1.59 + bool aShiftKey, bool aMetaKey, 1.60 + Event* aSourceEvent, 1.61 + ErrorResult& aRv) 1.62 + { 1.63 + aRv = InitCommandEvent(aType, aCanBubble, aCancelable, aView, aDetail, 1.64 + aCtrlKey, aAltKey, aShiftKey, aMetaKey, 1.65 + aSourceEvent); 1.66 + } 1.67 + 1.68 +protected: 1.69 + nsCOMPtr<nsIDOMEvent> mSourceEvent; 1.70 +}; 1.71 + 1.72 +} // namespace dom 1.73 +} // namespace mozilla 1.74 + 1.75 +#endif // mozilla_dom_XULCommandEvent_h_