/src/mozilla-central/gfx/layers/ipc/APZCTreeManagerParent.cpp
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 | | #include "mozilla/layers/APZCTreeManagerParent.h" |
8 | | |
9 | | #include "apz/src/APZCTreeManager.h" |
10 | | #include "mozilla/layers/APZThreadUtils.h" |
11 | | #include "mozilla/layers/APZUpdater.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace layers { |
15 | | |
16 | | APZCTreeManagerParent::APZCTreeManagerParent(LayersId aLayersId, |
17 | | RefPtr<APZCTreeManager> aAPZCTreeManager, |
18 | | RefPtr<APZUpdater> aAPZUpdater) |
19 | | : mLayersId(aLayersId) |
20 | | , mTreeManager(std::move(aAPZCTreeManager)) |
21 | | , mUpdater(std::move(aAPZUpdater)) |
22 | 0 | { |
23 | 0 | MOZ_ASSERT(mTreeManager != nullptr); |
24 | 0 | MOZ_ASSERT(mUpdater != nullptr); |
25 | 0 | MOZ_ASSERT(mUpdater->HasTreeManager(mTreeManager)); |
26 | 0 | } |
27 | | |
28 | | APZCTreeManagerParent::~APZCTreeManagerParent() |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | | void |
33 | | APZCTreeManagerParent::ChildAdopted(RefPtr<APZCTreeManager> aAPZCTreeManager, |
34 | | RefPtr<APZUpdater> aAPZUpdater) |
35 | 0 | { |
36 | 0 | MOZ_ASSERT(aAPZCTreeManager != nullptr); |
37 | 0 | MOZ_ASSERT(aAPZUpdater != nullptr); |
38 | 0 | MOZ_ASSERT(aAPZUpdater->HasTreeManager(aAPZCTreeManager)); |
39 | 0 | mTreeManager = std::move(aAPZCTreeManager); |
40 | 0 | mUpdater = std::move(aAPZUpdater); |
41 | 0 | } |
42 | | |
43 | | mozilla::ipc::IPCResult |
44 | | APZCTreeManagerParent::RecvSetKeyboardMap(const KeyboardMap& aKeyboardMap) |
45 | 0 | { |
46 | 0 | mUpdater->RunOnControllerThread(mLayersId, NewRunnableMethod<KeyboardMap>( |
47 | 0 | "layers::IAPZCTreeManager::SetKeyboardMap", |
48 | 0 | mTreeManager, |
49 | 0 | &IAPZCTreeManager::SetKeyboardMap, |
50 | 0 | aKeyboardMap)); |
51 | 0 |
|
52 | 0 | return IPC_OK(); |
53 | 0 | } |
54 | | |
55 | | mozilla::ipc::IPCResult |
56 | | APZCTreeManagerParent::RecvZoomToRect( |
57 | | const ScrollableLayerGuid& aGuid, |
58 | | const CSSRect& aRect, |
59 | | const uint32_t& aFlags) |
60 | 0 | { |
61 | 0 | if (aGuid.mLayersId != mLayersId) { |
62 | 0 | // Guard against bad data from hijacked child processes |
63 | 0 | NS_ERROR("Unexpected layers id in RecvZoomToRect; dropping message..."); |
64 | 0 | return IPC_FAIL_NO_REASON(this); |
65 | 0 | } |
66 | 0 |
|
67 | 0 | mUpdater->RunOnControllerThread( |
68 | 0 | mLayersId, |
69 | 0 | NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>( |
70 | 0 | "layers::IAPZCTreeManager::ZoomToRect", |
71 | 0 | mTreeManager, |
72 | 0 | &IAPZCTreeManager::ZoomToRect, |
73 | 0 | aGuid, aRect, aFlags)); |
74 | 0 | return IPC_OK(); |
75 | 0 | } |
76 | | |
77 | | mozilla::ipc::IPCResult |
78 | | APZCTreeManagerParent::RecvContentReceivedInputBlock( |
79 | | const uint64_t& aInputBlockId, |
80 | | const bool& aPreventDefault) |
81 | 0 | { |
82 | 0 | mUpdater->RunOnControllerThread(mLayersId, NewRunnableMethod<uint64_t, bool>( |
83 | 0 | "layers::IAPZCTreeManager::ContentReceivedInputBlock", |
84 | 0 | mTreeManager, |
85 | 0 | &IAPZCTreeManager::ContentReceivedInputBlock, |
86 | 0 | aInputBlockId, |
87 | 0 | aPreventDefault)); |
88 | 0 |
|
89 | 0 | return IPC_OK(); |
90 | 0 | } |
91 | | |
92 | | mozilla::ipc::IPCResult |
93 | | APZCTreeManagerParent::RecvSetTargetAPZC( |
94 | | const uint64_t& aInputBlockId, |
95 | | nsTArray<ScrollableLayerGuid>&& aTargets) |
96 | 0 | { |
97 | 0 | for (size_t i = 0; i < aTargets.Length(); i++) { |
98 | 0 | if (aTargets[i].mLayersId != mLayersId) { |
99 | 0 | // Guard against bad data from hijacked child processes |
100 | 0 | NS_ERROR("Unexpected layers id in RecvSetTargetAPZC; dropping message..."); |
101 | 0 | return IPC_FAIL_NO_REASON(this); |
102 | 0 | } |
103 | 0 | } |
104 | 0 | mUpdater->RunOnControllerThread( |
105 | 0 | mLayersId, |
106 | 0 | NewRunnableMethod<uint64_t, |
107 | 0 | StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>( |
108 | 0 | "layers::IAPZCTreeManager::SetTargetAPZC", |
109 | 0 | mTreeManager, |
110 | 0 | &IAPZCTreeManager::SetTargetAPZC, |
111 | 0 | aInputBlockId, |
112 | 0 | aTargets)); |
113 | 0 |
|
114 | 0 | return IPC_OK(); |
115 | 0 | } |
116 | | |
117 | | mozilla::ipc::IPCResult |
118 | | APZCTreeManagerParent::RecvUpdateZoomConstraints( |
119 | | const ScrollableLayerGuid& aGuid, |
120 | | const MaybeZoomConstraints& aConstraints) |
121 | 0 | { |
122 | 0 | if (aGuid.mLayersId != mLayersId) { |
123 | 0 | // Guard against bad data from hijacked child processes |
124 | 0 | NS_ERROR("Unexpected layers id in RecvUpdateZoomConstraints; dropping message..."); |
125 | 0 | return IPC_FAIL_NO_REASON(this); |
126 | 0 | } |
127 | 0 |
|
128 | 0 | mTreeManager->UpdateZoomConstraints(aGuid, aConstraints); |
129 | 0 | return IPC_OK(); |
130 | 0 | } |
131 | | |
132 | | mozilla::ipc::IPCResult |
133 | | APZCTreeManagerParent::RecvSetDPI(const float& aDpiValue) |
134 | 0 | { |
135 | 0 | mUpdater->RunOnControllerThread(mLayersId, NewRunnableMethod<float>( |
136 | 0 | "layers::IAPZCTreeManager::SetDPI", |
137 | 0 | mTreeManager, |
138 | 0 | &IAPZCTreeManager::SetDPI, |
139 | 0 | aDpiValue)); |
140 | 0 | return IPC_OK(); |
141 | 0 | } |
142 | | |
143 | | mozilla::ipc::IPCResult |
144 | | APZCTreeManagerParent::RecvSetAllowedTouchBehavior( |
145 | | const uint64_t& aInputBlockId, |
146 | | nsTArray<TouchBehaviorFlags>&& aValues) |
147 | 0 | { |
148 | 0 | mUpdater->RunOnControllerThread( |
149 | 0 | mLayersId, |
150 | 0 | NewRunnableMethod<uint64_t, |
151 | 0 | StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>( |
152 | 0 | "layers::IAPZCTreeManager::SetAllowedTouchBehavior", |
153 | 0 | mTreeManager, |
154 | 0 | &IAPZCTreeManager::SetAllowedTouchBehavior, |
155 | 0 | aInputBlockId, |
156 | 0 | std::move(aValues))); |
157 | 0 |
|
158 | 0 | return IPC_OK(); |
159 | 0 | } |
160 | | |
161 | | mozilla::ipc::IPCResult |
162 | | APZCTreeManagerParent::RecvStartScrollbarDrag( |
163 | | const ScrollableLayerGuid& aGuid, |
164 | | const AsyncDragMetrics& aDragMetrics) |
165 | 0 | { |
166 | 0 | if (aGuid.mLayersId != mLayersId) { |
167 | 0 | // Guard against bad data from hijacked child processes |
168 | 0 | NS_ERROR("Unexpected layers id in RecvStartScrollbarDrag; dropping message..."); |
169 | 0 | return IPC_FAIL_NO_REASON(this); |
170 | 0 | } |
171 | 0 |
|
172 | 0 | mUpdater->RunOnControllerThread( |
173 | 0 | mLayersId, |
174 | 0 | NewRunnableMethod<ScrollableLayerGuid, AsyncDragMetrics>( |
175 | 0 | "layers::IAPZCTreeManager::StartScrollbarDrag", |
176 | 0 | mTreeManager, |
177 | 0 | &IAPZCTreeManager::StartScrollbarDrag, |
178 | 0 | aGuid, |
179 | 0 | aDragMetrics)); |
180 | 0 |
|
181 | 0 | return IPC_OK(); |
182 | 0 | } |
183 | | |
184 | | mozilla::ipc::IPCResult |
185 | | APZCTreeManagerParent::RecvStartAutoscroll( |
186 | | const ScrollableLayerGuid& aGuid, |
187 | | const ScreenPoint& aAnchorLocation) |
188 | 0 | { |
189 | 0 | // Unlike RecvStartScrollbarDrag(), this message comes from the parent |
190 | 0 | // process (via nsBaseWidget::mAPZC) rather than from the child process |
191 | 0 | // (via TabChild::mApzcTreeManager), so there is no need to check the |
192 | 0 | // layers id against mLayersId (and in any case, it wouldn't match, because |
193 | 0 | // mLayersId stores the parent process's layers id, while nsBaseWidget is |
194 | 0 | // sending the child process's layers id). |
195 | 0 |
|
196 | 0 | mUpdater->RunOnControllerThread( |
197 | 0 | mLayersId, |
198 | 0 | NewRunnableMethod<ScrollableLayerGuid, ScreenPoint>( |
199 | 0 | "layers::IAPZCTreeManager::StartAutoscroll", |
200 | 0 | mTreeManager, |
201 | 0 | &IAPZCTreeManager::StartAutoscroll, |
202 | 0 | aGuid, aAnchorLocation)); |
203 | 0 |
|
204 | 0 | return IPC_OK(); |
205 | 0 | } |
206 | | |
207 | | mozilla::ipc::IPCResult |
208 | | APZCTreeManagerParent::RecvStopAutoscroll(const ScrollableLayerGuid& aGuid) |
209 | 0 | { |
210 | 0 | // See RecvStartAutoscroll() for why we don't check the layers id. |
211 | 0 |
|
212 | 0 | mUpdater->RunOnControllerThread( |
213 | 0 | mLayersId, |
214 | 0 | NewRunnableMethod<ScrollableLayerGuid>( |
215 | 0 | "layers::IAPZCTreeManager::StopAutoscroll", |
216 | 0 | mTreeManager, |
217 | 0 | &IAPZCTreeManager::StopAutoscroll, |
218 | 0 | aGuid)); |
219 | 0 |
|
220 | 0 | return IPC_OK(); |
221 | 0 | } |
222 | | |
223 | | mozilla::ipc::IPCResult |
224 | | APZCTreeManagerParent::RecvSetLongTapEnabled(const bool& aLongTapEnabled) |
225 | 0 | { |
226 | 0 | mUpdater->RunOnControllerThread( |
227 | 0 | mLayersId, |
228 | 0 | NewRunnableMethod<bool>( |
229 | 0 | "layers::IAPZCTreeManager::SetLongTapEnabled", |
230 | 0 | mTreeManager, |
231 | 0 | &IAPZCTreeManager::SetLongTapEnabled, |
232 | 0 | aLongTapEnabled)); |
233 | 0 |
|
234 | 0 | return IPC_OK(); |
235 | 0 | } |
236 | | |
237 | | } // namespace layers |
238 | | } // namespace mozilla |