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/. */
7 #include "mozilla/dom/XULCommandEvent.h"
10 namespace mozilla::dom
{
12 XULCommandEvent::XULCommandEvent(EventTarget
* aOwner
,
13 nsPresContext
* aPresContext
,
14 WidgetInputEvent
* aEvent
)
17 aEvent
? aEvent
: new WidgetInputEvent(false, eVoidEvent
, nullptr)),
20 mEventIsInternal
= false;
22 mEventIsInternal
= true;
26 NS_IMPL_ADDREF_INHERITED(XULCommandEvent
, UIEvent
)
27 NS_IMPL_RELEASE_INHERITED(XULCommandEvent
, UIEvent
)
29 NS_IMPL_CYCLE_COLLECTION_INHERITED(XULCommandEvent
, UIEvent
, mSourceEvent
)
31 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XULCommandEvent
)
32 NS_INTERFACE_MAP_END_INHERITING(UIEvent
)
34 bool XULCommandEvent::AltKey() { return mEvent
->AsInputEvent()->IsAlt(); }
36 bool XULCommandEvent::CtrlKey() { return mEvent
->AsInputEvent()->IsControl(); }
38 bool XULCommandEvent::ShiftKey() { return mEvent
->AsInputEvent()->IsShift(); }
40 bool XULCommandEvent::MetaKey() { return mEvent
->AsInputEvent()->IsMeta(); }
42 uint16_t XULCommandEvent::InputSource() { return mInputSource
; }
44 void XULCommandEvent::InitCommandEvent(
45 const nsAString
& aType
, bool aCanBubble
, bool aCancelable
,
46 nsGlobalWindowInner
* aView
, int32_t aDetail
, bool aCtrlKey
, bool aAltKey
,
47 bool aShiftKey
, bool aMetaKey
, int16_t aButton
, Event
* aSourceEvent
,
48 uint16_t aInputSource
, ErrorResult
& aRv
) {
49 if (NS_WARN_IF(mEvent
->mFlags
.mIsBeingDispatched
)) {
53 UIEvent::InitUIEvent(aType
, aCanBubble
, aCancelable
, aView
, aDetail
);
55 mEvent
->AsInputEvent()->InitBasicModifiers(aCtrlKey
, aAltKey
, aShiftKey
,
57 mSourceEvent
= aSourceEvent
;
58 mInputSource
= aInputSource
;
62 } // namespace mozilla::dom
64 using namespace mozilla
;
65 using namespace mozilla::dom
;
67 already_AddRefed
<XULCommandEvent
> NS_NewDOMXULCommandEvent(
68 EventTarget
* aOwner
, nsPresContext
* aPresContext
,
69 WidgetInputEvent
* aEvent
) {
70 RefPtr
<XULCommandEvent
> it
=
71 new XULCommandEvent(aOwner
, aPresContext
, aEvent
);