2012-07-19 23:48:25 -07:00
|
|
|
/* -*- 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 InputData_h__
|
|
|
|
#define InputData_h__
|
|
|
|
|
2015-04-13 12:45:37 -07:00
|
|
|
#include "nsIDOMWheelEvent.h"
|
2012-07-19 23:48:25 -07:00
|
|
|
#include "nsDebug.h"
|
2013-01-23 15:30:48 -08:00
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsTArray.h"
|
2013-06-11 15:13:11 -07:00
|
|
|
#include "Units.h"
|
2013-09-24 03:04:14 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2014-06-05 22:29:49 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2015-12-02 15:52:00 -08:00
|
|
|
#include "mozilla/gfx/MatrixFwd.h"
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2014-06-25 17:11:20 -07:00
|
|
|
template<class E> struct already_AddRefed;
|
2014-08-08 15:15:37 -07:00
|
|
|
class nsIWidget;
|
2014-06-25 17:11:20 -07:00
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-06-25 17:11:20 -07:00
|
|
|
namespace dom {
|
|
|
|
class Touch;
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace dom
|
2012-07-19 23:48:25 -07:00
|
|
|
|
|
|
|
enum InputType
|
|
|
|
{
|
|
|
|
MULTITOUCH_INPUT,
|
2015-09-28 07:32:05 -07:00
|
|
|
MOUSE_INPUT,
|
2014-06-06 15:49:49 -07:00
|
|
|
PANGESTURE_INPUT,
|
2012-07-19 23:48:25 -07:00
|
|
|
PINCHGESTURE_INPUT,
|
2014-11-17 20:56:18 -08:00
|
|
|
TAPGESTURE_INPUT,
|
|
|
|
SCROLLWHEEL_INPUT
|
2012-07-19 23:48:25 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class MultiTouchInput;
|
2015-09-28 07:32:05 -07:00
|
|
|
class MouseInput;
|
2014-06-06 15:49:49 -07:00
|
|
|
class PanGestureInput;
|
2012-07-19 23:48:25 -07:00
|
|
|
class PinchGestureInput;
|
|
|
|
class TapGestureInput;
|
2014-11-17 20:56:18 -08:00
|
|
|
class ScrollWheelInput;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
|
|
|
// This looks unnecessary now, but as we add more and more classes that derive
|
2013-09-25 04:21:22 -07:00
|
|
|
// from InputType (eventually probably almost as many as *Events.h has), it
|
2012-07-19 23:48:25 -07:00
|
|
|
// will be more and more clear what's going on with a macro that shortens the
|
|
|
|
// definition of the RTTI functions.
|
|
|
|
#define INPUTDATA_AS_CHILD_TYPE(type, enumID) \
|
|
|
|
const type& As##type() const \
|
|
|
|
{ \
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
|
2012-07-19 23:48:25 -07:00
|
|
|
return (const type&) *this; \
|
2014-07-08 11:55:52 -07:00
|
|
|
} \
|
|
|
|
type& As##type() \
|
|
|
|
{ \
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
|
2014-07-08 11:55:52 -07:00
|
|
|
return (type&) *this; \
|
2012-07-19 23:48:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Base input data class. Should never be instantiated. */
|
|
|
|
class InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InputType mInputType;
|
|
|
|
// Time in milliseconds that this data is relevant to. This only really
|
2012-08-22 08:56:38 -07:00
|
|
|
// matters when this data is used as an event. We use uint32_t instead of
|
2013-10-01 00:23:02 -07:00
|
|
|
// TimeStamp because it is easier to convert from WidgetInputEvent. The time
|
|
|
|
// is platform-specific but it in the case of B2G and Fennec it is since
|
|
|
|
// startup.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mTime;
|
2014-06-05 22:29:49 -07:00
|
|
|
// Set in parallel to mTime until we determine it is safe to drop
|
|
|
|
// platform-specific event times (see bug 77992).
|
|
|
|
TimeStamp mTimeStamp;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2013-11-25 20:30:26 -08:00
|
|
|
Modifiers modifiers;
|
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
INPUTDATA_AS_CHILD_TYPE(MultiTouchInput, MULTITOUCH_INPUT)
|
2015-09-28 07:32:05 -07:00
|
|
|
INPUTDATA_AS_CHILD_TYPE(MouseInput, MOUSE_INPUT)
|
2014-06-06 15:49:49 -07:00
|
|
|
INPUTDATA_AS_CHILD_TYPE(PanGestureInput, PANGESTURE_INPUT)
|
2012-07-19 23:48:25 -07:00
|
|
|
INPUTDATA_AS_CHILD_TYPE(PinchGestureInput, PINCHGESTURE_INPUT)
|
|
|
|
INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
|
2014-11-17 20:56:18 -08:00
|
|
|
INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput, SCROLLWHEEL_INPUT)
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2015-03-25 09:41:50 -07:00
|
|
|
explicit InputData(InputType aInputType)
|
2015-03-25 09:20:20 -07:00
|
|
|
: mInputType(aInputType),
|
|
|
|
mTime(0),
|
|
|
|
modifiers(0)
|
2013-01-23 15:30:48 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
protected:
|
2014-06-05 22:29:49 -07:00
|
|
|
InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp,
|
|
|
|
Modifiers aModifiers)
|
2012-07-19 23:48:25 -07:00
|
|
|
: mInputType(aInputType),
|
2013-11-25 20:30:26 -08:00
|
|
|
mTime(aTime),
|
2014-06-05 22:29:49 -07:00
|
|
|
mTimeStamp(aTimeStamp),
|
2013-11-25 20:30:26 -08:00
|
|
|
modifiers(aModifiers)
|
2012-07-19 23:48:25 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-04-05 01:49:00 -07:00
|
|
|
* Data container for a single touch input. Similar to dom::Touch, but used in
|
2012-07-19 23:48:25 -07:00
|
|
|
* off-main-thread situations. This is more for just storing touch data, whereas
|
2013-08-04 21:51:22 -07:00
|
|
|
* dom::Touch is more useful for dispatching through the DOM (which can only
|
|
|
|
* happen on the main thread). dom::Touch also bears the problem of storing
|
|
|
|
* pointers to nsIWidget instances which can only be used on the main thread,
|
|
|
|
* so if instead we used dom::Touch and ever set these pointers
|
|
|
|
* off-main-thread, Bad Things Can Happen(tm).
|
2012-07-19 23:48:25 -07:00
|
|
|
*
|
|
|
|
* Note that this doesn't inherit from InputData because this itself is not an
|
|
|
|
* event. It is only a container/struct that should have any number of instances
|
|
|
|
* within a MultiTouchInput.
|
|
|
|
*
|
2013-04-05 01:49:00 -07:00
|
|
|
* fixme/bug 775746: Make dom::Touch inherit from this class.
|
2012-07-19 23:48:25 -07:00
|
|
|
*/
|
|
|
|
class SingleTouchData
|
|
|
|
{
|
|
|
|
public:
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a SingleTouchData from a Screen point.
|
|
|
|
// mLocalScreenPoint remains (0,0) unless it's set later.
|
2012-08-22 08:56:38 -07:00
|
|
|
SingleTouchData(int32_t aIdentifier,
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenIntPoint aScreenPoint,
|
|
|
|
ScreenSize aRadius,
|
2012-07-19 23:48:25 -07:00
|
|
|
float aRotationAngle,
|
|
|
|
float aForce)
|
|
|
|
: mIdentifier(aIdentifier),
|
|
|
|
mScreenPoint(aScreenPoint),
|
|
|
|
mRadius(aRadius),
|
|
|
|
mRotationAngle(aRotationAngle),
|
|
|
|
mForce(aForce)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a SingleTouchData from a ParentLayer point.
|
|
|
|
// mScreenPoint remains (0,0) unless it's set later.
|
|
|
|
// Note: if APZ starts using the radius for anything, we should add a local
|
|
|
|
// version of that too, and have this constructor take it as a ParentLayerSize.
|
|
|
|
SingleTouchData(int32_t aIdentifier,
|
|
|
|
ParentLayerPoint aLocalScreenPoint,
|
|
|
|
ScreenSize aRadius,
|
|
|
|
float aRotationAngle,
|
|
|
|
float aForce)
|
|
|
|
: mIdentifier(aIdentifier),
|
|
|
|
mLocalScreenPoint(aLocalScreenPoint),
|
|
|
|
mRadius(aRadius),
|
|
|
|
mRotationAngle(aRotationAngle),
|
|
|
|
mForce(aForce)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-23 15:30:48 -08:00
|
|
|
SingleTouchData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-08 15:15:37 -07:00
|
|
|
already_AddRefed<dom::Touch> ToNewDOMTouch() const;
|
2014-06-25 17:11:20 -07:00
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
// A unique number assigned to each SingleTouchData within a MultiTouchInput so
|
|
|
|
// that they can be easily distinguished when handling a touch start/move/end.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mIdentifier;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
|
|
|
// Point on the screen that the touch hit, in device pixels. They are
|
|
|
|
// coordinates on the screen.
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenIntPoint mScreenPoint;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// |mScreenPoint| transformed to the local coordinates of the APZC targeted
|
|
|
|
// by the hit. This is set and used by APZ.
|
|
|
|
ParentLayerPoint mLocalScreenPoint;
|
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
// Radius that the touch covers, i.e. if you're using your thumb it will
|
|
|
|
// probably be larger than using your pinky, even with the same force.
|
|
|
|
// Radius can be different along x and y. For example, if you press down with
|
|
|
|
// your entire finger vertically, the y radius will be much larger than the x
|
|
|
|
// radius.
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenSize mRadius;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
|
|
|
float mRotationAngle;
|
|
|
|
|
|
|
|
// How hard the screen is being pressed.
|
|
|
|
float mForce;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-09-26 23:20:57 -07:00
|
|
|
* Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
|
|
|
|
* screen touch point instead of the many different coordinate spaces
|
|
|
|
* WidgetTouchEvent stores its touch point in. This includes a way to initialize
|
|
|
|
* itself from a WidgetTouchEvent by copying all relevant data over. Note that
|
|
|
|
* this copying from WidgetTouchEvent functionality can only be used on the main
|
|
|
|
* thread.
|
2012-07-19 23:48:25 -07:00
|
|
|
*
|
|
|
|
* Stores an array of SingleTouchData.
|
|
|
|
*/
|
|
|
|
class MultiTouchInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum MultiTouchType
|
|
|
|
{
|
|
|
|
MULTITOUCH_START,
|
|
|
|
MULTITOUCH_MOVE,
|
|
|
|
MULTITOUCH_END,
|
|
|
|
MULTITOUCH_CANCEL
|
|
|
|
};
|
|
|
|
|
2014-06-05 22:29:49 -07:00
|
|
|
MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
|
|
|
|
Modifiers aModifiers)
|
2015-10-28 09:53:34 -07:00
|
|
|
: InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mHandledByAPZ(false)
|
2012-07-19 23:48:25 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-23 15:30:48 -08:00
|
|
|
MultiTouchInput()
|
2015-03-25 09:20:20 -07:00
|
|
|
: InputData(MULTITOUCH_INPUT)
|
2015-10-28 09:53:34 -07:00
|
|
|
, mHandledByAPZ(false)
|
2012-07-19 23:48:25 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-25 17:11:20 -07:00
|
|
|
MultiTouchInput(const MultiTouchInput& aOther)
|
|
|
|
: InputData(MULTITOUCH_INPUT, aOther.mTime,
|
|
|
|
aOther.mTimeStamp, aOther.modifiers)
|
|
|
|
, mType(aOther.mType)
|
2015-10-28 09:53:34 -07:00
|
|
|
, mHandledByAPZ(aOther.mHandledByAPZ)
|
2014-06-25 17:11:20 -07:00
|
|
|
{
|
|
|
|
mTouches.AppendElements(aOther.mTouches);
|
|
|
|
}
|
|
|
|
|
2014-08-19 21:58:22 -07:00
|
|
|
explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
|
2014-08-08 15:15:37 -07:00
|
|
|
WidgetTouchEvent ToWidgetTouchEvent(nsIWidget* aWidget) const;
|
2015-01-10 10:54:24 -08:00
|
|
|
WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
|
2013-01-23 15:30:48 -08:00
|
|
|
|
2015-01-19 15:38:00 -08:00
|
|
|
// Return the index into mTouches of the SingleTouchData with the given
|
|
|
|
// identifier, or -1 if there is no such SingleTouchData.
|
|
|
|
int32_t IndexOfTouch(int32_t aTouchIdentifier);
|
|
|
|
|
2013-10-01 23:38:27 -07:00
|
|
|
// This conversion from WidgetMouseEvent to MultiTouchInput is needed because
|
|
|
|
// on the B2G emulator we can only receive mouse events, but we need to be
|
|
|
|
// able to pan correctly. To do this, we convert the events into a format that
|
|
|
|
// the panning code can handle. This code is very limited and only supports
|
2012-07-19 23:48:25 -07:00
|
|
|
// SingleTouchData. It also sends garbage for the identifier, radius, force
|
|
|
|
// and rotation angle.
|
2014-08-19 21:58:22 -07:00
|
|
|
explicit MultiTouchInput(const WidgetMouseEvent& aMouseEvent);
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-01-09 10:39:08 -08:00
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
MultiTouchType mType;
|
|
|
|
nsTArray<SingleTouchData> mTouches;
|
2015-10-28 09:53:34 -07:00
|
|
|
bool mHandledByAPZ;
|
2012-07-19 23:48:25 -07:00
|
|
|
};
|
|
|
|
|
2015-09-28 07:32:05 -07:00
|
|
|
class MouseInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum MouseType
|
|
|
|
{
|
|
|
|
MOUSE_MOVE,
|
|
|
|
MOUSE_DOWN,
|
|
|
|
MOUSE_UP,
|
|
|
|
MOUSE_DRAG_START,
|
|
|
|
MOUSE_DRAG_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ButtonType
|
|
|
|
{
|
|
|
|
LEFT_BUTTON,
|
|
|
|
MIDDLE_BUTTON,
|
|
|
|
RIGHT_BUTTON,
|
|
|
|
NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
MouseInput(MouseType aType, ButtonType aButtonType, uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp, Modifiers aModifiers)
|
|
|
|
: InputData(MOUSE_INPUT, aTime, aTimeStamp, aModifiers)
|
|
|
|
, mType(aType)
|
|
|
|
, mButtonType(aButtonType)
|
|
|
|
{}
|
|
|
|
|
|
|
|
MouseInput()
|
|
|
|
: InputData(MOUSE_INPUT)
|
|
|
|
{}
|
|
|
|
|
|
|
|
explicit MouseInput(const WidgetMouseEventBase& aMouseEvent);
|
|
|
|
|
|
|
|
bool IsLeftButton() const { return mButtonType == LEFT_BUTTON; }
|
|
|
|
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-09-28 11:44:37 -07:00
|
|
|
|
2015-09-28 07:32:05 -07:00
|
|
|
MouseType mType;
|
|
|
|
ButtonType mButtonType;
|
|
|
|
ScreenPoint mOrigin;
|
|
|
|
ParentLayerPoint mLocalOrigin;
|
|
|
|
};
|
|
|
|
|
2014-06-06 15:49:49 -07:00
|
|
|
/**
|
|
|
|
* Encapsulation class for pan events, can be used off-main-thread.
|
|
|
|
* These events are currently only used for scrolling on desktop.
|
|
|
|
*/
|
|
|
|
class PanGestureInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum PanGestureType
|
|
|
|
{
|
|
|
|
// MayStart: Dispatched before any actual panning has occurred but when a
|
|
|
|
// pan gesture is probably about to start, for example when the user
|
|
|
|
// starts touching the touchpad. Should interrupt any ongoing APZ
|
|
|
|
// animation and can be used to trigger scrollability indicators (e.g.
|
|
|
|
// flashing overlay scrollbars).
|
|
|
|
PANGESTURE_MAYSTART,
|
|
|
|
|
|
|
|
// Cancelled: Dispatched after MayStart when no pan gesture is going to
|
|
|
|
// happen after all, for example when the user lifts their fingers from a
|
|
|
|
// touchpad without having done any scrolling.
|
|
|
|
PANGESTURE_CANCELLED,
|
|
|
|
|
|
|
|
// Start: A pan gesture is starting.
|
|
|
|
// For devices that do not support the MayStart event type, this event can
|
|
|
|
// be used to interrupt ongoing APZ animations.
|
|
|
|
PANGESTURE_START,
|
|
|
|
|
|
|
|
// Pan: The actual pan motion by mPanDisplacement.
|
|
|
|
PANGESTURE_PAN,
|
|
|
|
|
|
|
|
// End: The pan gesture has ended, for example because the user has lifted
|
|
|
|
// their fingers from a touchpad after scrolling.
|
|
|
|
// Any potential momentum events fire after this event.
|
|
|
|
PANGESTURE_END,
|
|
|
|
|
|
|
|
// The following momentum event types are used in order to control the pan
|
|
|
|
// momentum animation. Using these instead of our own animation ensures
|
|
|
|
// that the animation curve is OS native and that the animation stops
|
|
|
|
// reliably if it is cancelled by the user.
|
|
|
|
|
|
|
|
// MomentumStart: Dispatched between the End event of the actual
|
|
|
|
// user-controlled pan, and the first MomentumPan event of the momentum
|
|
|
|
// animation.
|
|
|
|
PANGESTURE_MOMENTUMSTART,
|
|
|
|
|
|
|
|
// MomentumPan: The actual momentum motion by mPanDisplacement.
|
|
|
|
PANGESTURE_MOMENTUMPAN,
|
|
|
|
|
|
|
|
// MomentumEnd: The momentum animation has ended, for example because the
|
|
|
|
// momentum velocity has gone below the stopping threshold, or because the
|
|
|
|
// user has stopped the animation by putting their fingers on a touchpad.
|
|
|
|
PANGESTURE_MOMENTUMEND
|
|
|
|
};
|
|
|
|
|
|
|
|
PanGestureInput(PanGestureType aType,
|
|
|
|
uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ScreenPoint& aPanStartPoint,
|
|
|
|
const ScreenPoint& aPanDisplacement,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(PANGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
|
|
|
|
mType(aType),
|
|
|
|
mPanStartPoint(aPanStartPoint),
|
2015-08-25 20:21:41 -07:00
|
|
|
mPanDisplacement(aPanDisplacement),
|
|
|
|
mLineOrPageDeltaX(0),
|
2015-08-11 15:04:55 -07:00
|
|
|
mLineOrPageDeltaY(0),
|
2015-08-11 21:11:54 -07:00
|
|
|
mHandledByAPZ(false),
|
2015-08-28 13:50:00 -07:00
|
|
|
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false)
|
2014-06-06 15:49:49 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-08-25 20:21:41 -07:00
|
|
|
bool IsMomentum() const;
|
|
|
|
|
|
|
|
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
|
|
|
|
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-01-09 10:39:08 -08:00
|
|
|
|
2014-06-06 15:49:49 -07:00
|
|
|
PanGestureType mType;
|
|
|
|
ScreenPoint mPanStartPoint;
|
|
|
|
|
2015-08-11 12:57:47 -07:00
|
|
|
// The delta. This can be non-zero on any type of event.
|
2014-06-06 15:49:49 -07:00
|
|
|
ScreenPoint mPanDisplacement;
|
2014-11-10 11:35:11 -08:00
|
|
|
|
|
|
|
// Versions of |mPanStartPoint| and |mPanDisplacement| in the local
|
|
|
|
// coordinates of the APZC receiving the pan. These are set and used by APZ.
|
|
|
|
ParentLayerPoint mLocalPanStartPoint;
|
|
|
|
ParentLayerPoint mLocalPanDisplacement;
|
2015-08-25 20:21:41 -07:00
|
|
|
|
|
|
|
// See lineOrPageDeltaX/Y on WidgetWheelEvent.
|
|
|
|
int32_t mLineOrPageDeltaX;
|
|
|
|
int32_t mLineOrPageDeltaY;
|
2015-08-11 15:04:55 -07:00
|
|
|
|
|
|
|
bool mHandledByAPZ;
|
2015-08-11 21:11:54 -07:00
|
|
|
|
2015-08-28 13:50:00 -07:00
|
|
|
// If this is true, and this event started a new input block that couldn't
|
|
|
|
// find a scrollable target which is scrollable in the horizontal component
|
|
|
|
// of the scroll start direction, then this input block needs to be put on
|
|
|
|
// hold until a content response has arrived, even if the block has a
|
|
|
|
// confirmed target.
|
|
|
|
// This is used by events that can result in a swipe instead of a scroll.
|
|
|
|
bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection;
|
2014-06-06 15:49:49 -07:00
|
|
|
};
|
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
/**
|
|
|
|
* Encapsulation class for pinch events. In general, these will be generated by
|
|
|
|
* a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
|
|
|
|
* determining whether or not the user was trying to do a gesture.
|
|
|
|
*/
|
|
|
|
class PinchGestureInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum PinchGestureType
|
|
|
|
{
|
|
|
|
PINCHGESTURE_START,
|
|
|
|
PINCHGESTURE_SCALE,
|
|
|
|
PINCHGESTURE_END
|
|
|
|
};
|
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a tap gesture from a Screen point.
|
|
|
|
// mLocalFocusPoint remains (0,0) unless it's set later.
|
2012-07-19 23:48:25 -07:00
|
|
|
PinchGestureInput(PinchGestureType aType,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aTime,
|
2014-06-05 22:29:49 -07:00
|
|
|
TimeStamp aTimeStamp,
|
2013-06-11 15:13:11 -07:00
|
|
|
const ScreenPoint& aFocusPoint,
|
2012-07-19 23:48:25 -07:00
|
|
|
float aCurrentSpan,
|
2013-11-25 20:30:26 -08:00
|
|
|
float aPreviousSpan,
|
|
|
|
Modifiers aModifiers)
|
2014-06-05 22:29:49 -07:00
|
|
|
: InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
|
2012-07-19 23:48:25 -07:00
|
|
|
mType(aType),
|
|
|
|
mFocusPoint(aFocusPoint),
|
|
|
|
mCurrentSpan(aCurrentSpan),
|
|
|
|
mPreviousSpan(aPreviousSpan)
|
|
|
|
{
|
2014-11-10 11:35:11 -08:00
|
|
|
}
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a tap gesture from a ParentLayer point.
|
|
|
|
// mFocusPoint remains (0,0) unless it's set later.
|
|
|
|
PinchGestureInput(PinchGestureType aType,
|
|
|
|
uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ParentLayerPoint& aLocalFocusPoint,
|
|
|
|
float aCurrentSpan,
|
|
|
|
float aPreviousSpan,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
|
|
|
|
mType(aType),
|
|
|
|
mLocalFocusPoint(aLocalFocusPoint),
|
|
|
|
mCurrentSpan(aCurrentSpan),
|
|
|
|
mPreviousSpan(aPreviousSpan)
|
|
|
|
{
|
2012-07-19 23:48:25 -07:00
|
|
|
}
|
|
|
|
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-01-09 10:39:08 -08:00
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
PinchGestureType mType;
|
|
|
|
|
|
|
|
// Center point of the pinch gesture. That is, if there are two fingers on the
|
|
|
|
// screen, it is their midpoint. In the case of more than two fingers, the
|
|
|
|
// point is implementation-specific, but can for example be the midpoint
|
|
|
|
// between the very first and very last touch. This is in device pixels and
|
|
|
|
// are the coordinates on the screen of this midpoint.
|
2015-11-22 05:57:45 -08:00
|
|
|
// For PINCHGESTURE_END events, this instead will hold the coordinates of
|
|
|
|
// the remaining finger, if there is one. If there isn't one then it will
|
|
|
|
// store -1, -1.
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenPoint mFocusPoint;
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// |mFocusPoint| transformed to the local coordinates of the APZC targeted
|
|
|
|
// by the hit. This is set and used by APZ.
|
|
|
|
ParentLayerPoint mLocalFocusPoint;
|
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
// The distance in device pixels (though as a float for increased precision
|
|
|
|
// and because it is the distance along both the x and y axis) between the
|
|
|
|
// touches responsible for the pinch gesture.
|
|
|
|
float mCurrentSpan;
|
|
|
|
|
|
|
|
// The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
|
|
|
|
// This is only really relevant during a PINCHGESTURE_SCALE because when it is
|
|
|
|
// of this type then there must have been a history of spans.
|
|
|
|
float mPreviousSpan;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encapsulation class for tap events. In general, these will be generated by
|
|
|
|
* a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
|
|
|
|
* determining whether or not the user was trying to do a gesture.
|
|
|
|
*/
|
|
|
|
class TapGestureInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum TapGestureType
|
|
|
|
{
|
|
|
|
TAPGESTURE_LONG,
|
2013-12-11 16:39:06 -08:00
|
|
|
TAPGESTURE_LONG_UP,
|
2012-07-19 23:48:25 -07:00
|
|
|
TAPGESTURE_UP,
|
|
|
|
TAPGESTURE_CONFIRMED,
|
|
|
|
TAPGESTURE_DOUBLE,
|
|
|
|
TAPGESTURE_CANCEL
|
|
|
|
};
|
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a tap gesture from a Screen point.
|
|
|
|
// mLocalPoint remains (0,0) unless it's set later.
|
2013-11-25 20:30:26 -08:00
|
|
|
TapGestureInput(TapGestureType aType,
|
|
|
|
uint32_t aTime,
|
2014-06-05 22:29:49 -07:00
|
|
|
TimeStamp aTimeStamp,
|
2013-11-25 20:30:26 -08:00
|
|
|
const ScreenIntPoint& aPoint,
|
|
|
|
Modifiers aModifiers)
|
2014-06-05 22:29:49 -07:00
|
|
|
: InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
|
2012-07-19 23:48:25 -07:00
|
|
|
mType(aType),
|
|
|
|
mPoint(aPoint)
|
|
|
|
{
|
2014-11-10 11:35:11 -08:00
|
|
|
}
|
2012-07-19 23:48:25 -07:00
|
|
|
|
2014-11-10 11:35:11 -08:00
|
|
|
// Construct a tap gesture from a ParentLayer point.
|
|
|
|
// mPoint remains (0,0) unless it's set later.
|
|
|
|
TapGestureInput(TapGestureType aType,
|
|
|
|
uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
const ParentLayerPoint& aLocalPoint,
|
|
|
|
Modifiers aModifiers)
|
|
|
|
: InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
|
|
|
|
mType(aType),
|
|
|
|
mLocalPoint(aLocalPoint)
|
|
|
|
{
|
2012-07-19 23:48:25 -07:00
|
|
|
}
|
|
|
|
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-01-09 10:39:08 -08:00
|
|
|
|
2012-07-19 23:48:25 -07:00
|
|
|
TapGestureType mType;
|
2014-11-10 11:35:11 -08:00
|
|
|
|
|
|
|
// The location of the tap in screen pixels.
|
2013-06-11 15:13:11 -07:00
|
|
|
ScreenIntPoint mPoint;
|
2014-11-10 11:35:11 -08:00
|
|
|
|
|
|
|
// The location of the tap in the local coordinates of the APZC receiving it.
|
|
|
|
// This is set and used by APZ.
|
|
|
|
ParentLayerPoint mLocalPoint;
|
2012-07-19 23:48:25 -07:00
|
|
|
};
|
|
|
|
|
2014-11-17 20:56:18 -08:00
|
|
|
// Encapsulation class for scroll-wheel events. These are generated by mice
|
|
|
|
// with physical scroll wheels, and on Windows by most touchpads when using
|
|
|
|
// scroll gestures.
|
|
|
|
class ScrollWheelInput : public InputData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum ScrollDeltaType
|
|
|
|
{
|
|
|
|
// There are three kinds of scroll delta modes in Gecko: "page", "line" and
|
2015-04-13 12:45:37 -07:00
|
|
|
// "pixel". For apz, we currently only support the "line" and "pixel" modes.
|
|
|
|
SCROLLDELTA_LINE,
|
2015-12-02 17:05:11 -08:00
|
|
|
SCROLLDELTA_PAGE,
|
2015-04-13 12:45:37 -07:00
|
|
|
SCROLLDELTA_PIXEL
|
2014-11-17 20:56:18 -08:00
|
|
|
};
|
|
|
|
|
2015-04-13 12:45:37 -07:00
|
|
|
static ScrollDeltaType
|
|
|
|
DeltaTypeForDeltaMode(uint32_t aDeltaMode)
|
|
|
|
{
|
|
|
|
switch (aDeltaMode) {
|
|
|
|
case nsIDOMWheelEvent::DOM_DELTA_LINE:
|
|
|
|
return SCROLLDELTA_LINE;
|
2015-12-02 17:05:11 -08:00
|
|
|
case nsIDOMWheelEvent::DOM_DELTA_PAGE:
|
|
|
|
return SCROLLDELTA_PAGE;
|
2015-04-13 12:45:37 -07:00
|
|
|
case nsIDOMWheelEvent::DOM_DELTA_PIXEL:
|
|
|
|
return SCROLLDELTA_PIXEL;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
return SCROLLDELTA_LINE;
|
|
|
|
}
|
|
|
|
|
2014-11-17 20:56:18 -08:00
|
|
|
enum ScrollMode
|
|
|
|
{
|
|
|
|
SCROLLMODE_INSTANT,
|
|
|
|
SCROLLMODE_SMOOTH
|
|
|
|
};
|
|
|
|
|
|
|
|
ScrollWheelInput(uint32_t aTime,
|
|
|
|
TimeStamp aTimeStamp,
|
|
|
|
Modifiers aModifiers,
|
|
|
|
ScrollMode aScrollMode,
|
|
|
|
ScrollDeltaType aDeltaType,
|
|
|
|
const ScreenPoint& aOrigin,
|
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY)
|
|
|
|
: InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers),
|
|
|
|
mDeltaType(aDeltaType),
|
|
|
|
mScrollMode(aScrollMode),
|
|
|
|
mOrigin(aOrigin),
|
2015-08-11 15:04:55 -07:00
|
|
|
mHandledByAPZ(false),
|
2014-11-17 20:56:18 -08:00
|
|
|
mDeltaX(aDeltaX),
|
2015-08-25 20:21:41 -07:00
|
|
|
mDeltaY(aDeltaY),
|
|
|
|
mLineOrPageDeltaX(0),
|
|
|
|
mLineOrPageDeltaY(0),
|
2015-12-01 13:45:49 -08:00
|
|
|
mScrollSeriesNumber(0),
|
2015-12-01 13:46:07 -08:00
|
|
|
mUserDeltaMultiplierX(1.0),
|
|
|
|
mUserDeltaMultiplierY(1.0),
|
2015-08-25 20:21:41 -07:00
|
|
|
mIsMomentum(false)
|
2014-11-17 20:56:18 -08:00
|
|
|
{}
|
|
|
|
|
2015-11-18 16:32:37 -08:00
|
|
|
explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
|
|
|
|
|
2015-08-25 20:21:41 -07:00
|
|
|
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
|
2015-11-30 17:14:31 -08:00
|
|
|
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
|
2015-01-09 10:39:08 -08:00
|
|
|
|
2015-12-01 13:46:07 -08:00
|
|
|
bool IsCustomizedByUserPrefs() const;
|
|
|
|
|
2014-11-17 20:56:18 -08:00
|
|
|
ScrollDeltaType mDeltaType;
|
|
|
|
ScrollMode mScrollMode;
|
|
|
|
ScreenPoint mOrigin;
|
|
|
|
|
2015-08-11 15:04:55 -07:00
|
|
|
bool mHandledByAPZ;
|
|
|
|
|
2014-11-17 20:56:18 -08:00
|
|
|
// Deltas are in units corresponding to the delta type. For line deltas, they
|
|
|
|
// are the number of line units to scroll. The number of device pixels for a
|
|
|
|
// horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
|
2015-08-26 08:14:33 -07:00
|
|
|
// For pixel deltas, these values are in ScreenCoords.
|
2014-11-17 20:56:18 -08:00
|
|
|
//
|
|
|
|
// The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
|
|
|
|
// left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
|
|
|
|
// scrolling down.
|
|
|
|
double mDeltaX;
|
|
|
|
double mDeltaY;
|
|
|
|
|
|
|
|
// The location of the scroll in local coordinates. This is set and used by
|
|
|
|
// APZ.
|
|
|
|
ParentLayerPoint mLocalOrigin;
|
2015-08-25 20:21:41 -07:00
|
|
|
|
|
|
|
// See lineOrPageDeltaX/Y on WidgetWheelEvent.
|
|
|
|
int32_t mLineOrPageDeltaX;
|
|
|
|
int32_t mLineOrPageDeltaY;
|
|
|
|
|
2015-12-01 13:45:49 -08:00
|
|
|
// Indicates the order in which this event was added to a transaction. The
|
|
|
|
// first event is 1; if not a member of a transaction, this is 0.
|
|
|
|
uint32_t mScrollSeriesNumber;
|
|
|
|
|
2015-12-01 13:46:07 -08:00
|
|
|
// User-set delta multipliers.
|
|
|
|
double mUserDeltaMultiplierX;
|
|
|
|
double mUserDeltaMultiplierY;
|
|
|
|
|
2015-08-25 20:21:41 -07:00
|
|
|
bool mIsMomentum;
|
2014-11-17 20:56:18 -08:00
|
|
|
};
|
|
|
|
|
2015-07-13 08:25:42 -07:00
|
|
|
} // namespace mozilla
|
2012-07-19 23:48:25 -07:00
|
|
|
|
|
|
|
#endif // InputData_h__
|