Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/XULCommandEvent.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/XULCommandEvent.h"
8
#include "prtime.h"
9
10
namespace mozilla {
11
namespace dom {
12
13
XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
14
                                 nsPresContext* aPresContext,
15
                                 WidgetInputEvent* aEvent)
16
  : UIEvent(aOwner, aPresContext,
17
            aEvent ? aEvent :
18
                     new WidgetInputEvent(false, eVoidEvent, nullptr))
19
  , mInputSource(0)
20
0
{
21
0
  if (aEvent) {
22
0
    mEventIsInternal = false;
23
0
  }
24
0
  else {
25
0
    mEventIsInternal = true;
26
0
    mEvent->mTime = PR_Now();
27
0
  }
28
0
}
29
30
NS_IMPL_ADDREF_INHERITED(XULCommandEvent, UIEvent)
31
NS_IMPL_RELEASE_INHERITED(XULCommandEvent, UIEvent)
32
33
NS_IMPL_CYCLE_COLLECTION_INHERITED(XULCommandEvent, UIEvent,
34
                                   mSourceEvent)
35
36
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XULCommandEvent)
37
0
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
38
39
bool
40
XULCommandEvent::AltKey()
41
0
{
42
0
  return mEvent->AsInputEvent()->IsAlt();
43
0
}
44
45
bool
46
XULCommandEvent::CtrlKey()
47
0
{
48
0
  return mEvent->AsInputEvent()->IsControl();
49
0
}
50
51
bool
52
XULCommandEvent::ShiftKey()
53
0
{
54
0
  return mEvent->AsInputEvent()->IsShift();
55
0
}
56
57
bool
58
XULCommandEvent::MetaKey()
59
0
{
60
0
  return mEvent->AsInputEvent()->IsMeta();
61
0
}
62
63
uint16_t
64
XULCommandEvent::InputSource()
65
0
{
66
0
  return mInputSource;
67
0
}
68
69
void
70
XULCommandEvent::InitCommandEvent(const nsAString& aType,
71
                                  bool aCanBubble,
72
                                  bool aCancelable,
73
                                  nsGlobalWindowInner* aView,
74
                                  int32_t aDetail,
75
                                  bool aCtrlKey,
76
                                  bool aAltKey,
77
                                  bool aShiftKey,
78
                                  bool aMetaKey,
79
                                  Event* aSourceEvent,
80
                                  uint16_t aInputSource,
81
                                  ErrorResult& aRv)
82
0
{
83
0
  if (NS_WARN_IF(mEvent->mFlags.mIsBeingDispatched)) {
84
0
    return;
85
0
  }
86
0
87
0
  UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
88
0
89
0
  mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
90
0
                                             aShiftKey, aMetaKey);
91
0
  mSourceEvent = aSourceEvent;
92
0
  mInputSource = aInputSource;
93
0
}
94
95
} // namespace dom
96
} // namespace mozilla
97
98
using namespace mozilla;
99
using namespace mozilla::dom;
100
101
already_AddRefed<XULCommandEvent>
102
NS_NewDOMXULCommandEvent(EventTarget* aOwner,
103
                         nsPresContext* aPresContext,
104
                         WidgetInputEvent* aEvent)
105
0
{
106
0
  RefPtr<XULCommandEvent> it =
107
0
    new XULCommandEvent(aOwner, aPresContext, aEvent);
108
0
  return it.forget();
109
0
}