/work/obj-fuzz/dist/include/mozilla/layers/LayersMessageUtils.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_LayersMessageUtils |
8 | | #define mozilla_layers_LayersMessageUtils |
9 | | |
10 | | #include "FrameMetrics.h" |
11 | | #include "base/process_util.h" |
12 | | #include "chrome/common/ipc_message_utils.h" |
13 | | #include "gfxTelemetry.h" |
14 | | #include "ipc/IPCMessageUtils.h" |
15 | | #include "ipc/nsGUIEventIPC.h" |
16 | | #include "mozilla/GfxMessageUtils.h" |
17 | | #include "mozilla/layers/AsyncDragMetrics.h" |
18 | | #include "mozilla/layers/CompositorOptions.h" |
19 | | #include "mozilla/layers/CompositorTypes.h" |
20 | | #include "mozilla/layers/FocusTarget.h" |
21 | | #include "mozilla/layers/GeckoContentController.h" |
22 | | #include "mozilla/layers/KeyboardMap.h" |
23 | | #include "mozilla/layers/LayerAttributes.h" |
24 | | #include "mozilla/layers/LayersTypes.h" |
25 | | #include "mozilla/layers/RefCountedShmem.h" |
26 | | #include "mozilla/Move.h" |
27 | | |
28 | | #include <stdint.h> |
29 | | |
30 | | #ifdef _MSC_VER |
31 | | #pragma warning( disable : 4800 ) |
32 | | #endif |
33 | | |
34 | | namespace IPC { |
35 | | |
36 | | template <> |
37 | | struct ParamTraits<mozilla::layers::LayersId> |
38 | | : public PlainOldDataSerializer<mozilla::layers::LayersId> |
39 | | {}; |
40 | | |
41 | | template <> |
42 | | struct ParamTraits<mozilla::layers::TransactionId> |
43 | | : public PlainOldDataSerializer<mozilla::layers::TransactionId> |
44 | | {}; |
45 | | |
46 | | template <> |
47 | | struct ParamTraits<mozilla::layers::LayersObserverEpoch> |
48 | | : public PlainOldDataSerializer<mozilla::layers::LayersObserverEpoch> |
49 | | {}; |
50 | | |
51 | | template <> |
52 | | struct ParamTraits<mozilla::layers::LayersBackend> |
53 | | : public ContiguousEnumSerializer< |
54 | | mozilla::layers::LayersBackend, |
55 | | mozilla::layers::LayersBackend::LAYERS_NONE, |
56 | | mozilla::layers::LayersBackend::LAYERS_LAST> |
57 | | {}; |
58 | | |
59 | | template <> |
60 | | struct ParamTraits<mozilla::layers::ScaleMode> |
61 | | : public ContiguousEnumSerializerInclusive< |
62 | | mozilla::layers::ScaleMode, |
63 | | mozilla::layers::ScaleMode::SCALE_NONE, |
64 | | mozilla::layers::kHighestScaleMode> |
65 | | {}; |
66 | | |
67 | | template <> |
68 | | struct ParamTraits<mozilla::layers::TextureFlags> |
69 | | : public BitFlagsEnumSerializer< |
70 | | mozilla::layers::TextureFlags, |
71 | | mozilla::layers::TextureFlags::ALL_BITS> |
72 | | {}; |
73 | | |
74 | | template <> |
75 | | struct ParamTraits<mozilla::layers::DiagnosticTypes> |
76 | | : public BitFlagsEnumSerializer< |
77 | | mozilla::layers::DiagnosticTypes, |
78 | | mozilla::layers::DiagnosticTypes::ALL_BITS> |
79 | | {}; |
80 | | |
81 | | template <> |
82 | | struct ParamTraits<mozilla::layers::ScrollDirection> |
83 | | : public ContiguousEnumSerializerInclusive< |
84 | | mozilla::layers::ScrollDirection, |
85 | | mozilla::layers::ScrollDirection::eVertical, |
86 | | mozilla::layers::kHighestScrollDirection> |
87 | | {}; |
88 | | |
89 | | template<> |
90 | | struct ParamTraits<mozilla::layers::FrameMetrics::ScrollOffsetUpdateType> |
91 | | : public ContiguousEnumSerializerInclusive< |
92 | | mozilla::layers::FrameMetrics::ScrollOffsetUpdateType, |
93 | | mozilla::layers::FrameMetrics::ScrollOffsetUpdateType::eNone, |
94 | | mozilla::layers::FrameMetrics::sHighestScrollOffsetUpdateType> |
95 | | {}; |
96 | | |
97 | | template <> |
98 | | struct ParamTraits<mozilla::layers::OverscrollBehavior> |
99 | | : public ContiguousEnumSerializerInclusive< |
100 | | mozilla::layers::OverscrollBehavior, |
101 | | mozilla::layers::OverscrollBehavior::Auto, |
102 | | mozilla::layers::kHighestOverscrollBehavior> |
103 | | {}; |
104 | | |
105 | | template<> |
106 | | struct ParamTraits<mozilla::layers::LayerHandle> |
107 | | { |
108 | | typedef mozilla::layers::LayerHandle paramType; |
109 | | |
110 | 0 | static void Write(Message* msg, const paramType& param) { |
111 | 0 | WriteParam(msg, param.mHandle); |
112 | 0 | } |
113 | 0 | static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { |
114 | 0 | return ReadParam(msg, iter, &result->mHandle); |
115 | 0 | } |
116 | | }; |
117 | | |
118 | | template<> |
119 | | struct ParamTraits<mozilla::layers::CompositableHandle> |
120 | | { |
121 | | typedef mozilla::layers::CompositableHandle paramType; |
122 | | |
123 | 0 | static void Write(Message* msg, const paramType& param) { |
124 | 0 | WriteParam(msg, param.mHandle); |
125 | 0 | } |
126 | 0 | static bool Read(const Message* msg, PickleIterator* iter, paramType* result) { |
127 | 0 | return ReadParam(msg, iter, &result->mHandle); |
128 | 0 | } |
129 | | }; |
130 | | |
131 | | // Helper class for reading bitfields. |
132 | | // If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>. |
133 | | template <typename ParamType> |
134 | | struct BitfieldHelper |
135 | | { |
136 | | // We need this helper because we can't get the address of a bitfield to |
137 | | // pass directly to ReadParam. So instead we read it into a temporary bool |
138 | | // and set the bitfield using a setter function |
139 | | static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter, |
140 | | ParamType* aResult, void (ParamType::*aSetter)(bool)) |
141 | 0 | { |
142 | 0 | bool value; |
143 | 0 | if (ReadParam(aMsg, aIter, &value)) { |
144 | 0 | (aResult->*aSetter)(value); |
145 | 0 | return true; |
146 | 0 | } |
147 | 0 | return false; |
148 | 0 | } Unexecuted instantiation: IPC::BitfieldHelper<mozilla::layers::FrameMetrics>::ReadBoolForBitfield(IPC::Message const*, PickleIterator*, mozilla::layers::FrameMetrics*, void (mozilla::layers::FrameMetrics::*)(bool)) Unexecuted instantiation: IPC::BitfieldHelper<mozilla::layers::ScrollMetadata>::ReadBoolForBitfield(IPC::Message const*, PickleIterator*, mozilla::layers::ScrollMetadata*, void (mozilla::layers::ScrollMetadata::*)(bool)) |
149 | | }; |
150 | | |
151 | | template <> |
152 | | struct ParamTraits<mozilla::layers::FrameMetrics> |
153 | | : BitfieldHelper<mozilla::layers::FrameMetrics> |
154 | | { |
155 | | typedef mozilla::layers::FrameMetrics paramType; |
156 | | |
157 | | static void Write(Message* aMsg, const paramType& aParam) |
158 | 0 | { |
159 | 0 | WriteParam(aMsg, aParam.mScrollId); |
160 | 0 | WriteParam(aMsg, aParam.mPresShellResolution); |
161 | 0 | WriteParam(aMsg, aParam.mCompositionBounds); |
162 | 0 | WriteParam(aMsg, aParam.mDisplayPort); |
163 | 0 | WriteParam(aMsg, aParam.mCriticalDisplayPort); |
164 | 0 | WriteParam(aMsg, aParam.mScrollableRect); |
165 | 0 | WriteParam(aMsg, aParam.mCumulativeResolution); |
166 | 0 | WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel); |
167 | 0 | WriteParam(aMsg, aParam.mScrollOffset); |
168 | 0 | WriteParam(aMsg, aParam.mZoom); |
169 | 0 | WriteParam(aMsg, aParam.mScrollGeneration); |
170 | 0 | WriteParam(aMsg, aParam.mSmoothScrollOffset); |
171 | 0 | WriteParam(aMsg, aParam.mRootCompositionSize); |
172 | 0 | WriteParam(aMsg, aParam.mDisplayPortMargins); |
173 | 0 | WriteParam(aMsg, aParam.mPresShellId); |
174 | 0 | WriteParam(aMsg, aParam.mViewport); |
175 | 0 | WriteParam(aMsg, aParam.mExtraResolution); |
176 | 0 | WriteParam(aMsg, aParam.mPaintRequestTime); |
177 | 0 | WriteParam(aMsg, aParam.mScrollUpdateType); |
178 | 0 | WriteParam(aMsg, aParam.mIsRootContent); |
179 | 0 | WriteParam(aMsg, aParam.mDoSmoothScroll); |
180 | 0 | WriteParam(aMsg, aParam.mUseDisplayPortMargins); |
181 | 0 | WriteParam(aMsg, aParam.mIsScrollInfoLayer); |
182 | 0 | } |
183 | | |
184 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
185 | 0 | { |
186 | 0 | return (ReadParam(aMsg, aIter, &aResult->mScrollId) && |
187 | 0 | ReadParam(aMsg, aIter, &aResult->mPresShellResolution) && |
188 | 0 | ReadParam(aMsg, aIter, &aResult->mCompositionBounds) && |
189 | 0 | ReadParam(aMsg, aIter, &aResult->mDisplayPort) && |
190 | 0 | ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) && |
191 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollableRect) && |
192 | 0 | ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) && |
193 | 0 | ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) && |
194 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollOffset) && |
195 | 0 | ReadParam(aMsg, aIter, &aResult->mZoom) && |
196 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollGeneration) && |
197 | 0 | ReadParam(aMsg, aIter, &aResult->mSmoothScrollOffset) && |
198 | 0 | ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) && |
199 | 0 | ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) && |
200 | 0 | ReadParam(aMsg, aIter, &aResult->mPresShellId) && |
201 | 0 | ReadParam(aMsg, aIter, &aResult->mViewport) && |
202 | 0 | ReadParam(aMsg, aIter, &aResult->mExtraResolution) && |
203 | 0 | ReadParam(aMsg, aIter, &aResult->mPaintRequestTime) && |
204 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollUpdateType) && |
205 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsRootContent) && |
206 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetDoSmoothScroll) && |
207 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetUseDisplayPortMargins) && |
208 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsScrollInfoLayer)); |
209 | 0 | } |
210 | | }; |
211 | | |
212 | | template <> |
213 | | struct ParamTraits<mozilla::layers::ScrollSnapInfo> |
214 | | { |
215 | | typedef mozilla::layers::ScrollSnapInfo paramType; |
216 | | |
217 | | static void Write(Message* aMsg, const paramType& aParam) |
218 | 0 | { |
219 | 0 | WriteParam(aMsg, aParam.mScrollSnapTypeX); |
220 | 0 | WriteParam(aMsg, aParam.mScrollSnapTypeY); |
221 | 0 | WriteParam(aMsg, aParam.mScrollSnapIntervalX); |
222 | 0 | WriteParam(aMsg, aParam.mScrollSnapIntervalY); |
223 | 0 | WriteParam(aMsg, aParam.mScrollSnapDestination); |
224 | 0 | WriteParam(aMsg, aParam.mScrollSnapCoordinates); |
225 | 0 | } |
226 | | |
227 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
228 | 0 | { |
229 | 0 | return (ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeX) && |
230 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeY) && |
231 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalX) && |
232 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalY) && |
233 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollSnapDestination) && |
234 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollSnapCoordinates)); |
235 | 0 | } |
236 | | }; |
237 | | |
238 | | template <> |
239 | | struct ParamTraits<mozilla::layers::OverscrollBehaviorInfo> |
240 | | { |
241 | | // Not using PlainOldDataSerializer so we get enum validation |
242 | | // for the members. |
243 | | |
244 | | typedef mozilla::layers::OverscrollBehaviorInfo paramType; |
245 | | |
246 | | static void Write(Message* aMsg, const paramType& aParam) |
247 | 0 | { |
248 | 0 | WriteParam(aMsg, aParam.mBehaviorX); |
249 | 0 | WriteParam(aMsg, aParam.mBehaviorY); |
250 | 0 | } |
251 | | |
252 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
253 | 0 | { |
254 | 0 | return (ReadParam(aMsg, aIter, &aResult->mBehaviorX) && |
255 | 0 | ReadParam(aMsg, aIter, &aResult->mBehaviorY)); |
256 | 0 | } |
257 | | }; |
258 | | |
259 | | template <> |
260 | | struct ParamTraits<mozilla::layers::LayerClip> |
261 | | { |
262 | | typedef mozilla::layers::LayerClip paramType; |
263 | | |
264 | | static void Write(Message* aMsg, const paramType& aParam) |
265 | 0 | { |
266 | 0 | WriteParam(aMsg, aParam.mClipRect); |
267 | 0 | WriteParam(aMsg, aParam.mMaskLayerIndex); |
268 | 0 | } |
269 | | |
270 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
271 | 0 | { |
272 | 0 | return (ReadParam(aMsg, aIter, &aResult->mClipRect) && |
273 | 0 | ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex)); |
274 | 0 | } |
275 | | }; |
276 | | |
277 | | template <> |
278 | | struct ParamTraits<mozilla::layers::ScrollMetadata> |
279 | | : BitfieldHelper<mozilla::layers::ScrollMetadata> |
280 | | { |
281 | | typedef mozilla::layers::ScrollMetadata paramType; |
282 | | |
283 | | static void Write(Message* aMsg, const paramType& aParam) |
284 | 0 | { |
285 | 0 | WriteParam(aMsg, aParam.mMetrics); |
286 | 0 | WriteParam(aMsg, aParam.mSnapInfo); |
287 | 0 | WriteParam(aMsg, aParam.mScrollParentId); |
288 | 0 | WriteParam(aMsg, aParam.mBackgroundColor); |
289 | 0 | WriteParam(aMsg, aParam.GetContentDescription()); |
290 | 0 | WriteParam(aMsg, aParam.mLineScrollAmount); |
291 | 0 | WriteParam(aMsg, aParam.mPageScrollAmount); |
292 | 0 | WriteParam(aMsg, aParam.mScrollClip); |
293 | 0 | WriteParam(aMsg, aParam.mHasScrollgrab); |
294 | 0 | WriteParam(aMsg, aParam.mIsLayersIdRoot); |
295 | 0 | WriteParam(aMsg, aParam.mIsAutoDirRootContentRTL); |
296 | 0 | WriteParam(aMsg, aParam.mUsesContainerScrolling); |
297 | 0 | WriteParam(aMsg, aParam.mForceDisableApz); |
298 | 0 | WriteParam(aMsg, aParam.mDisregardedDirection); |
299 | 0 | WriteParam(aMsg, aParam.mOverscrollBehavior); |
300 | 0 | } |
301 | | |
302 | | static bool ReadContentDescription(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
303 | 0 | { |
304 | 0 | nsCString str; |
305 | 0 | if (!ReadParam(aMsg, aIter, &str)) { |
306 | 0 | return false; |
307 | 0 | } |
308 | 0 | aResult->SetContentDescription(str); |
309 | 0 | return true; |
310 | 0 | } |
311 | | |
312 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
313 | 0 | { |
314 | 0 | return (ReadParam(aMsg, aIter, &aResult->mMetrics) && |
315 | 0 | ReadParam(aMsg, aIter, &aResult->mSnapInfo) && |
316 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollParentId) && |
317 | 0 | ReadParam(aMsg, aIter, &aResult->mBackgroundColor) && |
318 | 0 | ReadContentDescription(aMsg, aIter, aResult) && |
319 | 0 | ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) && |
320 | 0 | ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) && |
321 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollClip) && |
322 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetHasScrollgrab) && |
323 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsLayersIdRoot) && |
324 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, |
325 | 0 | ¶mType::SetIsAutoDirRootContentRTL) && |
326 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetUsesContainerScrolling) && |
327 | 0 | ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetForceDisableApz) && |
328 | 0 | ReadParam(aMsg, aIter, &aResult->mDisregardedDirection) && |
329 | 0 | ReadParam(aMsg, aIter, &aResult->mOverscrollBehavior)); |
330 | 0 | } |
331 | | }; |
332 | | |
333 | | template<> |
334 | | struct ParamTraits<mozilla::layers::TextureFactoryIdentifier> |
335 | | { |
336 | | typedef mozilla::layers::TextureFactoryIdentifier paramType; |
337 | | |
338 | | static void Write(Message* aMsg, const paramType& aParam) |
339 | 0 | { |
340 | 0 | WriteParam(aMsg, aParam.mParentBackend); |
341 | 0 | WriteParam(aMsg, aParam.mParentProcessType); |
342 | 0 | WriteParam(aMsg, aParam.mMaxTextureSize); |
343 | 0 | WriteParam(aMsg, aParam.mSupportsTextureDirectMapping); |
344 | 0 | WriteParam(aMsg, aParam.mCompositorUseANGLE); |
345 | 0 | WriteParam(aMsg, aParam.mCompositorUseDComp); |
346 | 0 | WriteParam(aMsg, aParam.mSupportsTextureBlitting); |
347 | 0 | WriteParam(aMsg, aParam.mSupportsPartialUploads); |
348 | 0 | WriteParam(aMsg, aParam.mSupportsComponentAlpha); |
349 | 0 | WriteParam(aMsg, aParam.mUsingAdvancedLayers); |
350 | 0 | WriteParam(aMsg, aParam.mSyncHandle); |
351 | 0 | } |
352 | | |
353 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
354 | 0 | { |
355 | 0 | bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) && |
356 | 0 | ReadParam(aMsg, aIter, &aResult->mParentProcessType) && |
357 | 0 | ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) && |
358 | 0 | ReadParam(aMsg, aIter, &aResult->mSupportsTextureDirectMapping) && |
359 | 0 | ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) && |
360 | 0 | ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) && |
361 | 0 | ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) && |
362 | 0 | ReadParam(aMsg, aIter, &aResult->mSupportsPartialUploads) && |
363 | 0 | ReadParam(aMsg, aIter, &aResult->mSupportsComponentAlpha) && |
364 | 0 | ReadParam(aMsg, aIter, &aResult->mUsingAdvancedLayers) && |
365 | 0 | ReadParam(aMsg, aIter, &aResult->mSyncHandle); |
366 | 0 | return result; |
367 | 0 | } |
368 | | }; |
369 | | |
370 | | template<> |
371 | | struct ParamTraits<mozilla::layers::TextureInfo> |
372 | | { |
373 | | typedef mozilla::layers::TextureInfo paramType; |
374 | | |
375 | | static void Write(Message* aMsg, const paramType& aParam) |
376 | 0 | { |
377 | 0 | WriteParam(aMsg, aParam.mCompositableType); |
378 | 0 | WriteParam(aMsg, aParam.mTextureFlags); |
379 | 0 | } |
380 | | |
381 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
382 | 0 | { |
383 | 0 | return ReadParam(aMsg, aIter, &aResult->mCompositableType) && |
384 | 0 | ReadParam(aMsg, aIter, &aResult->mTextureFlags); |
385 | 0 | } |
386 | | }; |
387 | | |
388 | | template <> |
389 | | struct ParamTraits<mozilla::layers::CompositableType> |
390 | | : public ContiguousEnumSerializer< |
391 | | mozilla::layers::CompositableType, |
392 | | mozilla::layers::CompositableType::UNKNOWN, |
393 | | mozilla::layers::CompositableType::COUNT> |
394 | | {}; |
395 | | |
396 | | template <> |
397 | | struct ParamTraits<mozilla::layers::ScrollableLayerGuid> |
398 | | { |
399 | | typedef mozilla::layers::ScrollableLayerGuid paramType; |
400 | | |
401 | | static void Write(Message* aMsg, const paramType& aParam) |
402 | 0 | { |
403 | 0 | WriteParam(aMsg, aParam.mLayersId); |
404 | 0 | WriteParam(aMsg, aParam.mPresShellId); |
405 | 0 | WriteParam(aMsg, aParam.mScrollId); |
406 | 0 | } |
407 | | |
408 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
409 | 0 | { |
410 | 0 | return (ReadParam(aMsg, aIter, &aResult->mLayersId) && |
411 | 0 | ReadParam(aMsg, aIter, &aResult->mPresShellId) && |
412 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollId)); |
413 | 0 | } |
414 | | }; |
415 | | |
416 | | |
417 | | template <> |
418 | | struct ParamTraits<mozilla::layers::ZoomConstraints> |
419 | | { |
420 | | typedef mozilla::layers::ZoomConstraints paramType; |
421 | | |
422 | | static void Write(Message* aMsg, const paramType& aParam) |
423 | 0 | { |
424 | 0 | WriteParam(aMsg, aParam.mAllowZoom); |
425 | 0 | WriteParam(aMsg, aParam.mAllowDoubleTapZoom); |
426 | 0 | WriteParam(aMsg, aParam.mMinZoom); |
427 | 0 | WriteParam(aMsg, aParam.mMaxZoom); |
428 | 0 | } |
429 | | |
430 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
431 | 0 | { |
432 | 0 | return (ReadParam(aMsg, aIter, &aResult->mAllowZoom) && |
433 | 0 | ReadParam(aMsg, aIter, &aResult->mAllowDoubleTapZoom) && |
434 | 0 | ReadParam(aMsg, aIter, &aResult->mMinZoom) && |
435 | 0 | ReadParam(aMsg, aIter, &aResult->mMaxZoom)); |
436 | 0 | } |
437 | | }; |
438 | | |
439 | | template <> |
440 | | struct ParamTraits<mozilla::layers::EventRegions> |
441 | | { |
442 | | typedef mozilla::layers::EventRegions paramType; |
443 | | |
444 | | static void Write(Message* aMsg, const paramType& aParam) |
445 | 0 | { |
446 | 0 | WriteParam(aMsg, aParam.mHitRegion); |
447 | 0 | WriteParam(aMsg, aParam.mDispatchToContentHitRegion); |
448 | 0 | WriteParam(aMsg, aParam.mNoActionRegion); |
449 | 0 | WriteParam(aMsg, aParam.mHorizontalPanRegion); |
450 | 0 | WriteParam(aMsg, aParam.mVerticalPanRegion); |
451 | 0 | WriteParam(aMsg, aParam.mDTCRequiresTargetConfirmation); |
452 | 0 | } |
453 | | |
454 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
455 | 0 | { |
456 | 0 | return (ReadParam(aMsg, aIter, &aResult->mHitRegion) && |
457 | 0 | ReadParam(aMsg, aIter, &aResult->mDispatchToContentHitRegion) && |
458 | 0 | ReadParam(aMsg, aIter, &aResult->mNoActionRegion) && |
459 | 0 | ReadParam(aMsg, aIter, &aResult->mHorizontalPanRegion) && |
460 | 0 | ReadParam(aMsg, aIter, &aResult->mVerticalPanRegion) && |
461 | 0 | ReadParam(aMsg, aIter, &aResult->mDTCRequiresTargetConfirmation)); |
462 | 0 | } |
463 | | }; |
464 | | |
465 | | template <> |
466 | | struct ParamTraits<mozilla::layers::FocusTarget::ScrollTargets> |
467 | | { |
468 | | typedef mozilla::layers::FocusTarget::ScrollTargets paramType; |
469 | | |
470 | | static void Write(Message* aMsg, const paramType& aParam) |
471 | 0 | { |
472 | 0 | WriteParam(aMsg, aParam.mHorizontal); |
473 | 0 | WriteParam(aMsg, aParam.mVertical); |
474 | 0 | } |
475 | | |
476 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
477 | 0 | { |
478 | 0 | return ReadParam(aMsg, aIter, &aResult->mHorizontal) && |
479 | 0 | ReadParam(aMsg, aIter, &aResult->mVertical); |
480 | 0 | } |
481 | | }; |
482 | | |
483 | | template <> |
484 | | struct ParamTraits<mozilla::layers::FocusTarget::NoFocusTarget> |
485 | | : public EmptyStructSerializer<mozilla::layers::FocusTarget::NoFocusTarget> |
486 | | {}; |
487 | | |
488 | | template <> |
489 | | struct ParamTraits<mozilla::layers::FocusTarget> |
490 | | { |
491 | | typedef mozilla::layers::FocusTarget paramType; |
492 | | |
493 | | static void Write(Message* aMsg, const paramType& aParam) |
494 | 0 | { |
495 | 0 | WriteParam(aMsg, aParam.mSequenceNumber); |
496 | 0 | WriteParam(aMsg, aParam.mFocusHasKeyEventListeners); |
497 | 0 | WriteParam(aMsg, aParam.mData); |
498 | 0 | } |
499 | | |
500 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
501 | 0 | { |
502 | 0 | if (!ReadParam(aMsg, aIter, &aResult->mSequenceNumber) || |
503 | 0 | !ReadParam(aMsg, aIter, &aResult->mFocusHasKeyEventListeners) || |
504 | 0 | !ReadParam(aMsg, aIter, &aResult->mData)) { |
505 | 0 | return false; |
506 | 0 | } |
507 | 0 | return true; |
508 | 0 | } |
509 | | }; |
510 | | |
511 | | template <> |
512 | | struct ParamTraits<mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType> |
513 | | : public ContiguousEnumSerializerInclusive< |
514 | | mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType, |
515 | | mozilla::layers::KeyboardScrollAction::KeyboardScrollActionType::eScrollCharacter, |
516 | | mozilla::layers::KeyboardScrollAction::sHighestKeyboardScrollActionType> |
517 | | {}; |
518 | | |
519 | | template <> |
520 | | struct ParamTraits<mozilla::layers::KeyboardScrollAction> |
521 | | { |
522 | | typedef mozilla::layers::KeyboardScrollAction paramType; |
523 | | |
524 | | static void Write(Message* aMsg, const paramType& aParam) |
525 | 0 | { |
526 | 0 | WriteParam(aMsg, aParam.mType); |
527 | 0 | WriteParam(aMsg, aParam.mForward); |
528 | 0 | } |
529 | | |
530 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
531 | 0 | { |
532 | 0 | return ReadParam(aMsg, aIter, &aResult->mType) && |
533 | 0 | ReadParam(aMsg, aIter, &aResult->mForward); |
534 | 0 | } |
535 | | }; |
536 | | |
537 | | template <> |
538 | | struct ParamTraits<mozilla::layers::KeyboardShortcut> |
539 | | { |
540 | | typedef mozilla::layers::KeyboardShortcut paramType; |
541 | | |
542 | | static void Write(Message* aMsg, const paramType& aParam) |
543 | 0 | { |
544 | 0 | WriteParam(aMsg, aParam.mAction); |
545 | 0 | WriteParam(aMsg, aParam.mKeyCode); |
546 | 0 | WriteParam(aMsg, aParam.mCharCode); |
547 | 0 | WriteParam(aMsg, aParam.mModifiers); |
548 | 0 | WriteParam(aMsg, aParam.mModifiersMask); |
549 | 0 | WriteParam(aMsg, aParam.mEventType); |
550 | 0 | WriteParam(aMsg, aParam.mDispatchToContent); |
551 | 0 | } |
552 | | |
553 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
554 | 0 | { |
555 | 0 | return ReadParam(aMsg, aIter, &aResult->mAction) && |
556 | 0 | ReadParam(aMsg, aIter, &aResult->mKeyCode) && |
557 | 0 | ReadParam(aMsg, aIter, &aResult->mCharCode) && |
558 | 0 | ReadParam(aMsg, aIter, &aResult->mModifiers) && |
559 | 0 | ReadParam(aMsg, aIter, &aResult->mModifiersMask) && |
560 | 0 | ReadParam(aMsg, aIter, &aResult->mEventType) && |
561 | 0 | ReadParam(aMsg, aIter, &aResult->mDispatchToContent); |
562 | 0 | } |
563 | | }; |
564 | | |
565 | | template <> |
566 | | struct ParamTraits<mozilla::layers::KeyboardMap> |
567 | | { |
568 | | typedef mozilla::layers::KeyboardMap paramType; |
569 | | |
570 | | static void Write(Message* aMsg, const paramType& aParam) |
571 | 0 | { |
572 | 0 | WriteParam(aMsg, aParam.Shortcuts()); |
573 | 0 | } |
574 | | |
575 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
576 | 0 | { |
577 | 0 | nsTArray<mozilla::layers::KeyboardShortcut> shortcuts; |
578 | 0 | if (!ReadParam(aMsg, aIter, &shortcuts)) { |
579 | 0 | return false; |
580 | 0 | } |
581 | 0 | *aResult = mozilla::layers::KeyboardMap(std::move(shortcuts)); |
582 | 0 | return true; |
583 | 0 | } |
584 | | }; |
585 | | |
586 | | typedef mozilla::layers::GeckoContentController GeckoContentController; |
587 | | typedef GeckoContentController::TapType TapType; |
588 | | |
589 | | template <> |
590 | | struct ParamTraits<TapType> |
591 | | : public ContiguousEnumSerializerInclusive< |
592 | | TapType, |
593 | | TapType::eSingleTap, |
594 | | GeckoContentController::sHighestTapType> |
595 | | {}; |
596 | | |
597 | | typedef GeckoContentController::APZStateChange APZStateChange; |
598 | | |
599 | | template <> |
600 | | struct ParamTraits<APZStateChange> |
601 | | : public ContiguousEnumSerializerInclusive< |
602 | | APZStateChange, |
603 | | APZStateChange::eTransformBegin, |
604 | | GeckoContentController::sHighestAPZStateChange> |
605 | | {}; |
606 | | |
607 | | template<> |
608 | | struct ParamTraits<mozilla::layers::EventRegionsOverride> |
609 | | : public BitFlagsEnumSerializer< |
610 | | mozilla::layers::EventRegionsOverride, |
611 | | mozilla::layers::EventRegionsOverride::ALL_BITS> |
612 | | {}; |
613 | | |
614 | | template<> |
615 | | struct ParamTraits<mozilla::layers::AsyncDragMetrics> |
616 | | { |
617 | | typedef mozilla::layers::AsyncDragMetrics paramType; |
618 | | |
619 | | static void Write(Message* aMsg, const paramType& aParam) |
620 | 0 | { |
621 | 0 | WriteParam(aMsg, aParam.mViewId); |
622 | 0 | WriteParam(aMsg, aParam.mPresShellId); |
623 | 0 | WriteParam(aMsg, aParam.mDragStartSequenceNumber); |
624 | 0 | WriteParam(aMsg, aParam.mScrollbarDragOffset); |
625 | 0 | WriteParam(aMsg, aParam.mDirection); |
626 | 0 | } |
627 | | |
628 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
629 | 0 | { |
630 | 0 | return (ReadParam(aMsg, aIter, &aResult->mViewId) && |
631 | 0 | ReadParam(aMsg, aIter, &aResult->mPresShellId) && |
632 | 0 | ReadParam(aMsg, aIter, &aResult->mDragStartSequenceNumber) && |
633 | 0 | ReadParam(aMsg, aIter, &aResult->mScrollbarDragOffset) && |
634 | 0 | ReadParam(aMsg, aIter, &aResult->mDirection)); |
635 | 0 | } |
636 | | }; |
637 | | |
638 | | template <> |
639 | | struct ParamTraits<mozilla::layers::CompositorOptions> |
640 | | { |
641 | | typedef mozilla::layers::CompositorOptions paramType; |
642 | | |
643 | 0 | static void Write(Message* aMsg, const paramType& aParam) { |
644 | 0 | WriteParam(aMsg, aParam.mUseAPZ); |
645 | 0 | WriteParam(aMsg, aParam.mUseWebRender); |
646 | 0 | WriteParam(aMsg, aParam.mUseAdvancedLayers); |
647 | 0 | WriteParam(aMsg, aParam.mInitiallyPaused); |
648 | 0 | } |
649 | | |
650 | 0 | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { |
651 | 0 | return ReadParam(aMsg, aIter, &aResult->mUseAPZ) |
652 | 0 | && ReadParam(aMsg, aIter, &aResult->mUseWebRender) |
653 | 0 | && ReadParam(aMsg, aIter, &aResult->mUseAdvancedLayers) |
654 | 0 | && ReadParam(aMsg, aIter, &aResult->mInitiallyPaused); |
655 | 0 | } |
656 | | }; |
657 | | |
658 | | template <> |
659 | | struct ParamTraits<mozilla::layers::SimpleLayerAttributes> |
660 | | : public PlainOldDataSerializer<mozilla::layers::SimpleLayerAttributes> |
661 | | { }; |
662 | | |
663 | | template <> |
664 | | struct ParamTraits<mozilla::layers::ScrollUpdateInfo> |
665 | | : public PlainOldDataSerializer<mozilla::layers::ScrollUpdateInfo> |
666 | | {}; |
667 | | |
668 | | } /* namespace IPC */ |
669 | | |
670 | | #endif /* mozilla_layers_LayersMessageUtils */ |