Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=4 ts=8 et 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/. */
7 #ifndef mozilla_layers_GeckoContentController_h
8 #define mozilla_layers_GeckoContentController_h
10 #include "FrameMetrics.h" // for FrameMetrics, etc
11 #include "Units.h" // for CSSPoint, CSSRect, etc
12 #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
13 #include "nsISupportsImpl.h"
15 class Task;
17 namespace mozilla {
18 namespace layers {
20 class GeckoContentController
21 {
22 public:
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoContentController)
25 /**
26 * Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
27 * Implementations per-platform are responsible for actually handling this.
28 */
29 virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
31 /**
32 * Acknowledges the recipt of a scroll offset update for the scrollable
33 * frame with the given scroll id. This is used to maintain consistency
34 * between APZ and other sources of scroll changes.
35 */
36 virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
37 const uint32_t& aScrollGeneration) = 0;
39 /**
40 * Requests handling of a double tap. |aPoint| is in CSS pixels, relative to
41 * the current scroll offset. This should eventually round-trip back to
42 * AsyncPanZoomController::ZoomToRect with the dimensions that we want to zoom
43 * to.
44 */
45 virtual void HandleDoubleTap(const CSSPoint& aPoint,
46 int32_t aModifiers,
47 const ScrollableLayerGuid& aGuid) = 0;
49 /**
50 * Requests handling a single tap. |aPoint| is in CSS pixels, relative to the
51 * current scroll offset. This should simulate and send to content a mouse
52 * button down, then mouse button up at |aPoint|.
53 */
54 virtual void HandleSingleTap(const CSSPoint& aPoint,
55 int32_t aModifiers,
56 const ScrollableLayerGuid& aGuid) = 0;
58 /**
59 * Requests handling a long tap. |aPoint| is in CSS pixels, relative to the
60 * current scroll offset.
61 */
62 virtual void HandleLongTap(const CSSPoint& aPoint,
63 int32_t aModifiers,
64 const ScrollableLayerGuid& aGuid) = 0;
66 /**
67 * Requests handling of releasing a long tap. |aPoint| is in CSS pixels,
68 * relative to the current scroll offset. HandleLongTapUp will always be
69 * preceeded by HandleLongTap
70 */
71 virtual void HandleLongTapUp(const CSSPoint& aPoint,
72 int32_t aModifiers,
73 const ScrollableLayerGuid& aGuid) = 0;
75 /**
76 * Requests sending a mozbrowserasyncscroll domevent to embedder.
77 * |aContentRect| is in CSS pixels, relative to the current cssPage.
78 * |aScrollableSize| is the current content width/height in CSS pixels.
79 */
80 virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
81 const CSSRect &aContentRect,
82 const CSSSize &aScrollableSize) = 0;
84 /**
85 * Schedules a runnable to run on the controller/UI thread at some time
86 * in the future.
87 */
88 virtual void PostDelayedTask(Task* aTask, int aDelayMs) = 0;
90 /**
91 * Retrieves the last known zoom constraints for the root scrollable layer
92 * for this layers tree. This function should return false if there are no
93 * last known zoom constraints.
94 */
95 virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints)
96 {
97 return false;
98 }
100 /**
101 * APZ uses |FrameMetrics::mCompositionBounds| for hit testing. Sometimes,
102 * widget code has knowledge of a touch-sensitive region that should
103 * additionally constrain hit testing for all frames associated with the
104 * controller. This method allows APZ to query the controller for such a
105 * region. A return value of true indicates that the controller has such a
106 * region, and it is returned in |aOutRegion|.
107 * TODO: once bug 928833 is implemented, this should be removed, as
108 * APZ can then get the correct touch-sensitive region for each frame
109 * directly from the layer.
110 */
111 virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion)
112 {
113 return false;
114 }
116 MOZ_BEGIN_NESTED_ENUM_CLASS(APZStateChange, int8_t)
117 /**
118 * APZ started modifying the view (including panning, zooming, and fling).
119 */
120 TransformBegin,
121 /**
122 * APZ finished modifying the view.
123 */
124 TransformEnd,
125 /**
126 * APZ started a touch.
127 * |aArg| is 1 if touch can be a pan, 0 otherwise.
128 */
129 StartTouch,
130 /**
131 * APZ started a pan.
132 */
133 StartPanning,
134 /**
135 * APZ finished processing a touch.
136 * |aArg| is 1 if touch was a click, 0 otherwise.
137 */
138 EndTouch,
139 APZStateChangeSentinel
140 MOZ_END_NESTED_ENUM_CLASS(APZStateChange)
142 /**
143 * General notices of APZ state changes for consumers.
144 * |aGuid| identifies the APZC originating the state change.
145 * |aChange| identifies the type of state change
146 * |aArg| is used by some state changes to pass extra information (see
147 * the documentation for each state change above)
148 */
149 virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
150 APZStateChange aChange,
151 int aArg = 0) {}
153 GeckoContentController() {}
155 protected:
156 // Protected destructor, to discourage deletion outside of Release():
157 virtual ~GeckoContentController() {}
158 };
160 MOZ_FINISH_NESTED_ENUM_CLASS(GeckoContentController::APZStateChange)
162 }
163 }
165 #endif // mozilla_layers_GeckoContentController_h