/usr/include/thunderbird/mozilla/TouchEvents.h is in thunderbird-dev 1:38.6.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_TouchEvents_h__
#define mozilla_TouchEvents_h__
#include <stdint.h>
#include "mozilla/dom/Touch.h"
#include "mozilla/MouseEvents.h"
#include "nsAutoPtr.h"
#include "nsIDOMSimpleGestureEvent.h"
#include "nsTArray.h"
namespace mozilla {
/******************************************************************************
* mozilla::WidgetGestureNotifyEvent
*
* This event is the first event generated when the user touches
* the screen with a finger, and it's meant to decide what kind
* of action we'll use for that touch interaction.
*
* The event is dispatched to the layout and based on what is underneath
* the initial contact point it's then decided if we should pan
* (finger scrolling) or drag the target element.
******************************************************************************/
class WidgetGestureNotifyEvent : public WidgetGUIEvent
{
public:
virtual WidgetGestureNotifyEvent* AsGestureNotifyEvent() override
{
return this;
}
WidgetGestureNotifyEvent(bool aIsTrusted, uint32_t aMessage,
nsIWidget *aWidget)
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eGestureNotifyEventClass)
, panDirection(ePanNone)
, displayPanFeedback(false)
{
}
virtual WidgetEvent* Duplicate() const override
{
// XXX Looks like this event is handled only in PostHandleEvent() of
// EventStateManager. Therefore, it might be possible to handle this
// in PreHandleEvent() and not to dispatch as a DOM event into the DOM
// tree like ContentQueryEvent. Then, this event doesn't need to
// support Duplicate().
MOZ_ASSERT(mClass == eGestureNotifyEventClass,
"Duplicate() must be overridden by sub class");
// Not copying widget, it is a weak reference.
WidgetGestureNotifyEvent* result =
new WidgetGestureNotifyEvent(false, message, nullptr);
result->AssignGestureNotifyEventData(*this, true);
result->mFlags = mFlags;
return result;
}
enum ePanDirection
{
ePanNone,
ePanVertical,
ePanHorizontal,
ePanBoth
};
ePanDirection panDirection;
bool displayPanFeedback;
void AssignGestureNotifyEventData(const WidgetGestureNotifyEvent& aEvent,
bool aCopyTargets)
{
AssignGUIEventData(aEvent, aCopyTargets);
panDirection = aEvent.panDirection;
displayPanFeedback = aEvent.displayPanFeedback;
}
};
/******************************************************************************
* mozilla::WidgetTouchEvent
******************************************************************************/
class WidgetSimpleGestureEvent : public WidgetMouseEventBase
{
public:
virtual WidgetSimpleGestureEvent* AsSimpleGestureEvent() override
{
return this;
}
WidgetSimpleGestureEvent(bool aIsTrusted, uint32_t aMessage,
nsIWidget* aWidget)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
eSimpleGestureEventClass)
, allowedDirections(0)
, direction(0)
, delta(0.0)
, clickCount(0)
{
}
WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther)
: WidgetMouseEventBase(aOther.mFlags.mIsTrusted, aOther.message,
aOther.widget, eSimpleGestureEventClass)
, allowedDirections(aOther.allowedDirections)
, direction(aOther.direction)
, delta(aOther.delta)
, clickCount(0)
{
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eSimpleGestureEventClass,
"Duplicate() must be overridden by sub class");
// Not copying widget, it is a weak reference.
WidgetSimpleGestureEvent* result =
new WidgetSimpleGestureEvent(false, message, nullptr);
result->AssignSimpleGestureEventData(*this, true);
result->mFlags = mFlags;
return result;
}
// See nsIDOMSimpleGestureEvent for values
uint32_t allowedDirections;
// See nsIDOMSimpleGestureEvent for values
uint32_t direction;
// Delta for magnify and rotate events
double delta;
// The number of taps for tap events
uint32_t clickCount;
// XXX Not tested by test_assign_event_data.html
void AssignSimpleGestureEventData(const WidgetSimpleGestureEvent& aEvent,
bool aCopyTargets)
{
AssignMouseEventBaseData(aEvent, aCopyTargets);
// allowedDirections isn't copied
direction = aEvent.direction;
delta = aEvent.delta;
clickCount = aEvent.clickCount;
}
};
/******************************************************************************
* mozilla::WidgetTouchEvent
******************************************************************************/
class WidgetTouchEvent : public WidgetInputEvent
{
public:
typedef nsTArray<nsRefPtr<mozilla::dom::Touch>> TouchArray;
typedef nsAutoTArray<nsRefPtr<mozilla::dom::Touch>, 10> AutoTouchArray;
virtual WidgetTouchEvent* AsTouchEvent() override { return this; }
WidgetTouchEvent()
{
}
WidgetTouchEvent(const WidgetTouchEvent& aOther)
: WidgetInputEvent(aOther.mFlags.mIsTrusted, aOther.message, aOther.widget,
eTouchEventClass)
{
modifiers = aOther.modifiers;
time = aOther.time;
timeStamp = aOther.timeStamp;
touches.AppendElements(aOther.touches);
mFlags.mCancelable = message != NS_TOUCH_CANCEL;
MOZ_COUNT_CTOR(WidgetTouchEvent);
}
WidgetTouchEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, eTouchEventClass)
{
MOZ_COUNT_CTOR(WidgetTouchEvent);
mFlags.mCancelable = message != NS_TOUCH_CANCEL;
}
virtual ~WidgetTouchEvent()
{
MOZ_COUNT_DTOR(WidgetTouchEvent);
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eTouchEventClass,
"Duplicate() must be overridden by sub class");
// Not copying widget, it is a weak reference.
WidgetTouchEvent* result = new WidgetTouchEvent(false, message, nullptr);
result->AssignTouchEventData(*this, true);
result->mFlags = mFlags;
return result;
}
TouchArray touches;
void AssignTouchEventData(const WidgetTouchEvent& aEvent, bool aCopyTargets)
{
AssignInputEventData(aEvent, aCopyTargets);
// Assign*EventData() assume that they're called only new instance.
MOZ_ASSERT(touches.IsEmpty());
touches.AppendElements(aEvent.touches);
}
};
} // namespace mozilla
#endif // mozilla_TouchEvents_h__
|