Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/CommandEvent.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#include "mozilla/dom/CommandEvent.h"
8
#include "mozilla/MiscEvents.h"
9
#include "prtime.h"
10
11
namespace mozilla {
12
namespace dom {
13
14
CommandEvent::CommandEvent(EventTarget* aOwner,
15
                           nsPresContext* aPresContext,
16
                           WidgetCommandEvent* aEvent)
17
  : Event(aOwner, aPresContext,
18
          aEvent ? aEvent : new WidgetCommandEvent())
19
0
{
20
0
  mEvent->mTime = PR_Now();
21
0
  if (aEvent) {
22
0
    mEventIsInternal = false;
23
0
  } else {
24
0
    mEventIsInternal = true;
25
0
  }
26
0
}
27
28
void
29
CommandEvent::GetCommand(nsAString& aCommand)
30
0
{
31
0
  nsAtom* command = mEvent->AsCommandEvent()->mCommand;
32
0
  if (command) {
33
0
    command->ToString(aCommand);
34
0
  } else {
35
0
    aCommand.Truncate();
36
0
  }
37
0
}
38
39
} // namespace dom
40
} // namespace mozilla
41
42
using namespace mozilla;
43
using namespace mozilla::dom;
44
45
already_AddRefed<CommandEvent>
46
NS_NewDOMCommandEvent(EventTarget* aOwner,
47
                      nsPresContext* aPresContext,
48
                      WidgetCommandEvent* aEvent)
49
0
{
50
0
  RefPtr<CommandEvent> it =
51
0
    new CommandEvent(aOwner, aPresContext, aEvent);
52
0
  return it.forget();
53
0
}