Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / events / CommandEvent.cpp
blob17db047b62652e59b4135d759eb6e3376946caf0
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 mEvent->mTime = PR_Now();
17 if (aEvent) {
18 mEventIsInternal = false;
19 } else {
20 mEventIsInternal = true;
24 void CommandEvent::GetCommand(nsAString& aCommand) {
25 nsAtom* command = mEvent->AsCommandEvent()->mCommand;
26 if (command) {
27 command->ToString(aCommand);
28 } else {
29 aCommand.Truncate();
33 } // namespace mozilla::dom
35 using namespace mozilla;
36 using namespace mozilla::dom;
38 already_AddRefed<CommandEvent> NS_NewDOMCommandEvent(
39 EventTarget* aOwner, nsPresContext* aPresContext,
40 WidgetCommandEvent* aEvent) {
41 RefPtr<CommandEvent> it = new CommandEvent(aOwner, aPresContext, aEvent);
42 return it.forget();