Bug 1700051: part 45) Remove outdated part of comment in <mozInlineSpellChecker.cpp...
[gecko.git] / widget / nsGUIEventIPC.h
blobf402b3cec1eb9cdcc59f15c612ba6337af53698d
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 // Sigh, Touch bites us again! We want to be able to do
340 // WriteParam(aMsg, aParam.mTouches);
341 const paramType::TouchArray& touches = aParam.mTouches;
342 WriteParam(aMsg, touches.Length());
343 for (uint32_t i = 0; i < touches.Length(); ++i) {
344 mozilla::dom::Touch* touch = touches[i];
345 WriteParam(aMsg, touch->mIdentifier);
346 WriteParam(aMsg, touch->mRefPoint);
347 WriteParam(aMsg, touch->mRadius);
348 WriteParam(aMsg, touch->mRotationAngle);
349 WriteParam(aMsg, touch->mForce);
350 WriteParam(aMsg, touch->tiltX);
351 WriteParam(aMsg, touch->tiltY);
352 WriteParam(aMsg, touch->twist);
356 static bool Read(const Message* aMsg, PickleIterator* aIter,
357 paramType* aResult) {
358 paramType::TouchArray::size_type numTouches;
359 if (!ReadParam(aMsg, aIter,
360 static_cast<mozilla::WidgetInputEvent*>(aResult)) ||
361 !ReadParam(aMsg, aIter, &aResult->mInputSource) ||
362 !ReadParam(aMsg, aIter, &numTouches)) {
363 return false;
365 for (uint32_t i = 0; i < numTouches; ++i) {
366 int32_t identifier;
367 mozilla::LayoutDeviceIntPoint refPoint;
368 mozilla::LayoutDeviceIntPoint radius;
369 float rotationAngle;
370 float force;
371 uint32_t tiltX;
372 uint32_t tiltY;
373 uint32_t twist;
374 if (!ReadParam(aMsg, aIter, &identifier) ||
375 !ReadParam(aMsg, aIter, &refPoint) ||
376 !ReadParam(aMsg, aIter, &radius) ||
377 !ReadParam(aMsg, aIter, &rotationAngle) ||
378 !ReadParam(aMsg, aIter, &force) || !ReadParam(aMsg, aIter, &tiltX) ||
379 !ReadParam(aMsg, aIter, &tiltY) || !ReadParam(aMsg, aIter, &twist)) {
380 return false;
382 auto* touch = new mozilla::dom::Touch(identifier, refPoint, radius,
383 rotationAngle, force);
384 touch->tiltX = tiltX;
385 touch->tiltY = tiltY;
386 touch->twist = twist;
387 aResult->mTouches.AppendElement(touch);
389 return true;
393 template <>
394 struct ParamTraits<mozilla::AlternativeCharCode> {
395 typedef mozilla::AlternativeCharCode paramType;
397 static void Write(Message* aMsg, const paramType& aParam) {
398 WriteParam(aMsg, aParam.mUnshiftedCharCode);
399 WriteParam(aMsg, aParam.mShiftedCharCode);
402 static bool Read(const Message* aMsg, PickleIterator* aIter,
403 paramType* aResult) {
404 return ReadParam(aMsg, aIter, &aResult->mUnshiftedCharCode) &&
405 ReadParam(aMsg, aIter, &aResult->mShiftedCharCode);
409 template <>
410 struct ParamTraits<mozilla::ShortcutKeyCandidate> {
411 typedef mozilla::ShortcutKeyCandidate paramType;
413 static void Write(Message* aMsg, const paramType& aParam) {
414 WriteParam(aMsg, aParam.mCharCode);
415 WriteParam(aMsg, aParam.mIgnoreShift);
418 static bool Read(const Message* aMsg, PickleIterator* aIter,
419 paramType* aResult) {
420 return ReadParam(aMsg, aIter, &aResult->mCharCode) &&
421 ReadParam(aMsg, aIter, &aResult->mIgnoreShift);
425 template <>
426 struct ParamTraits<mozilla::WidgetKeyboardEvent> {
427 typedef mozilla::WidgetKeyboardEvent paramType;
429 static void Write(Message* aMsg, const paramType& aParam) {
430 WriteParam(aMsg, static_cast<const mozilla::WidgetInputEvent&>(aParam));
431 WriteParam(aMsg,
432 static_cast<mozilla::KeyNameIndexType>(aParam.mKeyNameIndex));
433 WriteParam(aMsg,
434 static_cast<mozilla::CodeNameIndexType>(aParam.mCodeNameIndex));
435 WriteParam(aMsg, aParam.mKeyValue);
436 WriteParam(aMsg, aParam.mCodeValue);
437 WriteParam(aMsg, aParam.mKeyCode);
438 WriteParam(aMsg, aParam.mCharCode);
439 WriteParam(aMsg, aParam.mPseudoCharCode);
440 WriteParam(aMsg, aParam.mAlternativeCharCodes);
441 WriteParam(aMsg, aParam.mIsRepeat);
442 WriteParam(aMsg, aParam.mLocation);
443 WriteParam(aMsg, aParam.mUniqueId);
444 WriteParam(aMsg, aParam.mIsSynthesizedByTIP);
445 WriteParam(aMsg, aParam.mMaybeSkippableInRemoteProcess);
447 // An OS-specific native event might be attached in |mNativeKeyEvent|, but
448 // that cannot be copied across process boundaries.
450 WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditor);
451 WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditor);
452 WriteParam(aMsg, aParam.mEditCommandsForRichTextEditor);
453 WriteParam(aMsg, aParam.mEditCommandsForSingleLineEditorInitialized);
454 WriteParam(aMsg, aParam.mEditCommandsForMultiLineEditorInitialized);
455 WriteParam(aMsg, aParam.mEditCommandsForRichTextEditorInitialized);
458 static bool Read(const Message* aMsg, PickleIterator* aIter,
459 paramType* aResult) {
460 mozilla::KeyNameIndexType keyNameIndex = 0;
461 mozilla::CodeNameIndexType codeNameIndex = 0;
462 if (ReadParam(aMsg, aIter,
463 static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
464 ReadParam(aMsg, aIter, &keyNameIndex) &&
465 ReadParam(aMsg, aIter, &codeNameIndex) &&
466 ReadParam(aMsg, aIter, &aResult->mKeyValue) &&
467 ReadParam(aMsg, aIter, &aResult->mCodeValue) &&
468 ReadParam(aMsg, aIter, &aResult->mKeyCode) &&
469 ReadParam(aMsg, aIter, &aResult->mCharCode) &&
470 ReadParam(aMsg, aIter, &aResult->mPseudoCharCode) &&
471 ReadParam(aMsg, aIter, &aResult->mAlternativeCharCodes) &&
472 ReadParam(aMsg, aIter, &aResult->mIsRepeat) &&
473 ReadParam(aMsg, aIter, &aResult->mLocation) &&
474 ReadParam(aMsg, aIter, &aResult->mUniqueId) &&
475 ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) &&
476 ReadParam(aMsg, aIter, &aResult->mMaybeSkippableInRemoteProcess) &&
477 ReadParam(aMsg, aIter, &aResult->mEditCommandsForSingleLineEditor) &&
478 ReadParam(aMsg, aIter, &aResult->mEditCommandsForMultiLineEditor) &&
479 ReadParam(aMsg, aIter, &aResult->mEditCommandsForRichTextEditor) &&
480 ReadParam(aMsg, aIter,
481 &aResult->mEditCommandsForSingleLineEditorInitialized) &&
482 ReadParam(aMsg, aIter,
483 &aResult->mEditCommandsForMultiLineEditorInitialized) &&
484 ReadParam(aMsg, aIter,
485 &aResult->mEditCommandsForRichTextEditorInitialized)) {
486 aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
487 aResult->mCodeNameIndex =
488 static_cast<mozilla::CodeNameIndex>(codeNameIndex);
489 aResult->mNativeKeyEvent = nullptr;
490 return true;
492 return false;
496 template <>
497 struct ParamTraits<mozilla::TextRangeStyle> {
498 typedef mozilla::TextRangeStyle paramType;
500 static void Write(Message* aMsg, const paramType& aParam) {
501 WriteParam(aMsg, aParam.mDefinedStyles);
502 WriteParam(aMsg, static_cast<mozilla::TextRangeStyle::LineStyleType>(
503 aParam.mLineStyle));
504 WriteParam(aMsg, aParam.mIsBoldLine);
505 WriteParam(aMsg, aParam.mForegroundColor);
506 WriteParam(aMsg, aParam.mBackgroundColor);
507 WriteParam(aMsg, aParam.mUnderlineColor);
510 static bool Read(const Message* aMsg, PickleIterator* aIter,
511 paramType* aResult) {
512 mozilla::TextRangeStyle::LineStyleType lineStyle;
513 if (!ReadParam(aMsg, aIter, &aResult->mDefinedStyles) ||
514 !ReadParam(aMsg, aIter, &lineStyle) ||
515 !ReadParam(aMsg, aIter, &aResult->mIsBoldLine) ||
516 !ReadParam(aMsg, aIter, &aResult->mForegroundColor) ||
517 !ReadParam(aMsg, aIter, &aResult->mBackgroundColor) ||
518 !ReadParam(aMsg, aIter, &aResult->mUnderlineColor)) {
519 return false;
521 aResult->mLineStyle = mozilla::TextRangeStyle::ToLineStyle(lineStyle);
522 return true;
526 template <>
527 struct ParamTraits<mozilla::TextRange> {
528 typedef mozilla::TextRange paramType;
530 static void Write(Message* aMsg, const paramType& aParam) {
531 WriteParam(aMsg, aParam.mStartOffset);
532 WriteParam(aMsg, aParam.mEndOffset);
533 WriteParam(aMsg, mozilla::ToRawTextRangeType(aParam.mRangeType));
534 WriteParam(aMsg, aParam.mRangeStyle);
537 static bool Read(const Message* aMsg, PickleIterator* aIter,
538 paramType* aResult) {
539 mozilla::RawTextRangeType rawTextRangeType;
540 if (ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
541 ReadParam(aMsg, aIter, &aResult->mEndOffset) &&
542 ReadParam(aMsg, aIter, &rawTextRangeType) &&
543 ReadParam(aMsg, aIter, &aResult->mRangeStyle)) {
544 aResult->mRangeType = mozilla::ToTextRangeType(rawTextRangeType);
545 return true;
547 return false;
551 template <>
552 struct ParamTraits<mozilla::TextRangeArray> {
553 typedef mozilla::TextRangeArray paramType;
555 static void Write(Message* aMsg, const paramType& aParam) {
556 WriteParam(aMsg, aParam.Length());
557 for (uint32_t index = 0; index < aParam.Length(); index++) {
558 WriteParam(aMsg, aParam[index]);
562 static bool Read(const Message* aMsg, PickleIterator* aIter,
563 paramType* aResult) {
564 paramType::size_type length;
565 if (!ReadParam(aMsg, aIter, &length)) {
566 return false;
568 for (uint32_t index = 0; index < length; index++) {
569 mozilla::TextRange textRange;
570 if (!ReadParam(aMsg, aIter, &textRange)) {
571 aResult->Clear();
572 return false;
574 aResult->AppendElement(textRange);
576 return true;
580 template <>
581 struct ParamTraits<mozilla::WidgetCompositionEvent> {
582 typedef mozilla::WidgetCompositionEvent paramType;
584 static void Write(Message* aMsg, const paramType& aParam) {
585 WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
586 WriteParam(aMsg, aParam.mData);
587 WriteParam(aMsg, aParam.mNativeIMEContext);
588 bool hasRanges = !!aParam.mRanges;
589 WriteParam(aMsg, hasRanges);
590 if (hasRanges) {
591 WriteParam(aMsg, *aParam.mRanges.get());
595 static bool Read(const Message* aMsg, PickleIterator* aIter,
596 paramType* aResult) {
597 bool hasRanges;
598 if (!ReadParam(aMsg, aIter,
599 static_cast<mozilla::WidgetGUIEvent*>(aResult)) ||
600 !ReadParam(aMsg, aIter, &aResult->mData) ||
601 !ReadParam(aMsg, aIter, &aResult->mNativeIMEContext) ||
602 !ReadParam(aMsg, aIter, &hasRanges)) {
603 return false;
606 if (!hasRanges) {
607 aResult->mRanges = nullptr;
608 } else {
609 aResult->mRanges = new mozilla::TextRangeArray();
610 if (!ReadParam(aMsg, aIter, aResult->mRanges.get())) {
611 return false;
614 return true;
618 template <>
619 struct ParamTraits<mozilla::FontRange> {
620 typedef mozilla::FontRange paramType;
622 static void Write(Message* aMsg, const paramType& aParam) {
623 WriteParam(aMsg, aParam.mStartOffset);
624 WriteParam(aMsg, aParam.mFontName);
625 WriteParam(aMsg, aParam.mFontSize);
628 static bool Read(const Message* aMsg, PickleIterator* aIter,
629 paramType* aResult) {
630 return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
631 ReadParam(aMsg, aIter, &aResult->mFontName) &&
632 ReadParam(aMsg, aIter, &aResult->mFontSize);
636 template <>
637 struct ParamTraits<mozilla::WidgetSelectionEvent> {
638 typedef mozilla::WidgetSelectionEvent paramType;
640 static void Write(Message* aMsg, const paramType& aParam) {
641 WriteParam(aMsg, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
642 WriteParam(aMsg, aParam.mOffset);
643 WriteParam(aMsg, aParam.mLength);
644 WriteParam(aMsg, aParam.mReversed);
645 WriteParam(aMsg, aParam.mExpandToClusterBoundary);
646 WriteParam(aMsg, aParam.mSucceeded);
647 WriteParam(aMsg, aParam.mUseNativeLineBreak);
650 static bool Read(const Message* aMsg, PickleIterator* aIter,
651 paramType* aResult) {
652 return ReadParam(aMsg, aIter,
653 static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
654 ReadParam(aMsg, aIter, &aResult->mOffset) &&
655 ReadParam(aMsg, aIter, &aResult->mLength) &&
656 ReadParam(aMsg, aIter, &aResult->mReversed) &&
657 ReadParam(aMsg, aIter, &aResult->mExpandToClusterBoundary) &&
658 ReadParam(aMsg, aIter, &aResult->mSucceeded) &&
659 ReadParam(aMsg, aIter, &aResult->mUseNativeLineBreak);
663 template <>
664 struct ParamTraits<mozilla::widget::IMENotificationRequests> {
665 typedef mozilla::widget::IMENotificationRequests paramType;
667 static void Write(Message* aMsg, const paramType& aParam) {
668 WriteParam(aMsg, aParam.mWantUpdates);
671 static bool Read(const Message* aMsg, PickleIterator* aIter,
672 paramType* aResult) {
673 return ReadParam(aMsg, aIter, &aResult->mWantUpdates);
677 template <>
678 struct ParamTraits<mozilla::widget::NativeIMEContext> {
679 typedef mozilla::widget::NativeIMEContext paramType;
681 static void Write(Message* aMsg, const paramType& aParam) {
682 WriteParam(aMsg, aParam.mRawNativeIMEContext);
683 WriteParam(aMsg, aParam.mOriginProcessID);
686 static bool Read(const Message* aMsg, PickleIterator* aIter,
687 paramType* aResult) {
688 return ReadParam(aMsg, aIter, &aResult->mRawNativeIMEContext) &&
689 ReadParam(aMsg, aIter, &aResult->mOriginProcessID);
693 template <>
694 struct ParamTraits<mozilla::widget::IMENotification::Point> {
695 typedef mozilla::widget::IMENotification::Point paramType;
697 static void Write(Message* aMsg, const paramType& aParam) {
698 WriteParam(aMsg, aParam.mX);
699 WriteParam(aMsg, aParam.mY);
702 static bool Read(const Message* aMsg, PickleIterator* aIter,
703 paramType* aResult) {
704 return ReadParam(aMsg, aIter, &aResult->mX) &&
705 ReadParam(aMsg, aIter, &aResult->mY);
709 template <>
710 struct ParamTraits<mozilla::widget::IMENotification::Rect> {
711 typedef mozilla::widget::IMENotification::Rect paramType;
713 static void Write(Message* aMsg, const paramType& aParam) {
714 WriteParam(aMsg, aParam.mX);
715 WriteParam(aMsg, aParam.mY);
716 WriteParam(aMsg, aParam.mWidth);
717 WriteParam(aMsg, aParam.mHeight);
720 static bool Read(const Message* aMsg, PickleIterator* aIter,
721 paramType* aResult) {
722 return ReadParam(aMsg, aIter, &aResult->mX) &&
723 ReadParam(aMsg, aIter, &aResult->mY) &&
724 ReadParam(aMsg, aIter, &aResult->mWidth) &&
725 ReadParam(aMsg, aIter, &aResult->mHeight);
729 template <>
730 struct ParamTraits<mozilla::widget::IMENotification::SelectionChangeDataBase> {
731 typedef mozilla::widget::IMENotification::SelectionChangeDataBase paramType;
733 static void Write(Message* aMsg, const paramType& aParam) {
734 MOZ_RELEASE_ASSERT(aParam.mString);
735 WriteParam(aMsg, aParam.mOffset);
736 WriteParam(aMsg, *aParam.mString);
737 WriteParam(aMsg, aParam.mWritingMode);
738 WriteParam(aMsg, aParam.mReversed);
739 WriteParam(aMsg, aParam.mCausedByComposition);
740 WriteParam(aMsg, aParam.mCausedBySelectionEvent);
741 WriteParam(aMsg, aParam.mOccurredDuringComposition);
744 static bool Read(const Message* aMsg, PickleIterator* aIter,
745 paramType* aResult) {
746 aResult->mString = new nsString();
747 return ReadParam(aMsg, aIter, &aResult->mOffset) &&
748 ReadParam(aMsg, aIter, aResult->mString) &&
749 ReadParam(aMsg, aIter, &aResult->mWritingMode) &&
750 ReadParam(aMsg, aIter, &aResult->mReversed) &&
751 ReadParam(aMsg, aIter, &aResult->mCausedByComposition) &&
752 ReadParam(aMsg, aIter, &aResult->mCausedBySelectionEvent) &&
753 ReadParam(aMsg, aIter, &aResult->mOccurredDuringComposition);
757 template <>
758 struct ParamTraits<mozilla::widget::IMENotification::TextChangeDataBase> {
759 typedef mozilla::widget::IMENotification::TextChangeDataBase paramType;
761 static void Write(Message* aMsg, const paramType& aParam) {
762 WriteParam(aMsg, aParam.mStartOffset);
763 WriteParam(aMsg, aParam.mRemovedEndOffset);
764 WriteParam(aMsg, aParam.mAddedEndOffset);
765 WriteParam(aMsg, aParam.mCausedOnlyByComposition);
766 WriteParam(aMsg, aParam.mIncludingChangesDuringComposition);
767 WriteParam(aMsg, aParam.mIncludingChangesWithoutComposition);
770 static bool Read(const Message* aMsg, PickleIterator* aIter,
771 paramType* aResult) {
772 return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
773 ReadParam(aMsg, aIter, &aResult->mRemovedEndOffset) &&
774 ReadParam(aMsg, aIter, &aResult->mAddedEndOffset) &&
775 ReadParam(aMsg, aIter, &aResult->mCausedOnlyByComposition) &&
776 ReadParam(aMsg, aIter,
777 &aResult->mIncludingChangesDuringComposition) &&
778 ReadParam(aMsg, aIter,
779 &aResult->mIncludingChangesWithoutComposition);
783 template <>
784 struct ParamTraits<mozilla::widget::IMENotification::MouseButtonEventData> {
785 typedef mozilla::widget::IMENotification::MouseButtonEventData paramType;
787 static void Write(Message* aMsg, const paramType& aParam) {
788 WriteParam(aMsg, aParam.mEventMessage);
789 WriteParam(aMsg, aParam.mOffset);
790 WriteParam(aMsg, aParam.mCursorPos);
791 WriteParam(aMsg, aParam.mCharRect);
792 WriteParam(aMsg, aParam.mButton);
793 WriteParam(aMsg, aParam.mButtons);
794 WriteParam(aMsg, aParam.mModifiers);
797 static bool Read(const Message* aMsg, PickleIterator* aIter,
798 paramType* aResult) {
799 return ReadParam(aMsg, aIter, &aResult->mEventMessage) &&
800 ReadParam(aMsg, aIter, &aResult->mOffset) &&
801 ReadParam(aMsg, aIter, &aResult->mCursorPos) &&
802 ReadParam(aMsg, aIter, &aResult->mCharRect) &&
803 ReadParam(aMsg, aIter, &aResult->mButton) &&
804 ReadParam(aMsg, aIter, &aResult->mButtons) &&
805 ReadParam(aMsg, aIter, &aResult->mModifiers);
809 template <>
810 struct ParamTraits<mozilla::widget::IMENotification> {
811 typedef mozilla::widget::IMENotification paramType;
813 static void Write(Message* aMsg, const paramType& aParam) {
814 WriteParam(aMsg,
815 static_cast<mozilla::widget::IMEMessageType>(aParam.mMessage));
816 switch (aParam.mMessage) {
817 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
818 WriteParam(aMsg, aParam.mSelectionChangeData);
819 return;
820 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
821 WriteParam(aMsg, aParam.mTextChangeData);
822 return;
823 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
824 WriteParam(aMsg, aParam.mMouseButtonEventData);
825 return;
826 default:
827 return;
831 static bool Read(const Message* aMsg, PickleIterator* aIter,
832 paramType* aResult) {
833 mozilla::widget::IMEMessageType IMEMessage = 0;
834 if (!ReadParam(aMsg, aIter, &IMEMessage)) {
835 return false;
837 aResult->mMessage = static_cast<mozilla::widget::IMEMessage>(IMEMessage);
838 switch (aResult->mMessage) {
839 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
840 return ReadParam(aMsg, aIter, &aResult->mSelectionChangeData);
841 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
842 return ReadParam(aMsg, aIter, &aResult->mTextChangeData);
843 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
844 return ReadParam(aMsg, aIter, &aResult->mMouseButtonEventData);
845 default:
846 return true;
851 template <>
852 struct ParamTraits<mozilla::widget::IMEEnabled>
853 : ContiguousEnumSerializer<mozilla::widget::IMEEnabled,
854 mozilla::widget::IMEEnabled::Disabled,
855 mozilla::widget::IMEEnabled::Unknown> {};
857 template <>
858 struct ParamTraits<mozilla::widget::IMEState::Open>
859 : ContiguousEnumSerializerInclusive<
860 mozilla::widget::IMEState::Open,
861 mozilla::widget::IMEState::Open::OPEN_STATE_NOT_SUPPORTED,
862 mozilla::widget::IMEState::Open::CLOSED> {};
864 template <>
865 struct ParamTraits<mozilla::widget::IMEState> {
866 typedef mozilla::widget::IMEState paramType;
868 static void Write(Message* aMsg, const paramType& aParam) {
869 WriteParam(aMsg, aParam.mEnabled);
870 WriteParam(aMsg, aParam.mOpen);
873 static bool Read(const Message* aMsg, PickleIterator* aIter,
874 paramType* aResult) {
875 return ReadParam(aMsg, aIter, &aResult->mEnabled) &&
876 ReadParam(aMsg, aIter, &aResult->mOpen);
880 template <>
881 struct ParamTraits<mozilla::widget::InputContext::Origin>
882 : ContiguousEnumSerializerInclusive<
883 mozilla::widget::InputContext::Origin,
884 mozilla::widget::InputContext::Origin::ORIGIN_MAIN,
885 mozilla::widget::InputContext::Origin::ORIGIN_CONTENT> {};
887 template <>
888 struct ParamTraits<mozilla::widget::InputContext> {
889 typedef mozilla::widget::InputContext paramType;
891 static void Write(Message* aMsg, const paramType& aParam) {
892 WriteParam(aMsg, aParam.mIMEState);
893 WriteParam(aMsg, aParam.mHTMLInputType);
894 WriteParam(aMsg, aParam.mHTMLInputInputmode);
895 WriteParam(aMsg, aParam.mActionHint);
896 WriteParam(aMsg, aParam.mAutocapitalize);
897 WriteParam(aMsg, aParam.mOrigin);
898 WriteParam(aMsg, aParam.mMayBeIMEUnaware);
899 WriteParam(aMsg, aParam.mHasHandledUserInput);
900 WriteParam(aMsg, aParam.mInPrivateBrowsing);
903 static bool Read(const Message* aMsg, PickleIterator* aIter,
904 paramType* aResult) {
905 return ReadParam(aMsg, aIter, &aResult->mIMEState) &&
906 ReadParam(aMsg, aIter, &aResult->mHTMLInputType) &&
907 ReadParam(aMsg, aIter, &aResult->mHTMLInputInputmode) &&
908 ReadParam(aMsg, aIter, &aResult->mActionHint) &&
909 ReadParam(aMsg, aIter, &aResult->mAutocapitalize) &&
910 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
911 ReadParam(aMsg, aIter, &aResult->mMayBeIMEUnaware) &&
912 ReadParam(aMsg, aIter, &aResult->mHasHandledUserInput) &&
913 ReadParam(aMsg, aIter, &aResult->mInPrivateBrowsing);
917 template <>
918 struct ParamTraits<mozilla::widget::InputContextAction::Cause>
919 : ContiguousEnumSerializerInclusive<
920 mozilla::widget::InputContextAction::Cause,
921 mozilla::widget::InputContextAction::Cause::CAUSE_UNKNOWN,
922 mozilla::widget::InputContextAction::Cause::
923 CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT> {};
925 template <>
926 struct ParamTraits<mozilla::widget::InputContextAction::FocusChange>
927 : ContiguousEnumSerializerInclusive<
928 mozilla::widget::InputContextAction::FocusChange,
929 mozilla::widget::InputContextAction::FocusChange::FOCUS_NOT_CHANGED,
930 mozilla::widget::InputContextAction::FocusChange::WIDGET_CREATED> {};
932 template <>
933 struct ParamTraits<mozilla::widget::InputContextAction> {
934 typedef mozilla::widget::InputContextAction paramType;
936 static void Write(Message* aMsg, const paramType& aParam) {
937 WriteParam(aMsg, aParam.mCause);
938 WriteParam(aMsg, aParam.mFocusChange);
941 static bool Read(const Message* aMsg, PickleIterator* aIter,
942 paramType* aResult) {
943 return ReadParam(aMsg, aIter, &aResult->mCause) &&
944 ReadParam(aMsg, aIter, &aResult->mFocusChange);
948 template <>
949 struct ParamTraits<mozilla::WritingMode> {
950 typedef mozilla::WritingMode paramType;
952 static void Write(Message* aMsg, const paramType& aParam) {
953 WriteParam(aMsg, aParam.mWritingMode.bits);
956 static bool Read(const Message* aMsg, PickleIterator* aIter,
957 paramType* aResult) {
958 return ReadParam(aMsg, aIter, &aResult->mWritingMode.bits);
962 template <>
963 struct ParamTraits<mozilla::ContentCache::Selection> {
964 typedef mozilla::ContentCache::Selection paramType;
966 static void Write(Message* aMsg, const paramType& aParam) {
967 WriteParam(aMsg, aParam.mAnchor);
968 WriteParam(aMsg, aParam.mFocus);
969 WriteParam(aMsg, aParam.mWritingMode);
970 WriteParam(aMsg, aParam.mAnchorCharRects[0]);
971 WriteParam(aMsg, aParam.mAnchorCharRects[1]);
972 WriteParam(aMsg, aParam.mFocusCharRects[0]);
973 WriteParam(aMsg, aParam.mFocusCharRects[1]);
974 WriteParam(aMsg, aParam.mRect);
977 static bool Read(const Message* aMsg, PickleIterator* aIter,
978 paramType* aResult) {
979 return ReadParam(aMsg, aIter, &aResult->mAnchor) &&
980 ReadParam(aMsg, aIter, &aResult->mFocus) &&
981 ReadParam(aMsg, aIter, &aResult->mWritingMode) &&
982 ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[0]) &&
983 ReadParam(aMsg, aIter, &aResult->mAnchorCharRects[1]) &&
984 ReadParam(aMsg, aIter, &aResult->mFocusCharRects[0]) &&
985 ReadParam(aMsg, aIter, &aResult->mFocusCharRects[1]) &&
986 ReadParam(aMsg, aIter, &aResult->mRect);
990 template <>
991 struct ParamTraits<mozilla::ContentCache::Caret> {
992 typedef mozilla::ContentCache::Caret paramType;
994 static void Write(Message* aMsg, const paramType& aParam) {
995 WriteParam(aMsg, aParam.mOffset);
996 WriteParam(aMsg, aParam.mRect);
999 static bool Read(const Message* aMsg, PickleIterator* aIter,
1000 paramType* aResult) {
1001 return ReadParam(aMsg, aIter, &aResult->mOffset) &&
1002 ReadParam(aMsg, aIter, &aResult->mRect);
1006 template <>
1007 struct ParamTraits<mozilla::ContentCache::TextRectArray> {
1008 typedef mozilla::ContentCache::TextRectArray paramType;
1010 static void Write(Message* aMsg, const paramType& aParam) {
1011 WriteParam(aMsg, aParam.mStart);
1012 WriteParam(aMsg, aParam.mRects);
1015 static bool Read(const Message* aMsg, PickleIterator* aIter,
1016 paramType* aResult) {
1017 return ReadParam(aMsg, aIter, &aResult->mStart) &&
1018 ReadParam(aMsg, aIter, &aResult->mRects);
1022 template <>
1023 struct ParamTraits<mozilla::ContentCache> {
1024 typedef mozilla::ContentCache paramType;
1026 static void Write(Message* aMsg, const paramType& aParam) {
1027 WriteParam(aMsg, aParam.mCompositionStart);
1028 WriteParam(aMsg, aParam.mText);
1029 WriteParam(aMsg, aParam.mSelection);
1030 WriteParam(aMsg, aParam.mFirstCharRect);
1031 WriteParam(aMsg, aParam.mCaret);
1032 WriteParam(aMsg, aParam.mTextRectArray);
1033 WriteParam(aMsg, aParam.mLastCommitStringTextRectArray);
1034 WriteParam(aMsg, aParam.mEditorRect);
1037 static bool Read(const Message* aMsg, PickleIterator* aIter,
1038 paramType* aResult) {
1039 return ReadParam(aMsg, aIter, &aResult->mCompositionStart) &&
1040 ReadParam(aMsg, aIter, &aResult->mText) &&
1041 ReadParam(aMsg, aIter, &aResult->mSelection) &&
1042 ReadParam(aMsg, aIter, &aResult->mFirstCharRect) &&
1043 ReadParam(aMsg, aIter, &aResult->mCaret) &&
1044 ReadParam(aMsg, aIter, &aResult->mTextRectArray) &&
1045 ReadParam(aMsg, aIter, &aResult->mLastCommitStringTextRectArray) &&
1046 ReadParam(aMsg, aIter, &aResult->mEditorRect);
1050 template <>
1051 struct ParamTraits<mozilla::widget::CandidateWindowPosition> {
1052 typedef mozilla::widget::CandidateWindowPosition paramType;
1054 static void Write(Message* aMsg, const paramType& aParam) {
1055 WriteParam(aMsg, aParam.mPoint);
1056 WriteParam(aMsg, aParam.mRect);
1057 WriteParam(aMsg, aParam.mExcludeRect);
1060 static bool Read(const Message* aMsg, PickleIterator* aIter,
1061 paramType* aResult) {
1062 return ReadParam(aMsg, aIter, &aResult->mPoint) &&
1063 ReadParam(aMsg, aIter, &aResult->mRect) &&
1064 ReadParam(aMsg, aIter, &aResult->mExcludeRect);
1068 // InputData.h
1070 template <>
1071 struct ParamTraits<mozilla::InputType>
1072 : public ContiguousEnumSerializerInclusive<
1073 mozilla::InputType, mozilla::InputType::MULTITOUCH_INPUT,
1074 mozilla::kHighestInputType> {};
1076 template <>
1077 struct ParamTraits<mozilla::InputData> {
1078 typedef mozilla::InputData paramType;
1080 static void Write(Message* aMsg, const paramType& aParam) {
1081 WriteParam(aMsg, aParam.mInputType);
1082 WriteParam(aMsg, aParam.mTime);
1083 WriteParam(aMsg, aParam.mTimeStamp);
1084 WriteParam(aMsg, aParam.modifiers);
1085 WriteParam(aMsg, aParam.mFocusSequenceNumber);
1086 WriteParam(aMsg, aParam.mLayersId);
1089 static bool Read(const Message* aMsg, PickleIterator* aIter,
1090 paramType* aResult) {
1091 return ReadParam(aMsg, aIter, &aResult->mInputType) &&
1092 ReadParam(aMsg, aIter, &aResult->mTime) &&
1093 ReadParam(aMsg, aIter, &aResult->mTimeStamp) &&
1094 ReadParam(aMsg, aIter, &aResult->modifiers) &&
1095 ReadParam(aMsg, aIter, &aResult->mFocusSequenceNumber) &&
1096 ReadParam(aMsg, aIter, &aResult->mLayersId);
1100 template <>
1101 struct ParamTraits<mozilla::SingleTouchData::HistoricalTouchData> {
1102 typedef mozilla::SingleTouchData::HistoricalTouchData paramType;
1104 static void Write(Message* aMsg, const paramType& aParam) {
1105 WriteParam(aMsg, aParam.mTimeStamp);
1106 WriteParam(aMsg, aParam.mScreenPoint);
1107 WriteParam(aMsg, aParam.mLocalScreenPoint);
1108 WriteParam(aMsg, aParam.mRadius);
1109 WriteParam(aMsg, aParam.mRotationAngle);
1110 WriteParam(aMsg, aParam.mForce);
1113 static bool Read(const Message* aMsg, PickleIterator* aIter,
1114 paramType* aResult) {
1115 return (ReadParam(aMsg, aIter, &aResult->mTimeStamp) &&
1116 ReadParam(aMsg, aIter, &aResult->mScreenPoint) &&
1117 ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) &&
1118 ReadParam(aMsg, aIter, &aResult->mRadius) &&
1119 ReadParam(aMsg, aIter, &aResult->mRotationAngle) &&
1120 ReadParam(aMsg, aIter, &aResult->mForce));
1124 template <>
1125 struct ParamTraits<mozilla::SingleTouchData> {
1126 using paramType = mozilla::SingleTouchData;
1128 static void Write(Message* aMsg, const paramType& aParam) {
1129 WriteParam(aMsg, aParam.mHistoricalData);
1130 WriteParam(aMsg, aParam.mIdentifier);
1131 WriteParam(aMsg, aParam.mScreenPoint);
1132 WriteParam(aMsg, aParam.mLocalScreenPoint);
1133 WriteParam(aMsg, aParam.mRadius);
1134 WriteParam(aMsg, aParam.mRotationAngle);
1135 WriteParam(aMsg, aParam.mForce);
1136 WriteParam(aMsg, aParam.mTiltX);
1137 WriteParam(aMsg, aParam.mTiltY);
1138 WriteParam(aMsg, aParam.mTwist);
1141 static bool Read(const Message* aMsg, PickleIterator* aIter,
1142 paramType* aResult) {
1143 return (ReadParam(aMsg, aIter, &aResult->mHistoricalData) &&
1144 ReadParam(aMsg, aIter, &aResult->mIdentifier) &&
1145 ReadParam(aMsg, aIter, &aResult->mScreenPoint) &&
1146 ReadParam(aMsg, aIter, &aResult->mLocalScreenPoint) &&
1147 ReadParam(aMsg, aIter, &aResult->mRadius) &&
1148 ReadParam(aMsg, aIter, &aResult->mRotationAngle) &&
1149 ReadParam(aMsg, aIter, &aResult->mForce) &&
1150 ReadParam(aMsg, aIter, &aResult->mTiltX) &&
1151 ReadParam(aMsg, aIter, &aResult->mTiltY) &&
1152 ReadParam(aMsg, aIter, &aResult->mTwist));
1156 template <>
1157 struct ParamTraits<mozilla::MultiTouchInput::MultiTouchType>
1158 : public ContiguousEnumSerializerInclusive<
1159 mozilla::MultiTouchInput::MultiTouchType,
1160 mozilla::MultiTouchInput::MultiTouchType::MULTITOUCH_START,
1161 mozilla::MultiTouchInput::sHighestMultiTouchType> {};
1163 template <>
1164 struct ParamTraits<mozilla::MultiTouchInput> {
1165 typedef mozilla::MultiTouchInput paramType;
1167 static void Write(Message* aMsg, const paramType& aParam) {
1168 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1169 WriteParam(aMsg, aParam.mType);
1170 WriteParam(aMsg, aParam.mTouches);
1171 WriteParam(aMsg, aParam.mHandledByAPZ);
1172 WriteParam(aMsg, aParam.mScreenOffset);
1175 static bool Read(const Message* aMsg, PickleIterator* aIter,
1176 paramType* aResult) {
1177 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1178 ReadParam(aMsg, aIter, &aResult->mType) &&
1179 ReadParam(aMsg, aIter, &aResult->mTouches) &&
1180 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1181 ReadParam(aMsg, aIter, &aResult->mScreenOffset);
1185 template <>
1186 struct ParamTraits<mozilla::MouseInput::MouseType>
1187 : public ContiguousEnumSerializerInclusive<
1188 mozilla::MouseInput::MouseType,
1189 mozilla::MouseInput::MouseType::MOUSE_NONE,
1190 mozilla::MouseInput::sHighestMouseType> {};
1192 template <>
1193 struct ParamTraits<mozilla::MouseInput::ButtonType>
1194 : public ContiguousEnumSerializerInclusive<
1195 mozilla::MouseInput::ButtonType,
1196 mozilla::MouseInput::ButtonType::PRIMARY_BUTTON,
1197 mozilla::MouseInput::sHighestButtonType> {};
1199 template <>
1200 struct ParamTraits<mozilla::MouseInput> {
1201 typedef mozilla::MouseInput paramType;
1203 static void Write(Message* aMsg, const paramType& aParam) {
1204 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1205 WriteParam(aMsg, aParam.mButtonType);
1206 WriteParam(aMsg, aParam.mType);
1207 WriteParam(aMsg, aParam.mInputSource);
1208 WriteParam(aMsg, aParam.mButtons);
1209 WriteParam(aMsg, aParam.mOrigin);
1210 WriteParam(aMsg, aParam.mLocalOrigin);
1211 WriteParam(aMsg, aParam.mHandledByAPZ);
1212 WriteParam(aMsg, aParam.mPreventClickEvent);
1215 static bool Read(const Message* aMsg, PickleIterator* aIter,
1216 paramType* aResult) {
1217 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1218 ReadParam(aMsg, aIter, &aResult->mButtonType) &&
1219 ReadParam(aMsg, aIter, &aResult->mType) &&
1220 ReadParam(aMsg, aIter, &aResult->mInputSource) &&
1221 ReadParam(aMsg, aIter, &aResult->mButtons) &&
1222 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
1223 ReadParam(aMsg, aIter, &aResult->mLocalOrigin) &&
1224 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1225 ReadParam(aMsg, aIter, &aResult->mPreventClickEvent);
1229 template <>
1230 struct ParamTraits<mozilla::PanGestureInput::PanGestureType>
1231 : public ContiguousEnumSerializerInclusive<
1232 mozilla::PanGestureInput::PanGestureType,
1233 mozilla::PanGestureInput::PanGestureType::PANGESTURE_MAYSTART,
1234 mozilla::PanGestureInput::sHighestPanGestureType> {};
1236 template <>
1237 struct ParamTraits<mozilla::PanGestureInput::PanDeltaType>
1238 : public ContiguousEnumSerializerInclusive<
1239 mozilla::PanGestureInput::PanDeltaType,
1240 mozilla::PanGestureInput::PanDeltaType::PANDELTA_PAGE,
1241 mozilla::PanGestureInput::sHighestPanDeltaType> {};
1243 template <>
1244 struct ParamTraits<mozilla::PanGestureInput>
1245 : BitfieldHelper<mozilla::PanGestureInput> {
1246 typedef mozilla::PanGestureInput paramType;
1248 static void Write(Message* aMsg, const paramType& aParam) {
1249 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1250 WriteParam(aMsg, aParam.mType);
1251 WriteParam(aMsg, aParam.mPanStartPoint);
1252 WriteParam(aMsg, aParam.mPanDisplacement);
1253 WriteParam(aMsg, aParam.mLocalPanStartPoint);
1254 WriteParam(aMsg, aParam.mLocalPanDisplacement);
1255 WriteParam(aMsg, aParam.mLineOrPageDeltaX);
1256 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1257 WriteParam(aMsg, aParam.mUserDeltaMultiplierX);
1258 WriteParam(aMsg, aParam.mUserDeltaMultiplierY);
1259 WriteParam(aMsg, aParam.mDeltaType);
1260 WriteParam(aMsg, aParam.mHandledByAPZ);
1261 WriteParam(aMsg, aParam.mFollowedByMomentum);
1262 WriteParam(
1263 aMsg,
1264 aParam
1265 .mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection);
1266 WriteParam(aMsg, aParam.mOverscrollBehaviorAllowsSwipe);
1267 WriteParam(aMsg, aParam.mSimulateMomentum);
1270 static bool Read(const Message* aMsg, PickleIterator* aIter,
1271 paramType* aResult) {
1272 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1273 ReadParam(aMsg, aIter, &aResult->mType) &&
1274 ReadParam(aMsg, aIter, &aResult->mPanStartPoint) &&
1275 ReadParam(aMsg, aIter, &aResult->mPanDisplacement) &&
1276 ReadParam(aMsg, aIter, &aResult->mLocalPanStartPoint) &&
1277 ReadParam(aMsg, aIter, &aResult->mLocalPanDisplacement) &&
1278 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) &&
1279 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1280 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) &&
1281 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
1282 ReadParam(aMsg, aIter, &aResult->mDeltaType) &&
1283 ReadBoolForBitfield(aMsg, aIter, aResult,
1284 &paramType::SetHandledByAPZ) &&
1285 ReadBoolForBitfield(aMsg, aIter, aResult,
1286 &paramType::SetFollowedByMomentum) &&
1287 ReadBoolForBitfield(
1288 aMsg, aIter, aResult,
1289 &paramType::
1290 SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
1291 ReadBoolForBitfield(aMsg, aIter, aResult,
1292 &paramType::SetOverscrollBehaviorAllowsSwipe) &&
1293 ReadBoolForBitfield(aMsg, aIter, aResult,
1294 &paramType::SetSimulateMomentum);
1298 template <>
1299 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureType>
1300 : public ContiguousEnumSerializerInclusive<
1301 mozilla::PinchGestureInput::PinchGestureType,
1302 mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START,
1303 mozilla::PinchGestureInput::sHighestPinchGestureType> {};
1305 template <>
1306 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureSource>
1307 : public ContiguousEnumSerializerInclusive<
1308 mozilla::PinchGestureInput::PinchGestureSource,
1309 // Set the min to TOUCH, to ensure UNKNOWN is never sent over IPC
1310 mozilla::PinchGestureInput::PinchGestureSource::TOUCH,
1311 mozilla::PinchGestureInput::sHighestPinchGestureSource> {};
1313 template <>
1314 struct ParamTraits<mozilla::PinchGestureInput> {
1315 typedef mozilla::PinchGestureInput paramType;
1317 static void Write(Message* aMsg, const paramType& aParam) {
1318 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1319 WriteParam(aMsg, aParam.mType);
1320 WriteParam(aMsg, aParam.mSource);
1321 WriteParam(aMsg, aParam.mScreenOffset);
1322 WriteParam(aMsg, aParam.mFocusPoint);
1323 WriteParam(aMsg, aParam.mLocalFocusPoint);
1324 WriteParam(aMsg, aParam.mCurrentSpan);
1325 WriteParam(aMsg, aParam.mPreviousSpan);
1326 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1327 WriteParam(aMsg, aParam.mHandledByAPZ);
1330 static bool Read(const Message* aMsg, PickleIterator* aIter,
1331 paramType* aResult) {
1332 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1333 ReadParam(aMsg, aIter, &aResult->mType) &&
1334 ReadParam(aMsg, aIter, &aResult->mSource) &&
1335 ReadParam(aMsg, aIter, &aResult->mScreenOffset) &&
1336 ReadParam(aMsg, aIter, &aResult->mFocusPoint) &&
1337 ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) &&
1338 ReadParam(aMsg, aIter, &aResult->mCurrentSpan) &&
1339 ReadParam(aMsg, aIter, &aResult->mPreviousSpan) &&
1340 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1341 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ);
1345 template <>
1346 struct ParamTraits<mozilla::TapGestureInput::TapGestureType>
1347 : public ContiguousEnumSerializerInclusive<
1348 mozilla::TapGestureInput::TapGestureType,
1349 mozilla::TapGestureInput::TapGestureType::TAPGESTURE_LONG,
1350 mozilla::TapGestureInput::sHighestTapGestureType> {};
1352 template <>
1353 struct ParamTraits<mozilla::TapGestureInput> {
1354 typedef mozilla::TapGestureInput paramType;
1356 static void Write(Message* aMsg, const paramType& aParam) {
1357 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1358 WriteParam(aMsg, aParam.mType);
1359 WriteParam(aMsg, aParam.mPoint);
1360 WriteParam(aMsg, aParam.mLocalPoint);
1363 static bool Read(const Message* aMsg, PickleIterator* aIter,
1364 paramType* aResult) {
1365 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1366 ReadParam(aMsg, aIter, &aResult->mType) &&
1367 ReadParam(aMsg, aIter, &aResult->mPoint) &&
1368 ReadParam(aMsg, aIter, &aResult->mLocalPoint);
1372 template <>
1373 struct ParamTraits<mozilla::ScrollWheelInput::ScrollDeltaType>
1374 : public ContiguousEnumSerializerInclusive<
1375 mozilla::ScrollWheelInput::ScrollDeltaType,
1376 mozilla::ScrollWheelInput::ScrollDeltaType::SCROLLDELTA_LINE,
1377 mozilla::ScrollWheelInput::sHighestScrollDeltaType> {};
1379 template <>
1380 struct ParamTraits<mozilla::ScrollWheelInput::ScrollMode>
1381 : public ContiguousEnumSerializerInclusive<
1382 mozilla::ScrollWheelInput::ScrollMode,
1383 mozilla::ScrollWheelInput::ScrollMode::SCROLLMODE_INSTANT,
1384 mozilla::ScrollWheelInput::sHighestScrollMode> {};
1386 template <>
1387 struct ParamTraits<mozilla::WheelDeltaAdjustmentStrategy>
1388 : public ContiguousEnumSerializer<
1389 mozilla::WheelDeltaAdjustmentStrategy,
1390 mozilla::WheelDeltaAdjustmentStrategy(0),
1391 mozilla::WheelDeltaAdjustmentStrategy::eSentinel> {};
1393 template <>
1394 struct ParamTraits<mozilla::layers::APZWheelAction>
1395 : public ContiguousEnumSerializerInclusive<
1396 mozilla::layers::APZWheelAction,
1397 mozilla::layers::APZWheelAction::Scroll,
1398 mozilla::layers::kHighestAPZWheelAction> {};
1400 template <>
1401 struct ParamTraits<mozilla::ScrollWheelInput> {
1402 typedef mozilla::ScrollWheelInput paramType;
1404 static void Write(Message* aMsg, const paramType& aParam) {
1405 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1406 WriteParam(aMsg, aParam.mDeltaType);
1407 WriteParam(aMsg, aParam.mScrollMode);
1408 WriteParam(aMsg, aParam.mOrigin);
1409 WriteParam(aMsg, aParam.mHandledByAPZ);
1410 WriteParam(aMsg, aParam.mDeltaX);
1411 WriteParam(aMsg, aParam.mDeltaY);
1412 WriteParam(aMsg, aParam.mWheelTicksX);
1413 WriteParam(aMsg, aParam.mWheelTicksY);
1414 WriteParam(aMsg, aParam.mLocalOrigin);
1415 WriteParam(aMsg, aParam.mLineOrPageDeltaX);
1416 WriteParam(aMsg, aParam.mLineOrPageDeltaY);
1417 WriteParam(aMsg, aParam.mScrollSeriesNumber);
1418 WriteParam(aMsg, aParam.mUserDeltaMultiplierX);
1419 WriteParam(aMsg, aParam.mUserDeltaMultiplierY);
1420 WriteParam(aMsg, aParam.mMayHaveMomentum);
1421 WriteParam(aMsg, aParam.mIsMomentum);
1422 WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed);
1423 WriteParam(aMsg, aParam.mWheelDeltaAdjustmentStrategy);
1424 WriteParam(aMsg, aParam.mAPZAction);
1427 static bool Read(const Message* aMsg, PickleIterator* aIter,
1428 paramType* aResult) {
1429 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1430 ReadParam(aMsg, aIter, &aResult->mDeltaType) &&
1431 ReadParam(aMsg, aIter, &aResult->mScrollMode) &&
1432 ReadParam(aMsg, aIter, &aResult->mOrigin) &&
1433 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
1434 ReadParam(aMsg, aIter, &aResult->mDeltaX) &&
1435 ReadParam(aMsg, aIter, &aResult->mDeltaY) &&
1436 ReadParam(aMsg, aIter, &aResult->mWheelTicksX) &&
1437 ReadParam(aMsg, aIter, &aResult->mWheelTicksY) &&
1438 ReadParam(aMsg, aIter, &aResult->mLocalOrigin) &&
1439 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaX) &&
1440 ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
1441 ReadParam(aMsg, aIter, &aResult->mScrollSeriesNumber) &&
1442 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) &&
1443 ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
1444 ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) &&
1445 ReadParam(aMsg, aIter, &aResult->mIsMomentum) &&
1446 ReadParam(aMsg, aIter,
1447 &aResult->mAllowToOverrideSystemScrollSpeed) &&
1448 ReadParam(aMsg, aIter, &aResult->mWheelDeltaAdjustmentStrategy) &&
1449 ReadParam(aMsg, aIter, &aResult->mAPZAction);
1453 template <>
1454 struct ParamTraits<mozilla::KeyboardInput::KeyboardEventType>
1455 : public ContiguousEnumSerializer<
1456 mozilla::KeyboardInput::KeyboardEventType,
1457 mozilla::KeyboardInput::KeyboardEventType::KEY_DOWN,
1458 mozilla::KeyboardInput::KeyboardEventType::KEY_SENTINEL> {};
1460 template <>
1461 struct ParamTraits<mozilla::KeyboardInput> {
1462 typedef mozilla::KeyboardInput paramType;
1464 static void Write(Message* aMsg, const paramType& aParam) {
1465 WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
1466 WriteParam(aMsg, aParam.mType);
1467 WriteParam(aMsg, aParam.mKeyCode);
1468 WriteParam(aMsg, aParam.mCharCode);
1469 WriteParam(aMsg, aParam.mShortcutCandidates);
1470 WriteParam(aMsg, aParam.mHandledByAPZ);
1473 static bool Read(const Message* aMsg, PickleIterator* aIter,
1474 paramType* aResult) {
1475 return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
1476 ReadParam(aMsg, aIter, &aResult->mType) &&
1477 ReadParam(aMsg, aIter, &aResult->mKeyCode) &&
1478 ReadParam(aMsg, aIter, &aResult->mCharCode) &&
1479 ReadParam(aMsg, aIter, &aResult->mShortcutCandidates) &&
1480 ReadParam(aMsg, aIter, &aResult->mHandledByAPZ);
1484 } // namespace IPC
1486 #endif // nsGUIEventIPC_h__