Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/events/SimpleGestureEvent.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/MouseEventBinding.h"
8
#include "mozilla/dom/SimpleGestureEvent.h"
9
#include "mozilla/TouchEvents.h"
10
#include "prtime.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
16
                                       nsPresContext* aPresContext,
17
                                       WidgetSimpleGestureEvent* aEvent)
18
  : MouseEvent(aOwner, aPresContext,
19
               aEvent ? aEvent :
20
                        new WidgetSimpleGestureEvent(false, eVoidEvent,
21
                                                     nullptr))
22
0
{
23
0
  NS_ASSERTION(mEvent->mClass == eSimpleGestureEventClass,
24
0
               "event type mismatch");
25
0
26
0
  if (aEvent) {
27
0
    mEventIsInternal = false;
28
0
  } else {
29
0
    mEventIsInternal = true;
30
0
    mEvent->mTime = PR_Now();
31
0
    mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
32
0
    static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
33
0
      MouseEvent_Binding::MOZ_SOURCE_UNKNOWN;
34
0
  }
35
0
}
36
37
uint32_t
38
SimpleGestureEvent::AllowedDirections() const
39
0
{
40
0
  return mEvent->AsSimpleGestureEvent()->mAllowedDirections;
41
0
}
42
43
void
44
SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
45
0
{
46
0
  mEvent->AsSimpleGestureEvent()->mAllowedDirections = aAllowedDirections;
47
0
}
48
49
uint32_t
50
SimpleGestureEvent::Direction() const
51
0
{
52
0
  return mEvent->AsSimpleGestureEvent()->mDirection;
53
0
}
54
55
double
56
SimpleGestureEvent::Delta() const
57
0
{
58
0
  return mEvent->AsSimpleGestureEvent()->mDelta;
59
0
}
60
61
uint32_t
62
SimpleGestureEvent::ClickCount() const
63
0
{
64
0
  return mEvent->AsSimpleGestureEvent()->mClickCount;
65
0
}
66
67
void
68
SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
69
                                           bool aCanBubbleArg,
70
                                           bool aCancelableArg,
71
                                           nsGlobalWindowInner* aViewArg,
72
                                           int32_t aDetailArg,
73
                                           int32_t aScreenX,
74
                                           int32_t aScreenY,
75
                                           int32_t aClientX,
76
                                           int32_t aClientY,
77
                                           bool aCtrlKeyArg,
78
                                           bool aAltKeyArg,
79
                                           bool aShiftKeyArg,
80
                                           bool aMetaKeyArg,
81
                                           uint16_t aButton,
82
                                           EventTarget* aRelatedTarget,
83
                                           uint32_t aAllowedDirectionsArg,
84
                                           uint32_t aDirectionArg,
85
                                           double aDeltaArg,
86
                                           uint32_t aClickCountArg)
87
0
{
88
0
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
89
0
90
0
  MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
91
0
                             aViewArg, aDetailArg,
92
0
                             aScreenX, aScreenY, aClientX, aClientY,
93
0
                             aCtrlKeyArg, aAltKeyArg, aShiftKeyArg,
94
0
                             aMetaKeyArg, aButton, aRelatedTarget);
95
0
96
0
  WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
97
0
  simpleGestureEvent->mAllowedDirections = aAllowedDirectionsArg;
98
0
  simpleGestureEvent->mDirection = aDirectionArg;
99
0
  simpleGestureEvent->mDelta = aDeltaArg;
100
0
  simpleGestureEvent->mClickCount = aClickCountArg;
101
0
}
102
103
} // namespace dom
104
} // namespace mozilla
105
106
using namespace mozilla;
107
using namespace mozilla::dom;
108
109
already_AddRefed<SimpleGestureEvent>
110
NS_NewDOMSimpleGestureEvent(EventTarget* aOwner,
111
                            nsPresContext* aPresContext,
112
                            WidgetSimpleGestureEvent* aEvent)
113
0
{
114
0
  RefPtr<SimpleGestureEvent> it =
115
0
    new SimpleGestureEvent(aOwner, aPresContext, aEvent);
116
0
  return it.forget();
117
0
}