Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / events / CommandEvent.cpp
blobb048a959f8d75b8e4ebb6be479ad7835bfc9743d
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/CommandEvent.h"
8 #include "mozilla/MiscEvents.h"
9 #include "prtime.h"
11 namespace mozilla::dom {
13 CommandEvent::CommandEvent(EventTarget* aOwner, nsPresContext* aPresContext,
14 WidgetCommandEvent* aEvent)
15 : Event(aOwner, aPresContext, aEvent ? aEvent : new WidgetCommandEvent()) {
16 if (aEvent) {
17 mEventIsInternal = false;
18 } else {
19 mEventIsInternal = true;
23 void CommandEvent::GetCommand(nsAString& aCommand) {
24 nsAtom* command = mEvent->AsCommandEvent()->mCommand;
25 if (command) {
26 command->ToString(aCommand);
27 } else {
28 aCommand.Truncate();
32 } // namespace mozilla::dom
34 using namespace mozilla;
35 using namespace mozilla::dom;
37 already_AddRefed<CommandEvent> NS_NewDOMCommandEvent(
38 EventTarget* aOwner, nsPresContext* aPresContext,
39 WidgetCommandEvent* aEvent) {
40 RefPtr<CommandEvent> it = new CommandEvent(aOwner, aPresContext, aEvent);
41 return it.forget();