InputData.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef InputData_h__
  6. #define InputData_h__
  7. #include "nsDebug.h"
  8. #include "nsIDOMWheelEvent.h"
  9. #include "nsIScrollableFrame.h"
  10. #include "nsPoint.h"
  11. #include "nsTArray.h"
  12. #include "Units.h"
  13. #include "mozilla/EventForwards.h"
  14. #include "mozilla/TimeStamp.h"
  15. #include "mozilla/gfx/MatrixFwd.h"
  16. template<class E> struct already_AddRefed;
  17. class nsIWidget;
  18. namespace mozilla {
  19. namespace layers {
  20. class PAPZCTreeManagerParent;
  21. class APZCTreeManagerChild;
  22. }
  23. namespace dom {
  24. class Touch;
  25. } // namespace dom
  26. enum InputType
  27. {
  28. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  29. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  30. MULTITOUCH_INPUT,
  31. MOUSE_INPUT,
  32. PANGESTURE_INPUT,
  33. PINCHGESTURE_INPUT,
  34. TAPGESTURE_INPUT,
  35. SCROLLWHEEL_INPUT,
  36. // Used as an upper bound for ContiguousEnumSerializer
  37. SENTINEL_INPUT,
  38. };
  39. class MultiTouchInput;
  40. class MouseInput;
  41. class PanGestureInput;
  42. class PinchGestureInput;
  43. class TapGestureInput;
  44. class ScrollWheelInput;
  45. // This looks unnecessary now, but as we add more and more classes that derive
  46. // from InputType (eventually probably almost as many as *Events.h has), it
  47. // will be more and more clear what's going on with a macro that shortens the
  48. // definition of the RTTI functions.
  49. #define INPUTDATA_AS_CHILD_TYPE(type, enumID) \
  50. const type& As##type() const \
  51. { \
  52. MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
  53. return (const type&) *this; \
  54. } \
  55. type& As##type() \
  56. { \
  57. MOZ_ASSERT(mInputType == enumID, "Invalid cast of InputData."); \
  58. return (type&) *this; \
  59. }
  60. /** Base input data class. Should never be instantiated. */
  61. class InputData
  62. {
  63. public:
  64. // Warning, this class is serialized and sent over IPC. Any change to its
  65. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  66. InputType mInputType;
  67. // Time in milliseconds that this data is relevant to. This only really
  68. // matters when this data is used as an event. We use uint32_t instead of
  69. // TimeStamp because it is easier to convert from WidgetInputEvent. The time
  70. // is platform-specific but it in the case of B2G and Fennec it is since
  71. // startup.
  72. uint32_t mTime;
  73. // Set in parallel to mTime until we determine it is safe to drop
  74. // platform-specific event times (see bug 77992).
  75. TimeStamp mTimeStamp;
  76. Modifiers modifiers;
  77. INPUTDATA_AS_CHILD_TYPE(MultiTouchInput, MULTITOUCH_INPUT)
  78. INPUTDATA_AS_CHILD_TYPE(MouseInput, MOUSE_INPUT)
  79. INPUTDATA_AS_CHILD_TYPE(PanGestureInput, PANGESTURE_INPUT)
  80. INPUTDATA_AS_CHILD_TYPE(PinchGestureInput, PINCHGESTURE_INPUT)
  81. INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
  82. INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput, SCROLLWHEEL_INPUT)
  83. virtual ~InputData();
  84. explicit InputData(InputType aInputType);
  85. protected:
  86. InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp,
  87. Modifiers aModifiers);
  88. };
  89. /**
  90. * Data container for a single touch input. Similar to dom::Touch, but used in
  91. * off-main-thread situations. This is more for just storing touch data, whereas
  92. * dom::Touch is more useful for dispatching through the DOM (which can only
  93. * happen on the main thread). dom::Touch also bears the problem of storing
  94. * pointers to nsIWidget instances which can only be used on the main thread,
  95. * so if instead we used dom::Touch and ever set these pointers
  96. * off-main-thread, Bad Things Can Happen(tm).
  97. *
  98. * Note that this doesn't inherit from InputData because this itself is not an
  99. * event. It is only a container/struct that should have any number of instances
  100. * within a MultiTouchInput.
  101. *
  102. * fixme/bug 775746: Make dom::Touch inherit from this class.
  103. */
  104. class SingleTouchData
  105. {
  106. public:
  107. // Construct a SingleTouchData from a Screen point.
  108. // mLocalScreenPoint remains (0,0) unless it's set later.
  109. SingleTouchData(int32_t aIdentifier,
  110. ScreenIntPoint aScreenPoint,
  111. ScreenSize aRadius,
  112. float aRotationAngle,
  113. float aForce);
  114. // Construct a SingleTouchData from a ParentLayer point.
  115. // mScreenPoint remains (0,0) unless it's set later.
  116. // Note: if APZ starts using the radius for anything, we should add a local
  117. // version of that too, and have this constructor take it as a ParentLayerSize.
  118. SingleTouchData(int32_t aIdentifier,
  119. ParentLayerPoint aLocalScreenPoint,
  120. ScreenSize aRadius,
  121. float aRotationAngle,
  122. float aForce);
  123. SingleTouchData();
  124. already_AddRefed<dom::Touch> ToNewDOMTouch() const;
  125. // Warning, this class is serialized and sent over IPC. Any change to its
  126. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  127. // A unique number assigned to each SingleTouchData within a MultiTouchInput so
  128. // that they can be easily distinguished when handling a touch start/move/end.
  129. int32_t mIdentifier;
  130. // Point on the screen that the touch hit, in device pixels. They are
  131. // coordinates on the screen.
  132. ScreenIntPoint mScreenPoint;
  133. // |mScreenPoint| transformed to the local coordinates of the APZC targeted
  134. // by the hit. This is set and used by APZ.
  135. ParentLayerPoint mLocalScreenPoint;
  136. // Radius that the touch covers, i.e. if you're using your thumb it will
  137. // probably be larger than using your pinky, even with the same force.
  138. // Radius can be different along x and y. For example, if you press down with
  139. // your entire finger vertically, the y radius will be much larger than the x
  140. // radius.
  141. ScreenSize mRadius;
  142. float mRotationAngle;
  143. // How hard the screen is being pressed.
  144. float mForce;
  145. };
  146. /**
  147. * Similar to WidgetTouchEvent, but for use off-main-thread. Also only stores a
  148. * screen touch point instead of the many different coordinate spaces
  149. * WidgetTouchEvent stores its touch point in. This includes a way to initialize
  150. * itself from a WidgetTouchEvent by copying all relevant data over. Note that
  151. * this copying from WidgetTouchEvent functionality can only be used on the main
  152. * thread.
  153. *
  154. * Stores an array of SingleTouchData.
  155. */
  156. class MultiTouchInput : public InputData
  157. {
  158. public:
  159. enum MultiTouchType
  160. {
  161. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  162. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  163. MULTITOUCH_START,
  164. MULTITOUCH_MOVE,
  165. MULTITOUCH_END,
  166. MULTITOUCH_CANCEL,
  167. // Used as an upper bound for ContiguousEnumSerializer
  168. MULTITOUCH_SENTINEL,
  169. };
  170. MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
  171. Modifiers aModifiers);
  172. MultiTouchInput();
  173. MultiTouchInput(const MultiTouchInput& aOther);
  174. explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
  175. // This conversion from WidgetMouseEvent to MultiTouchInput is needed because
  176. // on the B2G emulator we can only receive mouse events, but we need to be
  177. // able to pan correctly. To do this, we convert the events into a format that
  178. // the panning code can handle. This code is very limited and only supports
  179. // SingleTouchData. It also sends garbage for the identifier, radius, force
  180. // and rotation angle.
  181. explicit MultiTouchInput(const WidgetMouseEvent& aMouseEvent);
  182. WidgetTouchEvent ToWidgetTouchEvent(nsIWidget* aWidget) const;
  183. WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
  184. // Return the index into mTouches of the SingleTouchData with the given
  185. // identifier, or -1 if there is no such SingleTouchData.
  186. int32_t IndexOfTouch(int32_t aTouchIdentifier);
  187. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  188. // Warning, this class is serialized and sent over IPC. Any change to its
  189. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  190. MultiTouchType mType;
  191. nsTArray<SingleTouchData> mTouches;
  192. bool mHandledByAPZ;
  193. };
  194. class MouseInput : public InputData
  195. {
  196. protected:
  197. friend mozilla::layers::PAPZCTreeManagerParent;
  198. friend mozilla::layers::APZCTreeManagerChild;
  199. MouseInput();
  200. public:
  201. enum MouseType
  202. {
  203. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  204. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  205. MOUSE_NONE,
  206. MOUSE_MOVE,
  207. MOUSE_DOWN,
  208. MOUSE_UP,
  209. MOUSE_DRAG_START,
  210. MOUSE_DRAG_END,
  211. MOUSE_WIDGET_ENTER,
  212. MOUSE_WIDGET_EXIT,
  213. // Used as an upper bound for ContiguousEnumSerializer
  214. MOUSE_SENTINEL,
  215. };
  216. enum ButtonType
  217. {
  218. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  219. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  220. LEFT_BUTTON,
  221. MIDDLE_BUTTON,
  222. RIGHT_BUTTON,
  223. NONE,
  224. // Used as an upper bound for ContiguousEnumSerializer
  225. BUTTON_SENTINEL,
  226. };
  227. MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource,
  228. int16_t aButtons, const ScreenPoint& aPoint, uint32_t aTime,
  229. TimeStamp aTimeStamp, Modifiers aModifiers);
  230. explicit MouseInput(const WidgetMouseEventBase& aMouseEvent);
  231. bool IsLeftButton() const;
  232. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  233. WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
  234. // Warning, this class is serialized and sent over IPC. Any change to its
  235. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  236. MouseType mType;
  237. ButtonType mButtonType;
  238. uint16_t mInputSource;
  239. int16_t mButtons;
  240. ScreenPoint mOrigin;
  241. ParentLayerPoint mLocalOrigin;
  242. bool mHandledByAPZ;
  243. };
  244. /**
  245. * Encapsulation class for pan events, can be used off-main-thread.
  246. * These events are currently only used for scrolling on desktop.
  247. */
  248. class PanGestureInput : public InputData
  249. {
  250. protected:
  251. friend mozilla::layers::PAPZCTreeManagerParent;
  252. friend mozilla::layers::APZCTreeManagerChild;
  253. PanGestureInput();
  254. public:
  255. enum PanGestureType
  256. {
  257. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  258. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  259. // MayStart: Dispatched before any actual panning has occurred but when a
  260. // pan gesture is probably about to start, for example when the user
  261. // starts touching the touchpad. Should interrupt any ongoing APZ
  262. // animation and can be used to trigger scrollability indicators (e.g.
  263. // flashing overlay scrollbars).
  264. PANGESTURE_MAYSTART,
  265. // Cancelled: Dispatched after MayStart when no pan gesture is going to
  266. // happen after all, for example when the user lifts their fingers from a
  267. // touchpad without having done any scrolling.
  268. PANGESTURE_CANCELLED,
  269. // Start: A pan gesture is starting.
  270. // For devices that do not support the MayStart event type, this event can
  271. // be used to interrupt ongoing APZ animations.
  272. PANGESTURE_START,
  273. // Pan: The actual pan motion by mPanDisplacement.
  274. PANGESTURE_PAN,
  275. // End: The pan gesture has ended, for example because the user has lifted
  276. // their fingers from a touchpad after scrolling.
  277. // Any potential momentum events fire after this event.
  278. PANGESTURE_END,
  279. // The following momentum event types are used in order to control the pan
  280. // momentum animation. Using these instead of our own animation ensures
  281. // that the animation curve is OS native and that the animation stops
  282. // reliably if it is cancelled by the user.
  283. // MomentumStart: Dispatched between the End event of the actual
  284. // user-controlled pan, and the first MomentumPan event of the momentum
  285. // animation.
  286. PANGESTURE_MOMENTUMSTART,
  287. // MomentumPan: The actual momentum motion by mPanDisplacement.
  288. PANGESTURE_MOMENTUMPAN,
  289. // MomentumEnd: The momentum animation has ended, for example because the
  290. // momentum velocity has gone below the stopping threshold, or because the
  291. // user has stopped the animation by putting their fingers on a touchpad.
  292. PANGESTURE_MOMENTUMEND,
  293. // Used as an upper bound for ContiguousEnumSerializer
  294. PANGESTURE_SENTINEL,
  295. };
  296. PanGestureInput(PanGestureType aType,
  297. uint32_t aTime,
  298. TimeStamp aTimeStamp,
  299. const ScreenPoint& aPanStartPoint,
  300. const ScreenPoint& aPanDisplacement,
  301. Modifiers aModifiers);
  302. bool IsMomentum() const;
  303. WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
  304. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  305. ScreenPoint UserMultipliedPanDisplacement() const;
  306. ParentLayerPoint UserMultipliedLocalPanDisplacement() const;
  307. // Warning, this class is serialized and sent over IPC. Any change to its
  308. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  309. PanGestureType mType;
  310. ScreenPoint mPanStartPoint;
  311. // The delta. This can be non-zero on any type of event.
  312. ScreenPoint mPanDisplacement;
  313. // Versions of |mPanStartPoint| and |mPanDisplacement| in the local
  314. // coordinates of the APZC receiving the pan. These are set and used by APZ.
  315. ParentLayerPoint mLocalPanStartPoint;
  316. ParentLayerPoint mLocalPanDisplacement;
  317. // See lineOrPageDeltaX/Y on WidgetWheelEvent.
  318. int32_t mLineOrPageDeltaX;
  319. int32_t mLineOrPageDeltaY;
  320. // User-set delta multipliers.
  321. double mUserDeltaMultiplierX;
  322. double mUserDeltaMultiplierY;
  323. bool mHandledByAPZ;
  324. // true if this is a PANGESTURE_END event that will be followed by a
  325. // PANGESTURE_MOMENTUMSTART event.
  326. bool mFollowedByMomentum;
  327. // If this is true, and this event started a new input block that couldn't
  328. // find a scrollable target which is scrollable in the horizontal component
  329. // of the scroll start direction, then this input block needs to be put on
  330. // hold until a content response has arrived, even if the block has a
  331. // confirmed target.
  332. // This is used by events that can result in a swipe instead of a scroll.
  333. bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection;
  334. };
  335. /**
  336. * Encapsulation class for pinch events. In general, these will be generated by
  337. * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
  338. * determining whether or not the user was trying to do a gesture.
  339. */
  340. class PinchGestureInput : public InputData
  341. {
  342. protected:
  343. friend mozilla::layers::PAPZCTreeManagerParent;
  344. friend mozilla::layers::APZCTreeManagerChild;
  345. PinchGestureInput();
  346. public:
  347. enum PinchGestureType
  348. {
  349. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  350. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  351. PINCHGESTURE_START,
  352. PINCHGESTURE_SCALE,
  353. PINCHGESTURE_END,
  354. // Used as an upper bound for ContiguousEnumSerializer
  355. PINCHGESTURE_SENTINEL,
  356. };
  357. // Construct a pinch gesture from a ParentLayer point.
  358. // mFocusPoint remains (0,0) unless it's set later.
  359. PinchGestureInput(PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
  360. const ParentLayerPoint& aLocalFocusPoint,
  361. ParentLayerCoord aCurrentSpan,
  362. ParentLayerCoord aPreviousSpan, Modifiers aModifiers);
  363. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  364. // Warning, this class is serialized and sent over IPC. Any change to its
  365. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  366. PinchGestureType mType;
  367. // Center point of the pinch gesture. That is, if there are two fingers on the
  368. // screen, it is their midpoint. In the case of more than two fingers, the
  369. // point is implementation-specific, but can for example be the midpoint
  370. // between the very first and very last touch. This is in device pixels and
  371. // are the coordinates on the screen of this midpoint.
  372. // For PINCHGESTURE_END events, this instead will hold the coordinates of
  373. // the remaining finger, if there is one. If there isn't one then it will
  374. // store -1, -1.
  375. ScreenPoint mFocusPoint;
  376. // |mFocusPoint| transformed to the local coordinates of the APZC targeted
  377. // by the hit. This is set and used by APZ.
  378. ParentLayerPoint mLocalFocusPoint;
  379. // The distance between the touches responsible for the pinch gesture.
  380. ParentLayerCoord mCurrentSpan;
  381. // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
  382. // This is only really relevant during a PINCHGESTURE_SCALE because when it is
  383. // of this type then there must have been a history of spans.
  384. ParentLayerCoord mPreviousSpan;
  385. };
  386. /**
  387. * Encapsulation class for tap events. In general, these will be generated by
  388. * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
  389. * determining whether or not the user was trying to do a gesture.
  390. */
  391. class TapGestureInput : public InputData
  392. {
  393. protected:
  394. friend mozilla::layers::PAPZCTreeManagerParent;
  395. friend mozilla::layers::APZCTreeManagerChild;
  396. TapGestureInput();
  397. public:
  398. enum TapGestureType
  399. {
  400. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  401. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  402. TAPGESTURE_LONG,
  403. TAPGESTURE_LONG_UP,
  404. TAPGESTURE_UP,
  405. TAPGESTURE_CONFIRMED,
  406. TAPGESTURE_DOUBLE,
  407. TAPGESTURE_SECOND, // See GeckoContentController::TapType::eSecondTap
  408. TAPGESTURE_CANCEL,
  409. // Used as an upper bound for ContiguousEnumSerializer
  410. TAPGESTURE_SENTINEL,
  411. };
  412. // Construct a tap gesture from a Screen point.
  413. // mLocalPoint remains (0,0) unless it's set later.
  414. TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
  415. const ScreenIntPoint& aPoint, Modifiers aModifiers);
  416. // Construct a tap gesture from a ParentLayer point.
  417. // mPoint remains (0,0) unless it's set later.
  418. TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
  419. const ParentLayerPoint& aLocalPoint, Modifiers aModifiers);
  420. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  421. // Warning, this class is serialized and sent over IPC. Any change to its
  422. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  423. TapGestureType mType;
  424. // The location of the tap in screen pixels.
  425. ScreenIntPoint mPoint;
  426. // The location of the tap in the local coordinates of the APZC receiving it.
  427. // This is set and used by APZ.
  428. ParentLayerPoint mLocalPoint;
  429. };
  430. // Encapsulation class for scroll-wheel events. These are generated by mice
  431. // with physical scroll wheels, and on Windows by most touchpads when using
  432. // scroll gestures.
  433. class ScrollWheelInput : public InputData
  434. {
  435. protected:
  436. friend mozilla::layers::PAPZCTreeManagerParent;
  437. friend mozilla::layers::APZCTreeManagerChild;
  438. ScrollWheelInput();
  439. public:
  440. enum ScrollDeltaType
  441. {
  442. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  443. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  444. // There are three kinds of scroll delta modes in Gecko: "page", "line" and
  445. // "pixel".
  446. SCROLLDELTA_LINE,
  447. SCROLLDELTA_PAGE,
  448. SCROLLDELTA_PIXEL,
  449. // Used as an upper bound for ContiguousEnumSerializer
  450. SCROLLDELTA_SENTINEL,
  451. };
  452. enum ScrollMode
  453. {
  454. // Warning, this enum is serialized and sent over IPC. If you reorder, add,
  455. // or remove a value, you need to update its ParamTraits<> in nsGUIEventIPC.h
  456. SCROLLMODE_INSTANT,
  457. SCROLLMODE_SMOOTH,
  458. // Used as an upper bound for ContiguousEnumSerializer
  459. SCROLLMODE_SENTINEL,
  460. };
  461. ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers,
  462. ScrollMode aScrollMode, ScrollDeltaType aDeltaType,
  463. const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY,
  464. bool aAllowToOverrideSystemScrollSpeed);
  465. explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
  466. static ScrollDeltaType DeltaTypeForDeltaMode(uint32_t aDeltaMode);
  467. static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType);
  468. static nsIScrollableFrame::ScrollUnit ScrollUnitForDeltaType(ScrollDeltaType aDeltaType);
  469. WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
  470. bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
  471. bool IsCustomizedByUserPrefs() const;
  472. // Warning, this class is serialized and sent over IPC. Any change to its
  473. // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
  474. ScrollDeltaType mDeltaType;
  475. ScrollMode mScrollMode;
  476. ScreenPoint mOrigin;
  477. bool mHandledByAPZ;
  478. // Deltas are in units corresponding to the delta type. For line deltas, they
  479. // are the number of line units to scroll. The number of device pixels for a
  480. // horizontal and vertical line unit are in FrameMetrics::mLineScrollAmount.
  481. // For pixel deltas, these values are in ScreenCoords.
  482. //
  483. // The horizontal (X) delta is > 0 for scrolling right and < 0 for scrolling
  484. // left. The vertical (Y) delta is < 0 for scrolling up and > 0 for
  485. // scrolling down.
  486. double mDeltaX;
  487. double mDeltaY;
  488. // The location of the scroll in local coordinates. This is set and used by
  489. // APZ.
  490. ParentLayerPoint mLocalOrigin;
  491. // See lineOrPageDeltaX/Y on WidgetWheelEvent.
  492. int32_t mLineOrPageDeltaX;
  493. int32_t mLineOrPageDeltaY;
  494. // Indicates the order in which this event was added to a transaction. The
  495. // first event is 1; if not a member of a transaction, this is 0.
  496. uint32_t mScrollSeriesNumber;
  497. // User-set delta multipliers.
  498. double mUserDeltaMultiplierX;
  499. double mUserDeltaMultiplierY;
  500. bool mMayHaveMomentum;
  501. bool mIsMomentum;
  502. bool mAllowToOverrideSystemScrollSpeed;
  503. };
  504. } // namespace mozilla
  505. #endif // InputData_h__