/work/obj-fuzz/dist/include/mozilla/layers/APZInputBridge.h
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 | | #ifndef mozilla_layers_APZInputBridge_h |
8 | | #define mozilla_layers_APZInputBridge_h |
9 | | |
10 | | #include "APZUtils.h" // for APZWheelAction |
11 | | #include "mozilla/EventForwards.h" // for WidgetInputEvent, nsEventStatus |
12 | | #include "Units.h" // for LayoutDeviceIntPoint |
13 | | |
14 | | namespace mozilla { |
15 | | |
16 | | class InputData; |
17 | | |
18 | | namespace layers { |
19 | | |
20 | | class APZInputBridgeParent; |
21 | | struct ScrollableLayerGuid; |
22 | | |
23 | | /** |
24 | | * This class lives in the main process, and is accessed via the controller |
25 | | * thread (which is the process main thread for desktop, and the Java UI |
26 | | * thread for Android). This class exposes a synchronous API to deliver |
27 | | * incoming input events to APZ and modify them in-place to unapply the APZ |
28 | | * async transform. If there is a GPU process, then this class does sync IPC |
29 | | * calls over to the GPU process in order to accomplish this. Otherwise, |
30 | | * APZCTreeManager overrides and implements these methods directly. |
31 | | */ |
32 | | class APZInputBridge { |
33 | | public: |
34 | | /** |
35 | | * General handler for incoming input events. Manipulates the frame metrics |
36 | | * based on what type of input it is. For example, a PinchGestureEvent will |
37 | | * cause scaling. This should only be called externally to this class, and |
38 | | * must be called on the controller thread. |
39 | | * |
40 | | * This function transforms |aEvent| to have its coordinates in DOM space. |
41 | | * This is so that the event can be passed through the DOM and content can |
42 | | * handle them. The event may need to be converted to a WidgetInputEvent |
43 | | * by the caller if it wants to do this. |
44 | | * |
45 | | * The following values may be returned by this function: |
46 | | * nsEventStatus_eConsumeNoDefault is returned to indicate the |
47 | | * APZ is consuming this event and the caller should discard the event with |
48 | | * extreme prejudice. The exact scenarios under which this is returned is |
49 | | * implementation-dependent and may vary. |
50 | | * nsEventStatus_eIgnore is returned to indicate that the APZ code didn't |
51 | | * use this event. This might be because it was directed at a point on |
52 | | * the screen where there was no APZ, or because the thing the user was |
53 | | * trying to do was not allowed. (For example, attempting to pan a |
54 | | * non-pannable document). |
55 | | * nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ |
56 | | * code may have used this event to do some user-visible thing. Note that |
57 | | * in some cases CONSUMED is returned even if the event was NOT used. This |
58 | | * is because we cannot always know at the time of event delivery whether |
59 | | * the event will be used or not. So we err on the side of sending |
60 | | * CONSUMED when we are uncertain. |
61 | | * |
62 | | * @param aEvent input event object; is modified in-place |
63 | | * @param aOutTargetGuid returns the guid of the apzc this event was |
64 | | * delivered to. May be null. |
65 | | * @param aOutInputBlockId returns the id of the input block that this event |
66 | | * was added to, if that was the case. May be null. |
67 | | */ |
68 | | virtual nsEventStatus ReceiveInputEvent( |
69 | | InputData& aEvent, |
70 | | ScrollableLayerGuid* aOutTargetGuid, |
71 | | uint64_t* aOutInputBlockId) = 0; |
72 | | |
73 | | /** |
74 | | * WidgetInputEvent handler. Transforms |aEvent| (which is assumed to be an |
75 | | * already-existing instance of an WidgetInputEvent which may be an |
76 | | * WidgetTouchEvent) to have its coordinates in DOM space. This is so that the |
77 | | * event can be passed through the DOM and content can handle them. |
78 | | * |
79 | | * NOTE: Be careful of invoking the WidgetInputEvent variant. This can only be |
80 | | * called on the main thread. See widget/InputData.h for more information on |
81 | | * why we have InputData and WidgetInputEvent separated. If this function is |
82 | | * used, the controller thread must be the main thread, or undefined behaviour |
83 | | * may occur. |
84 | | * NOTE: On unix, mouse events are treated as touch and are forwarded |
85 | | * to the appropriate apz as such. |
86 | | * |
87 | | * See documentation for other ReceiveInputEvent above. |
88 | | */ |
89 | | nsEventStatus ReceiveInputEvent( |
90 | | WidgetInputEvent& aEvent, |
91 | | ScrollableLayerGuid* aOutTargetGuid, |
92 | | uint64_t* aOutInputBlockId); |
93 | | |
94 | | // Returns the kind of wheel event action, if any, that will be (or was) |
95 | | // performed by APZ. If this returns true, the event must not perform a |
96 | | // synchronous scroll. |
97 | | // |
98 | | // Even if this returns Nothing(), all wheel events in APZ-aware widgets must |
99 | | // be sent through APZ so they are transformed correctly for TabParent. |
100 | | static Maybe<APZWheelAction> ActionForWheelEvent(WidgetWheelEvent* aEvent); |
101 | | |
102 | | protected: |
103 | | friend class APZInputBridgeParent; |
104 | | |
105 | | // Methods to help process WidgetInputEvents (or manage conversion to/from InputData) |
106 | | |
107 | | virtual void ProcessUnhandledEvent( |
108 | | LayoutDeviceIntPoint* aRefPoint, |
109 | | ScrollableLayerGuid* aOutTargetGuid, |
110 | | uint64_t* aOutFocusSequenceNumber) = 0; |
111 | | |
112 | | virtual void UpdateWheelTransaction( |
113 | | LayoutDeviceIntPoint aRefPoint, |
114 | | EventMessage aEventMessage) = 0; |
115 | | |
116 | 0 | virtual ~APZInputBridge() { } |
117 | | }; |
118 | | |
119 | | } // namespace layers |
120 | | } // namespace mozilla |
121 | | |
122 | | #endif // mozilla_layers_APZInputBridge_h |