1 /* -*- Mode: C++; tab-width: 2; 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/. */
6 #include "mozilla/dom/CommandEvent.h"
7 #include "mozilla/MiscEvents.h"
13 CommandEvent::CommandEvent(EventTarget
* aOwner
,
14 nsPresContext
* aPresContext
,
15 WidgetCommandEvent
* aEvent
)
16 : Event(aOwner
, aPresContext
,
18 new WidgetCommandEvent(false, nullptr, nullptr, nullptr))
20 mEvent
->time
= PR_Now();
22 mEventIsInternal
= false;
24 mEventIsInternal
= true;
28 NS_INTERFACE_MAP_BEGIN(CommandEvent
)
29 NS_INTERFACE_MAP_ENTRY(nsIDOMCommandEvent
)
30 NS_INTERFACE_MAP_END_INHERITING(Event
)
32 NS_IMPL_ADDREF_INHERITED(CommandEvent
, Event
)
33 NS_IMPL_RELEASE_INHERITED(CommandEvent
, Event
)
36 CommandEvent::GetCommand(nsAString
& aCommand
)
38 nsIAtom
* command
= mEvent
->AsCommandEvent()->command
;
40 command
->ToString(aCommand
);
48 CommandEvent::InitCommandEvent(const nsAString
& aTypeArg
,
51 const nsAString
& aCommand
)
53 nsresult rv
= Event::InitEvent(aTypeArg
, aCanBubbleArg
, aCancelableArg
);
54 NS_ENSURE_SUCCESS(rv
, rv
);
56 mEvent
->AsCommandEvent()->command
= do_GetAtom(aCommand
);
61 } // namespace mozilla
63 using namespace mozilla
;
64 using namespace mozilla::dom
;
67 NS_NewDOMCommandEvent(nsIDOMEvent
** aInstancePtrResult
,
69 nsPresContext
* aPresContext
,
70 WidgetCommandEvent
* aEvent
)
72 CommandEvent
* it
= new CommandEvent(aOwner
, aPresContext
, aEvent
);
74 *aInstancePtrResult
= static_cast<Event
*>(it
);