Bug 1716846 [wpt PR 29402] - Update wpt metadata, a=testonly
[gecko.git] / widget / nsGUIEventIPC.h
blob016e81988303fe7e2d55835be77fe410afc35003
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/. */
6 #ifndef nsGUIEventIPC_h__
7 #define nsGUIEventIPC_h__
9 #include "ipc/EnumSerializer.h"
10 #include "ipc/IPCMessageUtils.h"
11 #include "mozilla/ContentCache.h"
12 #include "mozilla/GfxMessageUtils.h"
13 #include "mozilla/dom/Touch.h"
14 #include "mozilla/layers/LayersMessageUtils.h"
15 #include "mozilla/MiscEvents.h"
16 #include "mozilla/MouseEvents.h"
17 #include "mozilla/TextEvents.h"
18 #include "mozilla/TouchEvents.h"
19 #include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
20 #include "mozilla/dom/Selection.h"
21 #include "InputData.h"
23 namespace IPC {
25 template <>
26 struct ParamTraits<mozilla::EventMessage>
27 : public ContiguousEnumSerializer<
28 mozilla::EventMessage, mozilla::EventMessage(0),
29 mozilla::EventMessage::eEventMessage_MaxValue> {};
31 template <>
32 struct ParamTraits<mozilla::BaseEventFlags> {
33 typedef mozilla::BaseEventFlags paramType;
35 static void Write(Message* aMsg, const paramType& aParam) {
36 aMsg->WriteBytes(&aParam, sizeof(aParam));
39 static bool Read(const Message* aMsg, PickleIterator* aIter,
40 paramType* aResult) {
41 return aMsg->ReadBytesInto(aIter, aResult, sizeof(*aResult));
45 template <>
46 struct ParamTraits<mozilla::WidgetEvent> {
47 typedef mozilla::WidgetEvent paramType;
49 static void Write(Message* aMsg, const paramType& aParam) {
50 // Mark the event as posted to another process.
51 const_cast<mozilla::WidgetEvent&>(aParam).MarkAsPostedToRemoteProcess();
53 WriteParam(aMsg, static_cast<mozilla::EventClassIDType>(aParam.mClass));
54 WriteParam(aMsg, aParam.mMessage);
55 WriteParam(aMsg, aParam.mRefPoint);
56 WriteParam(aMsg, aParam.mFocusSequenceNumber);
57 WriteParam(aMsg, aParam.mTime);
58 WriteParam(aMsg, aParam.mTimeStamp);
59 WriteParam(aMsg, aParam.mFlags);
60 WriteParam(aMsg, aParam.mLayersId);
63 static bool Read(const Message* aMsg, PickleIterator* aIter,
64 paramType* aResult) {
65 mozilla::EventClassIDType eventClassID = 0;
66 bool ret = ReadParam(aMsg, aIter, &eventClassID) &&
67 ReadParam(aMsg, aIter, &aResult->mMessage) &&
68 ReadParam(aMsg, aIter, &aResult->mRefPoint) &&
69 ReadParam(aMsg, aIter, &aResult->mFocusSequenceNumber) &&
70 ReadParam(aMsg, aIter, &aResult->mTime) &&
71 ReadParam(aMsg, aIter, &aResult->mTimeStamp) &&
72 ReadParam(aMsg, aIter, &aResult->mFlags) &&
73 ReadParam(aMsg, aIter, &aResult->mLayersId);
74 aResult->mClass = static_cast<mozilla::EventClassID>(eventClassID);
75 if (ret) {
76 // Reset cross process dispatching state here because the event has not
77 // been dispatched to different process from current process.
78 aResult->ResetCrossProcessDispatchingState();
79 // Mark the event comes from another process.
80 aResult->MarkAsComingFromAnotherProcess();
82 return ret;
86 template <>
87 struct ParamTraits<mozilla::NativeEventData> {
88 typedef mozilla::NativeEventData paramType;
90 static void Write(Message* aMsg, const paramType& aParam) {
91 WriteParam(aMsg, aParam.mBuffer);
94 static bool Read(const Message* aMsg, PickleIterator* aIter,
95 paramType* aResult) {
96 return ReadParam(aMsg, aIter, &aResult->mBuffer);
100 template <>
101 struct ParamTraits<mozilla::WidgetGUIEvent> {
102 typedef mozilla::WidgetGUIEvent paramType;
104 static void Write(Message* aMsg, const paramType& aParam) {
105 WriteParam(aMsg, static_cast<const mozilla::WidgetEvent&>(aParam));
106 WriteParam(aMsg, aParam.mPluginEvent);
109 static bool Read(const Message* aMsg, PickleIterator* aIter,
110 paramType* aResult) {
111 return ReadParam(aMsg, aIter,
112 static_cast<mozilla::WidgetEvent*>(aResult)) &&
113 ReadParam(aMsg, aIter, &aResult->mPluginEvent);
117 template <>
118 struct ParamTraits<mozilla::WidgetInputEvent> {
119 typedef mozilla::WidgetInputEvent paramType;
121 static void Write(Message* aMsg, const paramType& aParam) {
122 WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
123 WriteParam(aMsg, aParam.mModifiers);
126 static bool Read(const Message* aMsg, PickleIterator* aIter,
127 paramType* aResult) {
128 return ReadParam(aMsg, aIter,
129 static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
130 ReadParam(aMsg, aIter, &aResult->mModifiers);
134 template <>
135 struct ParamTraits<mozilla::WidgetMouseEventBase> {
136 typedef mozilla::WidgetMouseEventBase paramType;
138 static void Write(Message* aMsg, const paramType& aParam) {
139 WriteParam(aMsg, static_cast<const mozilla::WidgetInputEvent&>(aParam));
140 WriteParam(aMsg, aParam.mButton);
141 WriteParam(aMsg, aParam.mButtons);
142 WriteParam(aMsg, aParam.mPressure);
143 WriteParam(aMsg, aParam.mInputSource);
146 static bool Read(const Message* aMsg, PickleIterator* aIter,
147 paramType* aResult) {
148 return ReadParam(aMsg, aIter,
149 static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
150 ReadParam(aMsg, aIter, &aResult->mButton) &&
151 ReadParam(aMsg, aIter, &aResult->mButtons) &&
152 ReadParam(aMsg, aIter, &aResult->mPressure) &&
153 ReadParam(aMsg, aIter, &aResult->mInputSource);
157 template <>
158 struct ParamTraits<mozilla::WidgetWheelEvent> {
159 typedef mozilla::WidgetWheelEvent paramType;
161 static void Write(Message* aMsg, const paramType& aParam) {
162 WriteParam(aMsg, static_cast<const mozilla::WidgetMouseEventBase&>(aParam));
163 WriteParam(aMsg, aParam.mDeltaX);
164 WriteParam(aMsg, aParam.mDeltaY);
165 WriteParam(aMsg, aParam.mDeltaZ);
166 WriteParam(aMsg, aParam.mDeltaMode);
167 WriteParam(aMsg, aParam.mWheelTicksX);
168 WriteParam(aMsg, aParam.mWheelTicksY);
169 WriteParam(aMsg, aParam.mCustomizedByUserPrefs);
170 WriteParam(aMsg, aParam.mMayHaveMomentum);
171 WriteParam(aMsg, aParam.mIsMomentum);
172 WriteParam(aMsg, aParam.mIsNoLineOrPageDelta);
173 WriteParam(aMsg, aParam.mLineOrPageDeltaX);
174 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
175 WriteParam(aMsg, static_cast<uint8_t>(aParam.mScrollType));
176 WriteParam(aMsg, aParam.mOverflowDeltaX);
177 WriteParam(aMsg, aParam.mOverflowDeltaY);
178 WriteParam(aMsg, aParam.mViewPortIsOverscrolled);
179 WriteParam(aMsg, aParam.mCanTriggerSwipe);
180 WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed);
181 WriteParam(aMsg, aParam.mDeltaValuesHorizontalizedForDefaultHandler);
184 static bool Read(const Message* aMsg, PickleIterator* aIter,
185 paramType* aResult) {
186 uint8_t scrollType = 0;
187 bool rv =
188 ReadParam(aMsg, aIter,
189 static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
190 ReadParam(aMsg, aIter, &aResult->mDeltaX) &&
191 ReadParam(aMsg, aIter, &aResult->mDeltaY) &&
192 ReadParam(aMsg, aIter, &aResult->mDeltaZ) &&
193 ReadParam(aMsg, aIter, &aResult->mDeltaMode) &&
194 ReadParam(aMsg, aIter, &aResult->mWheelTicksX) &&
195 ReadParam(aMsg, aIter, &aResult->mWheelTicksY) &&
196 ReadParam(aMsg, aIter, &aResult->mCustomizedByUserPrefs) &&
197 ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) &&
198 ReadParam(aMsg, aIter, &aResult->mIsMomentum) &&
199 ReadParam(aMsg, aIter, &aResult->mIsNoLineOrPageDelta) &&
200 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) &&
201 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
202 ReadParam(aMsg, aIter, &scrollType) &&
203 ReadParam(aMsg, aIter, &aResult->mOverflowDeltaX) &&
204 ReadParam(aMsg, aIter, &aResult->mOverflowDeltaY) &&
205 ReadParam(aMsg, aIter, &aResult->mViewPortIsOverscrolled) &&
206 ReadParam(aMsg, aIter, &aResult->mCanTriggerSwipe) &&
207 ReadParam(aMsg, aIter, &aResult->mAllowToOverrideSystemScrollSpeed) &&
208 ReadParam(aMsg, aIter,
209 &aResult->mDeltaValuesHorizontalizedForDefaultHandler);
210 aResult->mScrollType =
211 static_cast<mozilla::WidgetWheelEvent::ScrollType>(scrollType);
212 return rv;
216 template <>
217 struct ParamTraits<mozilla::WidgetPointerHelper> {
218 typedef mozilla::WidgetPointerHelper paramType;
220 static void Write(Message* aMsg, const paramType& aParam) {
221 WriteParam(aMsg, aParam.pointerId);
222 WriteParam(aMsg, aParam.tiltX);
223 WriteParam(aMsg, aParam.tiltY);
224 WriteParam(aMsg, aParam.twist);
225 WriteParam(aMsg, aParam.tangentialPressure);
226 // We don't serialize convertToPointer since it's temporarily variable and
227 // should be reset to default.
230 static bool Read(const Message* aMsg, PickleIterator* aIter,
231 paramType* aResult) {
232 bool rv;
233 rv = ReadParam(aMsg, aIter, &aResult->pointerId) &&
234 ReadParam(aMsg, aIter, &aResult->tiltX) &&
235 ReadParam(aMsg, aIter, &aResult->tiltY) &&
236 ReadParam(aMsg, aIter, &aResult->twist) &&
237 ReadParam(aMsg, aIter, &aResult->tangentialPressure);
238 return rv;
242 template <>
243 struct ParamTraits<mozilla::WidgetMouseEvent> {
244 typedef mozilla::WidgetMouseEvent paramType;
246 static void Write(Message* aMsg, const paramType& aParam) {
247 WriteParam(aMsg, static_cast<const mozilla::WidgetMouseEventBase&>(aParam));
248 WriteParam(aMsg, static_cast<const mozilla::WidgetPointerHelper&>(aParam));
249 WriteParam(aMsg, aParam.mIgnoreRootScrollFrame);
250 WriteParam(aMsg, aParam.mClickEventPrevented);
251 WriteParam(aMsg, static_cast<paramType::ReasonType>(aParam.mReason));
252 WriteParam(aMsg, static_cast<paramType::ContextMenuTriggerType>(
253 aParam.mContextMenuTrigger));
254 WriteParam(aMsg, aParam.mExitFrom.isSome());
255 if (aParam.mExitFrom.isSome()) {
256 WriteParam(
257 aMsg, static_cast<paramType::ExitFromType>(aParam.mExitFrom.value()));
259 WriteParam(aMsg, aParam.mClickCount);
262 static bool Read(const Message* aMsg, PickleIterator* aIter,
263 paramType* aResult) {
264 bool rv;
265 paramType::ReasonType reason = 0;
266 paramType::ContextMenuTriggerType contextMenuTrigger = 0;
267 bool hasExitFrom = false;
268 rv = ReadParam(aMsg, aIter,
269 static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
270 ReadParam(aMsg, aIter,
271 static_cast<mozilla::WidgetPointerHelper*>(aResult)) &&
272 ReadParam(aMsg, aIter, &aResult->mIgnoreRootScrollFrame) &&
273 ReadParam(aMsg, aIter, &aResult->mClickEventPrevented) &&
274 ReadParam(aMsg, aIter, &reason) &&
275 ReadParam(aMsg, aIter, &contextMenuTrigger);
276 aResult->mReason = static_cast<paramType::Reason>(reason);
277 aResult->mContextMenuTrigger =
278 static_cast<paramType::ContextMenuTrigger>(contextMenuTrigger);
279 rv = rv && ReadParam(aMsg, aIter, &hasExitFrom);
280 if (hasExitFrom) {
281 paramType::ExitFromType exitFrom = 0;
282 rv = rv && ReadParam(aMsg, aIter, &exitFrom);
283 aResult->mExitFrom = Some(static_cast<paramType::ExitFrom>(exitFrom));
285 rv = rv && ReadParam(aMsg, aIter, &aResult->mClickCount);
286 return rv;
290 template <>
291 struct ParamTraits<mozilla::WidgetDragEvent> {
292 typedef mozilla::WidgetDragEvent paramType;
294 static void Write(Message* aMsg, const paramType& aParam) {
295 WriteParam(aMsg, static_cast<const mozilla::WidgetMouseEvent&>(aParam));
296 WriteParam(aMsg, aParam.mUserCancelled);
297 WriteParam(aMsg, aParam.mDefaultPreventedOnContent);
300 static bool Read(const Message* aMsg, PickleIterator* aIter,
301 paramType* aResult) {
302 bool rv = ReadParam(aMsg, aIter,
303 static_cast<mozilla::WidgetMouseEvent*>(aResult)) &&
304 ReadParam(aMsg, aIter, &aResult->mUserCancelled) &&
305 ReadParam(aMsg, aIter, &aResult->mDefaultPreventedOnContent);
306 return rv;
310 template <>
311 struct ParamTraits<mozilla::WidgetPointerEvent> {
312 typedef mozilla::WidgetPointerEvent paramType;
314 static void Write(Message* aMsg, const paramType& aParam) {
315 WriteParam(aMsg, static_cast<const mozilla::WidgetMouseEvent&>(aParam));
316 WriteParam(aMsg, aParam.mWidth);
317 WriteParam(aMsg, aParam.mHeight);
318 WriteParam(aMsg, aParam.mIsPrimary);
321 static bool Read(const Message* aMsg, PickleIterator* aIter,
322 paramType* aResult) {
323 bool rv = ReadParam(aMsg, aIter,
324 static_cast<mozilla::WidgetMouseEvent*>(aResult)) &&
325 ReadParam(aMsg, aIter, &aResult->mWidth) &&
326 ReadParam(aMsg, aIter, &aResult->mHeight) &&
327 ReadParam(aMsg, aIter, &aResult->mIsPrimary);
328 return rv;
332 template <>
333 struct ParamTraits<mozilla::WidgetTouchEvent> {
334 using paramType = mozilla::WidgetTouchEvent;
336 static void Write(Message* aMsg, const paramType& aParam) {
337 WriteParam(aMsg, static_cast<const mozilla::WidgetInputEvent&>(aParam));
338 WriteParam(aMsg, aParam.mInputSource);
339 WriteParam(aMsg, aParam.mButton);
340 WriteParam(aMsg, aParam.mButtons);
341 // Sigh, Touch bites us again! We want to be able to do
342 // WriteParam(aMsg, aParam.mTouches);
343 const paramType::TouchArray& touches = aParam.mTouches;
344 WriteParam(aMsg, touches.Length());
345 for (uint32_t i = 0; i < touches.Length(); ++i) {
346 mozilla::dom::Touch* touch = touches[i];
347 WriteParam(aMsg, touch->mIdentifier);
348 WriteParam(aMsg, touch->mRefPoint);
349 WriteParam(aMsg, touch->mRadius);
350 WriteParam(aMsg, touch->mRotationAngle);
351 WriteParam(aMsg, touch->mForce);
352 WriteParam(aMsg, touch->tiltX);
353 WriteParam(aMsg, touch->tiltY);
354 WriteParam(aMsg, touch->twist);
358 static bool Read(const Message* aMsg, PickleIterator* aIter,
359 paramType* aResult) {
360 paramType::TouchArray::size_type numTouches;
361 if (!ReadParam(aMsg, aIter,
362 static_cast<mozilla::WidgetInputEvent*>(aResult)) ||
363 !ReadParam(aMsg, aIter, &aResult->mInputSource) ||
364 !ReadParam(aMsg, aIter, &aResult->mButton) ||
365 !ReadParam(aMsg, aIter, &aResult->mButtons) ||
366 !ReadParam(aMsg, aIter, &numTouches)) {
367 return false;
369 for (uint32_t i = 0; i < numTouches; ++i) {
370 int32_t identifier;
371 mozilla::LayoutDeviceIntPoint refPoint;
372 mozilla::LayoutDeviceIntPoint radius;
373 float rotationAngle;
374 float force;
375 uint32_t tiltX;
376 uint32_t tiltY;
377 uint32_t twist;
378 if (!ReadParam(aMsg, aIter, &identifier) ||
379 !ReadParam(aMsg, aIter, &refPoint) ||
380 !ReadParam(aMsg, aIter, &radius) ||
381 !ReadParam(aMsg, aIter, &rotationAngle) ||
382 !ReadParam(aMsg, aIter, &force) || !ReadParam(aMsg, aIter, &tiltX) ||
383 !ReadParam(aMsg, aIter, &tiltY) || !ReadParam(aMsg, aIter, &twist)) {
384 return false;
386 auto* touch = new mozilla::dom::Touch(identifier, refPoint, radius,
387 rotationAngle, force);
388 touch->tiltX = tiltX;
389 touch->tiltY = tiltY;
390 touch->twist = twist;
391 aResult->mTouches.AppendElement(touch);
393 return true;
397 template <>
398 struct ParamTraits<mozilla::AlternativeCharCode> {
399 typedef mozilla::AlternativeCharCode paramType;
401 static void Write(Message* aMsg, const paramType& aParam) {
402 WriteParam(aMsg, aParam.mUnshiftedCharCode);
403 WriteParam(aMsg, aParam.mShiftedCharCode);
406 static bool Read(const Message* aMsg, PickleIterator* aIter,
407 paramType* aResult) {
408 return ReadParam(aMsg, aIter, &aResult->mUnshiftedCharCode) &&
409 ReadParam(aMsg, aIter, &aResult->mShiftedCharCode);
413 template <>
414 struct ParamTraits<mozilla::ShortcutKeyCandidate> {
415 typedef mozilla::ShortcutKeyCandidate paramType;
417 static void Write(Message* aMsg, const paramType& aParam) {
418 WriteParam(aMsg, aParam.mCharCode);
419 WriteParam(aMsg, aParam.mIgnoreShift);
422 static bool Read(const Message* aMsg, PickleIterator* aIter,
423 paramType* aResult) {
424 return ReadParam(aMsg, aIter, &aResult->mCharCode) &&
425 ReadParam(aMsg, aIter, &aResult->mIgnoreShift);
429 template <>
430 struct ParamTraits<mozilla::WidgetKeyboardEvent> {
431 typedef mozilla::WidgetKeyboardEvent paramType;
433 static void Write(Message* aMsg, const paramType& aParam) {
434 WriteParam(aMsg, static_cast<const mozilla::WidgetInputEvent&>(aParam));
435 WriteParam(aMsg,
436 static_cast<mozilla::KeyNameIndexType>(aParam.mKeyNameIndex));
437 WriteParam(aMsg,
438 static_cast<mozilla::CodeNameIndexType>(aParam.mCodeNameIndex));
439 WriteParam(aMsg, aParam.mKeyValue);
440 WriteParam(aMsg, aParam.mCodeValue);
441 WriteParam(aMsg, aParam.mKeyCode);
442 WriteParam(aMsg, aParam.mCharCode);
443 WriteParam(aMsg, aParam.mPseudoCharCode);
444 WriteParam(aMsg, aParam.mAlternativeCharCodes);
445 WriteParam(aMsg, aParam.mIsRepeat);
446 WriteParam(aMsg, aParam.mLocation);
447 WriteParam(aMsg, aParam.mUniqueId);
448 WriteParam(aMsg, aParam.mIsSynthesizedByTIP);
449 WriteParam(aMsg, aParam.mMaybeSkippableInRemoteProcess);
451 // An OS-specific native event might be attached in |mNativeKeyEvent|, but
452 // that cannot be copied across process boundaries.
454 WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditor);
455 WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditor);
456 WriteParam(aMsg, aParam.mEditCommandsForRichTextEditor);
457 WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditorInitialized);
458 WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditorInitialized);
459 WriteParam(aMsg, aParam.mEditCommandsForRichTextEditorInitialized);
462 static bool Read(const Message* aMsg, PickleIterator* aIter,
463 paramType* aResult) {
464 mozilla::KeyNameIndexType keyNameIndex = 0;
465 mozilla::CodeNameIndexType codeNameIndex = 0;
466 if (ReadParam(aMsg, aIter,
467 static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
468 ReadParam(aMsg, aIter, &keyNameIndex) &&
469 ReadParam(aMsg, aIter, &codeNameIndex) &&
470 ReadParam(aMsg, aIter, &aResult->mKeyValue) &&
471 ReadParam(aMsg, aIter, &aResult->mCodeValue) &&
472 ReadParam(aMsg, aIter, &aResult->mKeyCode) &&
473 ReadParam(aMsg, aIter, &aResult->mCharCode) &&
474 ReadParam(aMsg, aIter, &aResult->mPseudoCharCode) &&
475 ReadParam(aMsg, aIter, &aResult->mAlternativeCharCodes) &&
476 ReadParam(aMsg, aIter, &aResult->mIsRepeat) &&
477 ReadParam(aMsg, aIter, &aResult->mLocation) &&
478 ReadParam(aMsg, aIter, &aResult->mUniqueId) &&
479 ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) &&
480 ReadParam(aMsg, aIter, &aResult->mMaybeSkippableInRemoteProcess) &&
481 ReadParam(aMsg, aIter, &aResult->mEditCommandsForSingleLineEditor) &&
482 ReadParam(aMsg, aIter, &aResult->mEditCommandsForMultiLineEditor) &&
483 ReadParam(aMsg, aIter, &aResult->mEditCommandsForRichTextEditor) &&
484 ReadParam(aMsg, aIter,
485 &aResult->mEditCommandsForSingleLineEditorInitialized) &&
486 ReadParam(aMsg, aIter,
487 &aResult->mEditCommandsForMultiLineEditorInitialized) &&
488 ReadParam(aMsg, aIter,
489 &aResult->mEditCommandsForRichTextEditorInitialized)) {
490 aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
491 aResult->mCodeNameIndex =
492 static_cast<mozilla::CodeNameIndex>(codeNameIndex);
493 aResult->mNativeKeyEvent = nullptr;
494 return true;
496 return false;
500 template <>
501 struct ParamTraits<mozilla::TextRangeStyle> {
502 typedef mozilla::TextRangeStyle paramType;
504 static void Write(Message* aMsg, const paramType& aParam) {
505 WriteParam(aMsg, aParam.mDefinedStyles);
506 WriteParam(aMsg, static_cast<mozilla::TextRangeStyle::LineStyleType>(
507 aParam.mLineStyle));
508 WriteParam(aMsg, aParam.mIsBoldLine);
509 WriteParam(aMsg, aParam.mForegroundColor);
510 WriteParam(aMsg, aParam.mBackgroundColor);
511 WriteParam(aMsg, aParam.mUnderlineColor);
514 static bool Read(const Message* aMsg, PickleIterator* aIter,
515 paramType* aResult) {
516 mozilla::TextRangeStyle::LineStyleType lineStyle;
517 if (!ReadParam(aMsg, aIter, &aResult->mDefinedStyles) ||
518 !ReadParam(aMsg, aIter, &lineStyle) ||
519 !ReadParam(aMsg, aIter, &aResult->mIsBoldLine) ||
520 !ReadParam(aMsg, aIter, &aResult->mForegroundColor) ||
521 !ReadParam(aMsg, aIter, &aResult->mBackgroundColor) ||
522 !ReadParam(aMsg, aIter, &aResult->mUnderlineColor)) {
523 return false;
525 aResult->mLineStyle = mozilla::TextRangeStyle::ToLineStyle(lineStyle);
526 return true;
530 template <>
531 struct ParamTraits<mozilla::TextRange> {
532 typedef mozilla::TextRange paramType;
534 static void Write(Message* aMsg, const paramType& aParam) {
535 WriteParam(aMsg, aParam.mStartOffset);
536 WriteParam(aMsg, aParam.mEndOffset);
537 WriteParam(aMsg, mozilla::ToRawTextRangeType(aParam.mRangeType));
538 WriteParam(aMsg, aParam.mRangeStyle);
541 static bool Read(const Message* aMsg, PickleIterator* aIter,
542 paramType* aResult) {
543 mozilla::RawTextRangeType rawTextRangeType;
544 if (ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
545 ReadParam(aMsg, aIter, &aResult->mEndOffset) &&
546 ReadParam(aMsg, aIter, &rawTextRangeType) &&
547 ReadParam(aMsg, aIter, &aResult->mRangeStyle)) {
548 aResult->mRangeType = mozilla::ToTextRangeType(rawTextRangeType);
549 return true;
551 return false;
555 template <>
556 struct ParamTraits<mozilla::TextRangeArray> {
557 typedef mozilla::TextRangeArray paramType;
559 static void Write(Message* aMsg, const paramType& aParam) {
560 WriteParam(aMsg, aParam.Length());
561 for (uint32_t index = 0; index < aParam.Length(); index++) {
562 WriteParam(aMsg, aParam[index]);
566 static bool Read(const Message* aMsg, PickleIterator* aIter,
567 paramType* aResult) {
568 paramType::size_type length;
569 if (!ReadParam(aMsg, aIter, &length)) {
570 return false;
572 for (uint32_t index = 0; index < length; index++) {
573 mozilla::TextRange textRange;
574 if (!ReadParam(aMsg, aIter, &textRange)) {
575 aResult->Clear();
576 return false;
578 aResult->AppendElement(textRange);
580 return true;
584 template <>
585 struct ParamTraits<mozilla::WidgetCompositionEvent> {
586 typedef mozilla::WidgetCompositionEvent paramType;
588 static void Write(Message* aMsg, const paramType& aParam) {
589 WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
590 WriteParam(aMsg, aParam.mData);
591 WriteParam(aMsg, aParam.mNativeIMEContext);
592 bool hasRanges = !!aParam.mRanges;
593 WriteParam(aMsg, hasRanges);
594 if (hasRanges) {
595 WriteParam(aMsg, *aParam.mRanges.get());
599 static bool Read(const Message* aMsg, PickleIterator* aIter,
600 paramType* aResult) {
601 bool hasRanges;
602 if (!ReadParam(aMsg, aIter,
603 static_cast<mozilla::WidgetGUIEvent*>(aResult)) ||
604 !ReadParam(aMsg, aIter, &aResult->mData) ||
605 !ReadParam(aMsg, aIter, &aResult->mNativeIMEContext) ||
606 !ReadParam(aMsg, aIter, &hasRanges)) {
607 return false;
610 if (!hasRanges) {
611 aResult->mRanges = nullptr;
612 } else {
613 aResult->mRanges = new mozilla::TextRangeArray();
614 if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) {
615 return false;
618 return true;
622 template <>
623 struct ParamTraits<mozilla::FontRange> {
624 typedef mozilla::FontRange paramType;
626 static void Write(Message* aMsg, const paramType& aParam) {
627 WriteParam(aMsg, aParam.mStartOffset);
628 WriteParam(aMsg, aParam.mFontName);
629 WriteParam(aMsg, aParam.mFontSize);
632 static bool Read(const Message* aMsg, PickleIterator* aIter,
633 paramType* aResult) {
634 return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
635 ReadParam(aMsg, aIter, &aResult->mFontName) &&
636 ReadParam(aMsg, aIter, &aResult->mFontSize);
640 template <>
641 struct ParamTraits<mozilla::WidgetSelectionEvent> {
642 typedef mozilla::WidgetSelectionEvent paramType;
644 static void Write(Message* aMsg, const paramType& aParam) {
645 WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
646 WriteParam(aMsg, aParam.mOffset);
647 WriteParam(aMsg, aParam.mLength);
648 WriteParam(aMsg, aParam.mReversed);
649 WriteParam(aMsg, aParam.mExpandToClusterBoundary);
650 WriteParam(aMsg, aParam.mSucceeded);
651 WriteParam(aMsg, aParam.mUseNativeLineBreak);
654 static bool Read(const Message* aMsg, PickleIterator* aIter,
655 paramType* aResult) {
656 return ReadParam(aMsg, aIter,
657 static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
658 ReadParam(aMsg, aIter, &aResult->mOffset) &&
659 ReadParam(aMsg, aIter, &aResult->mLength) &&
660 ReadParam(aMsg, aIter, &aResult->mReversed) &&
661 ReadParam(aMsg, aIter, &aResult->mExpandToClusterBoundary) &&
662 ReadParam(aMsg, aIter, &aResult->mSucceeded) &&
663 ReadParam(aMsg, aIter, &aResult->mUseNativeLineBreak);
667 template <>
668 struct ParamTraits<mozilla::widget::IMENotificationRequests> {
669 typedef mozilla::widget::IMENotificationRequests paramType;
671 static void Write(Message* aMsg, const paramType& aParam) {
672 WriteParam(aMsg, aParam.mWantUpdates);
675 static bool Read(const Message* aMsg, PickleIterator* aIter,
676 paramType* aResult) {
677 return ReadParam(aMsg, aIter, &aResult->mWantUpdates);
681 template <>
682 struct ParamTraits<mozilla::widget::NativeIMEContext> {
683 typedef mozilla::widget::NativeIMEContext paramType;
685 static void Write(Message* aMsg, const paramType& aParam) {
686 WriteParam(aMsg, aParam.mRawNativeIMEContext);
687 WriteParam(aMsg, aParam.mOriginProcessID);
690 static bool Read(const Message* aMsg, PickleIterator* aIter,
691 paramType* aResult) {
692 return ReadParam(aMsg, aIter, &aResult->mRawNativeIMEContext) &&
693 ReadParam(aMsg, aIter, &aResult->mOriginProcessID);
697 template <>
698 struct ParamTraits<mozilla::widget::IMENotification::SelectionChangeDataBase> {
699 typedef mozilla::widget::IMENotification::SelectionChangeDataBase paramType;
701 static void Write(Message* aMsg, const paramType& aParam) {
702 MOZ_RELEASE_ASSERT(aParam.mString);
703 WriteParam(aMsg, aParam.mOffset);
704 WriteParam(aMsg, *aParam.mString);
705 WriteParam(aMsg, aParam.mWritingMode);
706 WriteParam(aMsg, aParam.mReversed);
707 WriteParam(aMsg, aParam.mCausedByComposition);
708 WriteParam(aMsg, aParam.mCausedBySelectionEvent);
709 WriteParam(aMsg, aParam.mOccurredDuringComposition);
712 static bool Read(const Message* aMsg, PickleIterator* aIter,
713 paramType* aResult) {
714 aResult->mString = new nsString();
715 return ReadParam(aMsg, aIter, &aResult->mOffset) &&
716 ReadParam(aMsg, aIter, aResult->mString) &&
717 ReadParam(aMsg, aIter, &aResult->mWritingMode) &&
718 ReadParam(aMsg, aIter, &aResult->mReversed) &&
719 ReadParam(aMsg, aIter, &aResult->mCausedByComposition) &&
720 ReadParam(aMsg, aIter, &aResult->mCausedBySelectionEvent) &&
721 ReadParam(aMsg, aIter, &aResult->mOccurredDuringComposition);
725 template <>
726 struct ParamTraits<mozilla::widget::IMENotification::TextChangeDataBase> {
727 typedef mozilla::widget::IMENotification::TextChangeDataBase paramType;
729 static void Write(Message* aMsg, const paramType& aParam) {
730 WriteParam(aMsg, aParam.mStartOffset);
731 WriteParam(aMsg, aParam.mRemovedEndOffset);
732 WriteParam(aMsg, aParam.mAddedEndOffset);
733 WriteParam(aMsg, aParam.mCausedOnlyByComposition);
734 WriteParam(aMsg, aParam.mIncludingChangesDuringComposition);
735 WriteParam(aMsg, aParam.mIncludingChangesWithoutComposition);
738 static bool Read(const Message* aMsg, PickleIterator* aIter,
739 paramType* aResult) {
740 return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
741 ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) &&
742 ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) &&
743 ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) &&
744 ReadParam(aMsg, aIter,
745 &aResult->mIncludingChangesDuringComposition) &&
746 ReadParam(aMsg, aIter,
747 &aResult->mIncludingChangesWithoutComposition);
751 template <>
752 struct ParamTraits<mozilla::widget::IMENotification::MouseButtonEventData> {
753 typedef mozilla::widget::IMENotification::MouseButtonEventData paramType;
755 static void Write(Message* aMsg, const paramType& aParam) {
756 WriteParam(aMsg, aParam.mEventMessage);
757 WriteParam(aMsg, aParam.mOffset);
758 WriteParam(aMsg, aParam.mCursorPos);
759 WriteParam(aMsg, aParam.mCharRect);
760 WriteParam(aMsg, aParam.mButton);
761 WriteParam(aMsg, aParam.mButtons);
762 WriteParam(aMsg, aParam.mModifiers);
765 static bool Read(const Message* aMsg, PickleIterator* aIter,
766 paramType* aResult) {
767 return ReadParam(aMsg, aIter, &aResult->mEventMessage) &&
768 ReadParam(aMsg, aIter, &aResult->mOffset) &&
769 ReadParam(aMsg, aIter, &aResult->mCursorPos) &&
770 ReadParam(aMsg, aIter, &aResult->mCharRect) &&
771 ReadParam(aMsg, aIter, &aResult->mButton) &&
772 ReadParam(aMsg, aIter, &aResult->mButtons) &&
773 ReadParam(aMsg, aIter, &aResult->mModifiers);
777 template <>
778 struct ParamTraits<mozilla::widget::IMENotification> {
779 typedef mozilla::widget::IMENotification paramType;
781 static void Write(Message* aMsg, const paramType& aParam) {
782 WriteParam(aMsg,
783 static_cast<mozilla::widget::IMEMessageType>(aParam.mMessage));
784 switch (aParam.mMessage) {
785 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
786 WriteParam(aMsg, aParam.mSelectionChangeData);
787 return;
788 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
789 WriteParam(aMsg, aParam.mTextChangeData);
790 return;
791 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
792 WriteParam(aMsg, aParam.mMouseButtonEventData);
793 return;
794 default:
795 return;
799 static bool Read(const Message* aMsg, PickleIterator* aIter,
800 paramType* aResult) {
801 mozilla::widget::IMEMessageType IMEMessage = 0;
802 if (!ReadParam(aMsg, aIter, &IMEMessage)) {
803 return false;
805 aResult->mMessage = static_cast<mozilla::widget::IMEMessage>(IMEMessage);
806 switch (aResult->mMessage) {
807 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
808 return ReadParam(aMsg, aIter, &aResult->mSelectionChangeData);
809 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
810 return ReadParam(aMsg, aIter, &aResult->mTextChangeData);
811 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
812 return ReadParam(aMsg, aIter, &aResult->mMouseButtonEventData);
813 default:
814 return true;
819 template <>
820 struct ParamTraits<mozilla::widget::IMEEnabled>
821 : ContiguousEnumSerializer<mozilla::widget::IMEEnabled,
822 mozilla::widget::IMEEnabled::Disabled,
823 mozilla::widget::IMEEnabled::Unknown> {};
825 template <>
826 struct ParamTraits<mozilla::widget::IMEState::Open>
827 : ContiguousEnumSerializerInclusive<
828 mozilla::widget::IMEState::Open,
829 mozilla::widget::IMEState::Open::OPEN_STATE_NOT_SUPPORTED,
830 mozilla::widget::IMEState::Open::CLOSED> {};
832 template <>
833 struct ParamTraits<mozilla::widget::IMEState> {
834 typedef mozilla::widget::IMEState paramType;
836 static void Write(Message* aMsg, const paramType& aParam) {
837 WriteParam(aMsg, aParam.mEnabled);
838 WriteParam(aMsg, aParam.mOpen);
841 static bool Read(const Message* aMsg, PickleIterator* aIter,
842 paramType* aResult) {
843 return ReadParam(aMsg, aIter, &aResult->mEnabled) &&
844 ReadParam(aMsg, aIter, &aResult->mOpen);
848 template <>
849 struct ParamTraits<mozilla::widget::InputContext::Origin>
850 : ContiguousEnumSerializerInclusive<
851 mozilla::widget::InputContext::Origin,
852 mozilla::widget::InputContext::Origin::ORIGIN_MAIN,
853 mozilla::widget::InputContext::Origin::ORIGIN_CONTENT> {};
855 template <>
856 struct ParamTraits<mozilla::widget::InputContext> {
857 typedef mozilla::widget::InputContext paramType;
859 static void Write(Message* aMsg, const paramType& aParam) {
860 WriteParam(aMsg, aParam.mIMEState);
861 WriteParam(aMsg, aParam.mHTMLInputType);
862 WriteParam(aMsg, aParam.mHTMLInputInputmode);
863 WriteParam(aMsg, aParam.mActionHint);
864 WriteParam(aMsg, aParam.mAutocapitalize);
865 WriteParam(aMsg, aParam.mOrigin);
866 WriteParam(aMsg, aParam.mMayBeIMEUnaware);
867 WriteParam(aMsg, aParam.mHasHandledUserInput);
868 WriteParam(aMsg, aParam.mInPrivateBrowsing);
871 static bool Read(const Message* aMsg, PickleIterator* aIter,
872 paramType* aResult) {
873 return ReadParam(aMsg, aIter, &aResult->mIMEState) &&
874 ReadParam(aMsg, aIter, &aResult->mHTMLInputType) &&
875 ReadParam(aMsg, aIter, &aResult->mHTMLInputInputmode) &&
876 ReadParam(aMsg, aIter, &aResult->mActionHint) &&
877 ReadParam(aMsg, aIter, &aResult->mAutocapitalize) &&
878 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
879 ReadParam(aMsg, aIter, &aResult->mMayBeIMEUnaware) &&
880 ReadParam(aMsg, aIter, &aResult->mHasHandledUserInput) &&
881 ReadParam(aMsg, aIter, &aResult->mInPrivateBrowsing);
885 template <>
886 struct ParamTraits<mozilla::widget::InputContextAction::Cause>
887 : ContiguousEnumSerializerInclusive<
888 mozilla::widget::InputContextAction::Cause,
889 mozilla::widget::InputContextAction::Cause::CAUSE_UNKNOWN,
890 mozilla::widget::InputContextAction::Cause::
891 CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT> {};
893 template <>
894 struct ParamTraits<mozilla::widget::InputContextAction::FocusChange>
895 : ContiguousEnumSerializerInclusive<
896 mozilla::widget::InputContextAction::FocusChange,
897 mozilla::widget::InputContextAction::FocusChange::FOCUS_NOT_CHANGED,
898 mozilla::widget::InputContextAction::FocusChange::WIDGET_CREATED> {};
900 template <>
901 struct ParamTraits<mozilla::widget::InputContextAction> {
902 typedef mozilla::widget::InputContextAction paramType;
904 static void Write(Message* aMsg, const paramType& aParam) {
905 WriteParam(aMsg, aParam.mCause);
906 WriteParam(aMsg, aParam.mFocusChange);
909 static bool Read(const Message* aMsg, PickleIterator* aIter,
910 paramType* aResult) {
911 return ReadParam(aMsg, aIter, &aResult->mCause) &&
912 ReadParam(aMsg, aIter, &aResult->mFocusChange);
916 template <>
917 struct ParamTraits<mozilla::WritingMode> {
918 typedef mozilla::WritingMode paramType;
920 static void Write(Message* aMsg, const paramType& aParam) {
921 WriteParam(aMsg, aParam.mWritingMode.bits);
924 static bool Read(const Message* aMsg, PickleIterator* aIter,
925 paramType* aResult) {
926 return ReadParam(aMsg, aIter, &aResult->mWritingMode.bits);
930 template <>
931 struct ParamTraits<mozilla::ContentCache::Selection> {
932 typedef mozilla::ContentCache::Selection paramType;
934 static void Write(Message* aMsg, const paramType& aParam) {
935 WriteParam(aMsg, aParam.mAnchor);
936 WriteParam(aMsg, aParam.mFocus);
937 WriteParam(aMsg, aParam.mWritingMode);
938 WriteParam(aMsg, aParam.mAnchorCharRects[0]);
939 WriteParam(aMsg, aParam.mAnchorCharRects[1]);
940 WriteParam(aMsg, aParam.mFocusCharRects[0]);
941 WriteParam(aMsg, aParam.mFocusCharRects[1]);
942 WriteParam(aMsg, aParam.mRect);
945 static bool Read(const Message* aMsg, PickleIterator* aIter,
946 paramType* aResult) {
947 return ReadParam(aMsg, aIter, &aResult->mAnchor) &&
948 ReadParam(aMsg, aIter, &aResult->mFocus) &&
949 ReadParam(aMsg, aIter, &aResult->mWritingMode) &&
950 ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[0]) &&
951 ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[1]) &&
952 ReadParam(aMsg, aIter, &aResult->mFocusCharRects[0]) &&
953 ReadParam(aMsg, aIter, &aResult->mFocusCharRects[1]) &&
954 ReadParam(aMsg, aIter, &aResult->mRect);
958 template <>
959 struct ParamTraits<mozilla::ContentCache::Caret> {
960 typedef mozilla::ContentCache::Caret paramType;
962 static void Write(Message* aMsg, const paramType& aParam) {
963 WriteParam(aMsg, aParam.mOffset);
964 WriteParam(aMsg, aParam.mRect);
967 static bool Read(const Message* aMsg, PickleIterator* aIter,
968 paramType* aResult) {
969 return ReadParam(aMsg, aIter, &aResult->mOffset) &&
970 ReadParam(aMsg, aIter, &aResult->mRect);
974 template <>
975 struct ParamTraits<mozilla::ContentCache::TextRectArray> {
976 typedef mozilla::ContentCache::TextRectArray paramType;
978 static void Write(Message* aMsg, const paramType& aParam) {
979 WriteParam(aMsg, aParam.mStart);
980 WriteParam(aMsg, aParam.mRects);
983 static bool Read(const Message* aMsg, PickleIterator* aIter,
984 paramType* aResult) {
985 return ReadParam(aMsg, aIter, &aResult->mStart) &&
986 ReadParam(aMsg, aIter, &aResult->mRects);
990 template <>
991 struct ParamTraits<mozilla::ContentCache> {
992 typedef mozilla::ContentCache paramType;
994 static void Write(Message* aMsg, const paramType& aParam) {
995 WriteParam(aMsg, aParam.mCompositionStart);
996 WriteParam(aMsg, aParam.mText);
997 WriteParam(aMsg, aParam.mSelection);
998 WriteParam(aMsg, aParam.mFirstCharRect);
999 WriteParam(aMsg, aParam.mCaret);
1000 WriteParam(aMsg, aParam.mTextRectArray);
1001 WriteParam(aMsg, aParam.mLastCommitStringTextRectArray);
1002 WriteParam(aMsg, aParam.mEditorRect);
1005 static bool Read(const Message* aMsg, PickleIterator* aIter,
1006 paramType* aResult) {
1007 return ReadParam(aMsg, aIter, &aResult->mCompositionStart) &&
1008 ReadParam(aMsg, aIter, &aResult->mText) &&
1009 ReadParam(aMsg, aIter, &aResult->mSelection) &&
1010 ReadParam(aMsg, aIter, &aResult->mFirstCharRect) &&
1011 ReadParam(aMsg, aIter, &aResult->mCaret) &&
1012 ReadParam(aMsg, aIter, &aResult->mTextRectArray) &&
1013 ReadParam(aMsg, aIter, &aResult->mLastCommitStringTextRectArray) &&
1014 ReadParam(aMsg, aIter, &aResult->mEditorRect);
1018 template <>
1019 struct ParamTraits<mozilla::widget::CandidateWindowPosition> {
1020 typedef mozilla::widget::CandidateWindowPosition paramType;
1022 static void Write(Message* aMsg, const paramType& aParam) {
1023 WriteParam(aMsg, aParam.mPoint);
1024 WriteParam(aMsg, aParam.mRect);
1025 WriteParam(aMsg, aParam.mExcludeRect);
1028 static bool Read(const Message* aMsg, PickleIterator* aIter,
1029 paramType* aResult) {
1030 return ReadParam(aMsg, aIter, &aResult->mPoint) &&
1031 ReadParam(aMsg, aIter, &aResult->mRect) &&
1032 ReadParam(aMsg, aIter, &aResult->mExcludeRect);
1036 // InputData.h
1038 template <>
1039 struct ParamTraits<mozilla::InputType>
1040 : public ContiguousEnumSerializerInclusive<
1041 mozilla::InputType, mozilla::InputType::MULTITOUCH_INPUT,
1042 mozilla::kHighestInputType> {};
1044 template <>
1045 struct ParamTraits<mozilla::InputData> {
1046 typedef mozilla::InputData paramType;
1048 static void Write(Message* aMsg, const paramType& aParam) {
1049 WriteParam(aMsg, aParam.mInputType);
1050 WriteParam(aMsg, aParam.mTime);
1051 WriteParam(aMsg, aParam.mTimeStamp);
1052 WriteParam(aMsg, aParam.modifiers);
1053 WriteParam(aMsg, aParam.mFocusSequenceNumber);
1054 WriteParam(aMsg, aParam.mLayersId);
1057 static bool Read(const Message* aMsg, PickleIterator* aIter,
1058 paramType* aResult) {
1059 return ReadParam(aMsg, aIter, &aResult->mInputType) &&
1060 ReadParam(aMsg, aIter, &aResult->mTime) &&
1061 ReadParam(aMsg, aIter, &aResult->mTimeStamp) &&
1062 ReadParam(aMsg, aIter, &aResult->modifiers) &&
1063 ReadParam(aMsg, aIter, &aResult->mFocusSequenceNumber) &&
1064 ReadParam(aMsg, aIter, &aResult->mLayersId);
1068 template <>
1069 struct ParamTraits<mozilla::SingleTouchData::HistoricalTouchData> {
1070 typedef mozilla::SingleTouchData::HistoricalTouchData paramType;
1072 static void Write(Message* aMsg, const paramType& aParam) {
1073 WriteParam(aMsg, aParam.mTimeStamp);
1074 WriteParam(aMsg, aParam.mScreenPoint);
1075 WriteParam(aMsg, aParam.mLocalScreenPoint);
1076 WriteParam(aMsg, aParam.mRadius);
1077 WriteParam(aMsg, aParam.mRotationAngle);
1078 WriteParam(aMsg, aParam.mForce);
1081 static bool Read(const Message* aMsg, PickleIterator* aIter,
1082 paramType* aResult) {
1083 return (ReadParam(aMsg, aIter, &aResult->mTimeStamp) &&
1084 ReadParam(aMsg, aIter, &aResult->mScreenPoint) &&
1085 ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) &&
1086 ReadParam(aMsg, aIter, &aResult->mRadius) &&
1087 ReadParam(aMsg, aIter, &aResult->mRotationAngle) &&
1088 ReadParam(aMsg, aIter, &aResult->mForce));
1092 template <>
1093 struct ParamTraits<mozilla::SingleTouchData> {
1094 using paramType = mozilla::SingleTouchData;
1096 static void Write(Message* aMsg, const paramType& aParam) {
1097 WriteParam(aMsg, aParam.mHistoricalData);
1098 WriteParam(aMsg, aParam.mIdentifier);
1099 WriteParam(aMsg, aParam.mScreenPoint);
1100 WriteParam(aMsg, aParam.mLocalScreenPoint);
1101 WriteParam(aMsg, aParam.mRadius);
1102 WriteParam(aMsg, aParam.mRotationAngle);
1103 WriteParam(aMsg, aParam.mForce);
1104 WriteParam(aMsg, aParam.mTiltX);
1105 WriteParam(aMsg, aParam.mTiltY);
1106 WriteParam(aMsg, aParam.mTwist);
1109 static bool Read(const Message* aMsg, PickleIterator* aIter,
1110 paramType* aResult) {
1111 return (ReadParam(aMsg, aIter, &aResult->mHistoricalData) &&
1112 ReadParam(aMsg, aIter, &aResult->mIdentifier) &&
1113 ReadParam(aMsg, aIter, &aResult->mScreenPoint) &&
1114 ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) &&
1115 ReadParam(aMsg, aIter, &aResult->mRadius) &&
1116 ReadParam(aMsg, aIter, &aResult->mRotationAngle) &&
1117 ReadParam(aMsg, aIter, &aResult->mForce) &&
1118 ReadParam(aMsg, aIter, &aResult->mTiltX) &&
1119 ReadParam(aMsg, aIter, &aResult->mTiltY) &&
1120 ReadParam(aMsg, aIter, &aResult->mTwist));
1124 template <>
1125 struct ParamTraits<mozilla::MultiTouchInput::MultiTouchType>
1126 : public ContiguousEnumSerializerInclusive<
1127 mozilla::MultiTouchInput::MultiTouchType,
1128 mozilla::MultiTouchInput::MultiTouchType::MULTITOUCH_START,
1129 mozilla::MultiTouchInput::sHighestMultiTouchType> {};
1131 template <>
1132 struct ParamTraits<mozilla::MultiTouchInput> {
1133 using paramType = mozilla::MultiTouchInput;
1135 static void Write(Message* aMsg, const paramType& aParam) {
1136 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1137 WriteParam(aMsg, aParam.mType);
1138 WriteParam(aMsg, aParam.mTouches);
1139 WriteParam(aMsg, aParam.mHandledByAPZ);
1140 WriteParam(aMsg, aParam.mScreenOffset);
1141 WriteParam(aMsg, aParam.mButton);
1142 WriteParam(aMsg, aParam.mButtons);
1145 static bool Read(const Message* aMsg, PickleIterator* aIter,
1146 paramType* aResult) {
1147 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1148 ReadParam(aMsg, aIter, &aResult->mType) &&
1149 ReadParam(aMsg, aIter, &aResult->mTouches) &&
1150 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1151 ReadParam(aMsg, aIter, &aResult->mScreenOffset) &&
1152 ReadParam(aMsg, aIter, &aResult->mButton) &&
1153 ReadParam(aMsg, aIter, &aResult->mButtons);
1157 template <>
1158 struct ParamTraits<mozilla::MouseInput::MouseType>
1159 : public ContiguousEnumSerializerInclusive<
1160 mozilla::MouseInput::MouseType,
1161 mozilla::MouseInput::MouseType::MOUSE_NONE,
1162 mozilla::MouseInput::sHighestMouseType> {};
1164 template <>
1165 struct ParamTraits<mozilla::MouseInput::ButtonType>
1166 : public ContiguousEnumSerializerInclusive<
1167 mozilla::MouseInput::ButtonType,
1168 mozilla::MouseInput::ButtonType::PRIMARY_BUTTON,
1169 mozilla::MouseInput::sHighestButtonType> {};
1171 template <>
1172 struct ParamTraits<mozilla::MouseInput> {
1173 typedef mozilla::MouseInput paramType;
1175 static void Write(Message* aMsg, const paramType& aParam) {
1176 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1177 WriteParam(aMsg, aParam.mButtonType);
1178 WriteParam(aMsg, aParam.mType);
1179 WriteParam(aMsg, aParam.mInputSource);
1180 WriteParam(aMsg, aParam.mButtons);
1181 WriteParam(aMsg, aParam.mOrigin);
1182 WriteParam(aMsg, aParam.mLocalOrigin);
1183 WriteParam(aMsg, aParam.mHandledByAPZ);
1184 WriteParam(aMsg, aParam.mPreventClickEvent);
1187 static bool Read(const Message* aMsg, PickleIterator* aIter,
1188 paramType* aResult) {
1189 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1190 ReadParam(aMsg, aIter, &aResult->mButtonType) &&
1191 ReadParam(aMsg, aIter, &aResult->mType) &&
1192 ReadParam(aMsg, aIter, &aResult->mInputSource) &&
1193 ReadParam(aMsg, aIter, &aResult->mButtons) &&
1194 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
1195 ReadParam(aMsg, aIter, &aResult->mLocalOrigin) &&
1196 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1197 ReadParam(aMsg, aIter, &aResult->mPreventClickEvent);
1201 template <>
1202 struct ParamTraits<mozilla::PanGestureInput::PanGestureType>
1203 : public ContiguousEnumSerializerInclusive<
1204 mozilla::PanGestureInput::PanGestureType,
1205 mozilla::PanGestureInput::PanGestureType::PANGESTURE_MAYSTART,
1206 mozilla::PanGestureInput::sHighestPanGestureType> {};
1208 template <>
1209 struct ParamTraits<mozilla::PanGestureInput::PanDeltaType>
1210 : public ContiguousEnumSerializerInclusive<
1211 mozilla::PanGestureInput::PanDeltaType,
1212 mozilla::PanGestureInput::PanDeltaType::PANDELTA_PAGE,
1213 mozilla::PanGestureInput::sHighestPanDeltaType> {};
1215 template <>
1216 struct ParamTraits<mozilla::PanGestureInput>
1217 : BitfieldHelper<mozilla::PanGestureInput> {
1218 typedef mozilla::PanGestureInput paramType;
1220 static void Write(Message* aMsg, const paramType& aParam) {
1221 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1222 WriteParam(aMsg, aParam.mType);
1223 WriteParam(aMsg, aParam.mPanStartPoint);
1224 WriteParam(aMsg, aParam.mPanDisplacement);
1225 WriteParam(aMsg, aParam.mLocalPanStartPoint);
1226 WriteParam(aMsg, aParam.mLocalPanDisplacement);
1227 WriteParam(aMsg, aParam.mLineOrPageDeltaX);
1228 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1229 WriteParam(aMsg, aParam.mUserDeltaMultiplierX);
1230 WriteParam(aMsg, aParam.mUserDeltaMultiplierY);
1231 WriteParam(aMsg, aParam.mDeltaType);
1232 WriteParam(aMsg, aParam.mHandledByAPZ);
1233 WriteParam(aMsg, aParam.mFollowedByMomentum);
1234 WriteParam(
1235 aMsg,
1236 aParam
1237 .mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection);
1238 WriteParam(aMsg, aParam.mOverscrollBehaviorAllowsSwipe);
1239 WriteParam(aMsg, aParam.mSimulateMomentum);
1242 static bool Read(const Message* aMsg, PickleIterator* aIter,
1243 paramType* aResult) {
1244 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1245 ReadParam(aMsg, aIter, &aResult->mType) &&
1246 ReadParam(aMsg, aIter, &aResult->mPanStartPoint) &&
1247 ReadParam(aMsg, aIter, &aResult->mPanDisplacement) &&
1248 ReadParam(aMsg, aIter, &aResult->mLocalPanStartPoint) &&
1249 ReadParam(aMsg, aIter, &aResult->mLocalPanDisplacement) &&
1250 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) &&
1251 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1252 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) &&
1253 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
1254 ReadParam(aMsg, aIter, &aResult->mDeltaType) &&
1255 ReadBoolForBitfield(aMsg, aIter, aResult,
1256 &paramType::SetHandledByAPZ) &&
1257 ReadBoolForBitfield(aMsg, aIter, aResult,
1258 &paramType::SetFollowedByMomentum) &&
1259 ReadBoolForBitfield(
1260 aMsg, aIter, aResult,
1261 &paramType::
1262 SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
1263 ReadBoolForBitfield(aMsg, aIter, aResult,
1264 &paramType::SetOverscrollBehaviorAllowsSwipe) &&
1265 ReadBoolForBitfield(aMsg, aIter, aResult,
1266 &paramType::SetSimulateMomentum);
1270 template <>
1271 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureType>
1272 : public ContiguousEnumSerializerInclusive<
1273 mozilla::PinchGestureInput::PinchGestureType,
1274 mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START,
1275 mozilla::PinchGestureInput::sHighestPinchGestureType> {};
1277 template <>
1278 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureSource>
1279 : public ContiguousEnumSerializerInclusive<
1280 mozilla::PinchGestureInput::PinchGestureSource,
1281 // Set the min to TOUCH, to ensure UNKNOWN is never sent over IPC
1282 mozilla::PinchGestureInput::PinchGestureSource::TOUCH,
1283 mozilla::PinchGestureInput::sHighestPinchGestureSource> {};
1285 template <>
1286 struct ParamTraits<mozilla::PinchGestureInput> {
1287 typedef mozilla::PinchGestureInput paramType;
1289 static void Write(Message* aMsg, const paramType& aParam) {
1290 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1291 WriteParam(aMsg, aParam.mType);
1292 WriteParam(aMsg, aParam.mSource);
1293 WriteParam(aMsg, aParam.mScreenOffset);
1294 WriteParam(aMsg, aParam.mFocusPoint);
1295 WriteParam(aMsg, aParam.mLocalFocusPoint);
1296 WriteParam(aMsg, aParam.mCurrentSpan);
1297 WriteParam(aMsg, aParam.mPreviousSpan);
1298 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1299 WriteParam(aMsg, aParam.mHandledByAPZ);
1302 static bool Read(const Message* aMsg, PickleIterator* aIter,
1303 paramType* aResult) {
1304 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1305 ReadParam(aMsg, aIter, &aResult->mType) &&
1306 ReadParam(aMsg, aIter, &aResult->mSource) &&
1307 ReadParam(aMsg, aIter, &aResult->mScreenOffset) &&
1308 ReadParam(aMsg, aIter, &aResult->mFocusPoint) &&
1309 ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) &&
1310 ReadParam(aMsg, aIter, &aResult->mCurrentSpan) &&
1311 ReadParam(aMsg, aIter, &aResult->mPreviousSpan) &&
1312 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1313 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ);
1317 template <>
1318 struct ParamTraits<mozilla::TapGestureInput::TapGestureType>
1319 : public ContiguousEnumSerializerInclusive<
1320 mozilla::TapGestureInput::TapGestureType,
1321 mozilla::TapGestureInput::TapGestureType::TAPGESTURE_LONG,
1322 mozilla::TapGestureInput::sHighestTapGestureType> {};
1324 template <>
1325 struct ParamTraits<mozilla::TapGestureInput> {
1326 typedef mozilla::TapGestureInput paramType;
1328 static void Write(Message* aMsg, const paramType& aParam) {
1329 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1330 WriteParam(aMsg, aParam.mType);
1331 WriteParam(aMsg, aParam.mPoint);
1332 WriteParam(aMsg, aParam.mLocalPoint);
1335 static bool Read(const Message* aMsg, PickleIterator* aIter,
1336 paramType* aResult) {
1337 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1338 ReadParam(aMsg, aIter, &aResult->mType) &&
1339 ReadParam(aMsg, aIter, &aResult->mPoint) &&
1340 ReadParam(aMsg, aIter, &aResult->mLocalPoint);
1344 template <>
1345 struct ParamTraits<mozilla::ScrollWheelInput::ScrollDeltaType>
1346 : public ContiguousEnumSerializerInclusive<
1347 mozilla::ScrollWheelInput::ScrollDeltaType,
1348 mozilla::ScrollWheelInput::ScrollDeltaType::SCROLLDELTA_LINE,
1349 mozilla::ScrollWheelInput::sHighestScrollDeltaType> {};
1351 template <>
1352 struct ParamTraits<mozilla::ScrollWheelInput::ScrollMode>
1353 : public ContiguousEnumSerializerInclusive<
1354 mozilla::ScrollWheelInput::ScrollMode,
1355 mozilla::ScrollWheelInput::ScrollMode::SCROLLMODE_INSTANT,
1356 mozilla::ScrollWheelInput::sHighestScrollMode> {};
1358 template <>
1359 struct ParamTraits<mozilla::WheelDeltaAdjustmentStrategy>
1360 : public ContiguousEnumSerializer<
1361 mozilla::WheelDeltaAdjustmentStrategy,
1362 mozilla::WheelDeltaAdjustmentStrategy(0),
1363 mozilla::WheelDeltaAdjustmentStrategy::eSentinel> {};
1365 template <>
1366 struct ParamTraits<mozilla::layers::APZWheelAction>
1367 : public ContiguousEnumSerializerInclusive<
1368 mozilla::layers::APZWheelAction,
1369 mozilla::layers::APZWheelAction::Scroll,
1370 mozilla::layers::kHighestAPZWheelAction> {};
1372 template <>
1373 struct ParamTraits<mozilla::ScrollWheelInput> {
1374 typedef mozilla::ScrollWheelInput paramType;
1376 static void Write(Message* aMsg, const paramType& aParam) {
1377 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1378 WriteParam(aMsg, aParam.mDeltaType);
1379 WriteParam(aMsg, aParam.mScrollMode);
1380 WriteParam(aMsg, aParam.mOrigin);
1381 WriteParam(aMsg, aParam.mHandledByAPZ);
1382 WriteParam(aMsg, aParam.mDeltaX);
1383 WriteParam(aMsg, aParam.mDeltaY);
1384 WriteParam(aMsg, aParam.mWheelTicksX);
1385 WriteParam(aMsg, aParam.mWheelTicksY);
1386 WriteParam(aMsg, aParam.mLocalOrigin);
1387 WriteParam(aMsg, aParam.mLineOrPageDeltaX);
1388 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1389 WriteParam(aMsg, aParam.mScrollSeriesNumber);
1390 WriteParam(aMsg, aParam.mUserDeltaMultiplierX);
1391 WriteParam(aMsg, aParam.mUserDeltaMultiplierY);
1392 WriteParam(aMsg, aParam.mMayHaveMomentum);
1393 WriteParam(aMsg, aParam.mIsMomentum);
1394 WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed);
1395 WriteParam(aMsg, aParam.mWheelDeltaAdjustmentStrategy);
1396 WriteParam(aMsg, aParam.mAPZAction);
1399 static bool Read(const Message* aMsg, PickleIterator* aIter,
1400 paramType* aResult) {
1401 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1402 ReadParam(aMsg, aIter, &aResult->mDeltaType) &&
1403 ReadParam(aMsg, aIter, &aResult->mScrollMode) &&
1404 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
1405 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1406 ReadParam(aMsg, aIter, &aResult->mDeltaX) &&
1407 ReadParam(aMsg, aIter, &aResult->mDeltaY) &&
1408 ReadParam(aMsg, aIter, &aResult->mWheelTicksX) &&
1409 ReadParam(aMsg, aIter, &aResult->mWheelTicksY) &&
1410 ReadParam(aMsg, aIter, &aResult->mLocalOrigin) &&
1411 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) &&
1412 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1413 ReadParam(aMsg, aIter, &aResult->mScrollSeriesNumber) &&
1414 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) &&
1415 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
1416 ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) &&
1417 ReadParam(aMsg, aIter, &aResult->mIsMomentum) &&
1418 ReadParam(aMsg, aIter,
1419 &aResult->mAllowToOverrideSystemScrollSpeed) &&
1420 ReadParam(aMsg, aIter, &aResult->mWheelDeltaAdjustmentStrategy) &&
1421 ReadParam(aMsg, aIter, &aResult->mAPZAction);
1425 template <>
1426 struct ParamTraits<mozilla::KeyboardInput::KeyboardEventType>
1427 : public ContiguousEnumSerializer<
1428 mozilla::KeyboardInput::KeyboardEventType,
1429 mozilla::KeyboardInput::KeyboardEventType::KEY_DOWN,
1430 mozilla::KeyboardInput::KeyboardEventType::KEY_SENTINEL> {};
1432 template <>
1433 struct ParamTraits<mozilla::KeyboardInput> {
1434 typedef mozilla::KeyboardInput paramType;
1436 static void Write(Message* aMsg, const paramType& aParam) {
1437 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1438 WriteParam(aMsg, aParam.mType);
1439 WriteParam(aMsg, aParam.mKeyCode);
1440 WriteParam(aMsg, aParam.mCharCode);
1441 WriteParam(aMsg, aParam.mShortcutCandidates);
1442 WriteParam(aMsg, aParam.mHandledByAPZ);
1445 static bool Read(const Message* aMsg, PickleIterator* aIter,
1446 paramType* aResult) {
1447 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1448 ReadParam(aMsg, aIter, &aResult->mType) &&
1449 ReadParam(aMsg, aIter, &aResult->mKeyCode) &&
1450 ReadParam(aMsg, aIter, &aResult->mCharCode) &&
1451 ReadParam(aMsg, aIter, &aResult->mShortcutCandidates) &&
1452 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ);
1456 } // namespace IPC
1458 #endif // nsGUIEventIPC_h__