Bug 1942006 - Upstream a variety of Servo-specific code from Servo's downstream fork...
[gecko.git] / widget / nsGUIEventIPC.h
bloba1f48167403f5bfb30a66809ec3e64bea468fa05
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/ipc/IPDLParamTraits.h" // for ReadIPDLParam and WriteIPDLParam
15 #include "mozilla/ipc/URIUtils.h" // for IPDLParamTraits<nsIURI*>
16 #include "mozilla/layers/LayersMessageUtils.h"
17 #include "mozilla/MiscEvents.h"
18 #include "mozilla/MouseEvents.h"
19 #include "mozilla/TextEvents.h"
20 #include "mozilla/TouchEvents.h"
21 #include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
22 #include "mozilla/dom/Selection.h"
23 #include "InputData.h"
25 namespace IPC {
27 template <>
28 struct ParamTraits<mozilla::EventMessage>
29 : public ContiguousEnumSerializer<
30 mozilla::EventMessage, mozilla::EventMessage(0),
31 mozilla::EventMessage::eEventMessage_MaxValue> {};
33 template <>
34 struct ParamTraits<mozilla::BaseEventFlags> {
35 using paramType = mozilla::BaseEventFlags;
37 static void Write(MessageWriter* aWriter, const paramType& aParam) {
38 aWriter->WriteBytes(&aParam, sizeof(aParam));
41 static bool Read(MessageReader* aReader, paramType* aResult) {
42 return aReader->ReadBytesInto(aResult, sizeof(*aResult));
46 template <>
47 struct ParamTraits<mozilla::WidgetEvent> {
48 using paramType = mozilla::WidgetEvent;
50 static void Write(MessageWriter* aWriter, const paramType& aParam) {
51 // Mark the event as posted to another process.
52 const_cast<mozilla::WidgetEvent&>(aParam).MarkAsPostedToRemoteProcess();
54 WriteParam(aWriter, static_cast<mozilla::EventClassIDType>(aParam.mClass));
55 WriteParam(aWriter, aParam.mMessage);
56 WriteParam(aWriter, aParam.mRefPoint);
57 WriteParam(aWriter, aParam.mFocusSequenceNumber);
58 WriteParam(aWriter, aParam.mTimeStamp);
59 WriteParam(aWriter, aParam.mFlags);
60 WriteParam(aWriter, aParam.mLayersId);
63 static bool Read(MessageReader* aReader, paramType* aResult) {
64 mozilla::EventClassIDType eventClassID = 0;
65 bool ret = ReadParam(aReader, &eventClassID) &&
66 ReadParam(aReader, &aResult->mMessage) &&
67 ReadParam(aReader, &aResult->mRefPoint) &&
68 ReadParam(aReader, &aResult->mFocusSequenceNumber) &&
69 ReadParam(aReader, &aResult->mTimeStamp) &&
70 ReadParam(aReader, &aResult->mFlags) &&
71 ReadParam(aReader, &aResult->mLayersId);
72 aResult->mClass = static_cast<mozilla::EventClassID>(eventClassID);
73 if (ret) {
74 // Reset cross process dispatching state here because the event has not
75 // been dispatched to different process from current process.
76 aResult->ResetCrossProcessDispatchingState();
77 // Mark the event comes from another process.
78 aResult->MarkAsComingFromAnotherProcess();
80 return ret;
84 template <>
85 struct ParamTraits<mozilla::WidgetGUIEvent> {
86 using paramType = mozilla::WidgetGUIEvent;
88 static void Write(MessageWriter* aWriter, const paramType& aParam) {
89 WriteParam(aWriter, static_cast<const mozilla::WidgetEvent&>(aParam));
92 static bool Read(MessageReader* aReader, paramType* aResult) {
93 return ReadParam(aReader, static_cast<mozilla::WidgetEvent*>(aResult));
97 template <>
98 struct ParamTraits<mozilla::WidgetInputEvent> {
99 using paramType = mozilla::WidgetInputEvent;
101 static void Write(MessageWriter* aWriter, const paramType& aParam) {
102 WriteParam(aWriter, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
103 WriteParam(aWriter, aParam.mModifiers);
106 static bool Read(MessageReader* aReader, paramType* aResult) {
107 return ReadParam(aReader, static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
108 ReadParam(aReader, &aResult->mModifiers);
112 template <>
113 struct ParamTraits<mozilla::WidgetMouseEventBase> {
114 using paramType = mozilla::WidgetMouseEventBase;
116 static void Write(MessageWriter* aWriter, const paramType& aParam) {
117 WriteParam(aWriter, static_cast<const mozilla::WidgetInputEvent&>(aParam));
118 WriteParam(aWriter, aParam.mButton);
119 WriteParam(aWriter, aParam.mButtons);
120 WriteParam(aWriter, aParam.mPressure);
121 WriteParam(aWriter, aParam.mInputSource);
124 static bool Read(MessageReader* aReader, paramType* aResult) {
125 return ReadParam(aReader,
126 static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
127 ReadParam(aReader, &aResult->mButton) &&
128 ReadParam(aReader, &aResult->mButtons) &&
129 ReadParam(aReader, &aResult->mPressure) &&
130 ReadParam(aReader, &aResult->mInputSource);
134 template <>
135 struct ParamTraits<mozilla::WidgetWheelEvent> {
136 using paramType = mozilla::WidgetWheelEvent;
138 static void Write(MessageWriter* aWriter, const paramType& aParam) {
139 WriteParam(aWriter,
140 static_cast<const mozilla::WidgetMouseEventBase&>(aParam));
141 WriteParam(aWriter, aParam.mDeltaX);
142 WriteParam(aWriter, aParam.mDeltaY);
143 WriteParam(aWriter, aParam.mDeltaZ);
144 WriteParam(aWriter, aParam.mDeltaMode);
145 WriteParam(aWriter, aParam.mWheelTicksX);
146 WriteParam(aWriter, aParam.mWheelTicksY);
147 WriteParam(aWriter, aParam.mCustomizedByUserPrefs);
148 WriteParam(aWriter, aParam.mMayHaveMomentum);
149 WriteParam(aWriter, aParam.mIsMomentum);
150 WriteParam(aWriter, aParam.mIsNoLineOrPageDelta);
151 WriteParam(aWriter, aParam.mLineOrPageDeltaX);
152 WriteParam(aWriter, aParam.mLineOrPageDeltaY);
153 WriteParam(aWriter, static_cast<uint8_t>(aParam.mScrollType));
154 WriteParam(aWriter, aParam.mOverflowDeltaX);
155 WriteParam(aWriter, aParam.mOverflowDeltaY);
156 WriteParam(aWriter, aParam.mViewPortIsOverscrolled);
157 WriteParam(aWriter, aParam.mCanTriggerSwipe);
158 WriteParam(aWriter, aParam.mAllowToOverrideSystemScrollSpeed);
159 WriteParam(aWriter, aParam.mDeltaValuesHorizontalizedForDefaultHandler);
162 static bool Read(MessageReader* aReader, paramType* aResult) {
163 uint8_t scrollType = 0;
164 bool rv = ReadParam(aReader,
165 static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
166 ReadParam(aReader, &aResult->mDeltaX) &&
167 ReadParam(aReader, &aResult->mDeltaY) &&
168 ReadParam(aReader, &aResult->mDeltaZ) &&
169 ReadParam(aReader, &aResult->mDeltaMode) &&
170 ReadParam(aReader, &aResult->mWheelTicksX) &&
171 ReadParam(aReader, &aResult->mWheelTicksY) &&
172 ReadParam(aReader, &aResult->mCustomizedByUserPrefs) &&
173 ReadParam(aReader, &aResult->mMayHaveMomentum) &&
174 ReadParam(aReader, &aResult->mIsMomentum) &&
175 ReadParam(aReader, &aResult->mIsNoLineOrPageDelta) &&
176 ReadParam(aReader, &aResult->mLineOrPageDeltaX) &&
177 ReadParam(aReader, &aResult->mLineOrPageDeltaY) &&
178 ReadParam(aReader, &scrollType) &&
179 ReadParam(aReader, &aResult->mOverflowDeltaX) &&
180 ReadParam(aReader, &aResult->mOverflowDeltaY) &&
181 ReadParam(aReader, &aResult->mViewPortIsOverscrolled) &&
182 ReadParam(aReader, &aResult->mCanTriggerSwipe) &&
183 ReadParam(aReader, &aResult->mAllowToOverrideSystemScrollSpeed) &&
184 ReadParam(aReader,
185 &aResult->mDeltaValuesHorizontalizedForDefaultHandler);
186 aResult->mScrollType =
187 static_cast<mozilla::WidgetWheelEvent::ScrollType>(scrollType);
188 return rv;
192 template <>
193 struct ParamTraits<mozilla::WidgetPointerHelper> {
194 using paramType = mozilla::WidgetPointerHelper;
196 static void Write(MessageWriter* aWriter, const paramType& aParam) {
197 WriteParam(aWriter, aParam.pointerId);
198 WriteParam(aWriter, aParam.tiltX);
199 WriteParam(aWriter, aParam.tiltY);
200 WriteParam(aWriter, aParam.twist);
201 WriteParam(aWriter, aParam.tangentialPressure);
202 // We don't serialize convertToPointer since it's temporarily variable and
203 // should be reset to default.
206 static bool Read(MessageReader* aReader, paramType* aResult) {
207 bool rv;
208 rv = ReadParam(aReader, &aResult->pointerId) &&
209 ReadParam(aReader, &aResult->tiltX) &&
210 ReadParam(aReader, &aResult->tiltY) &&
211 ReadParam(aReader, &aResult->twist) &&
212 ReadParam(aReader, &aResult->tangentialPressure);
213 return rv;
217 template <>
218 struct ParamTraits<mozilla::WidgetMouseEvent> {
219 using paramType = mozilla::WidgetMouseEvent;
221 // We don't need to copy the following members:
222 // - mIgnoreCapturingContent: When this is `true`, the remote process should
223 // not be capturing the pointer because this is used to dispatch boundary
224 // events outside the capturing element after handling ePointerUp/eMouseUp.
225 // - mSynthesizeMoveAfterDispatch: When this is `true`, the event needs to
226 // synthesize a move event to dispatch corresponding boundary events.
227 // However, when a remote content is under the pointer, it should occur
228 // before dispatching this event in the remote process, but there is no
229 // path to do that. Therefore, this flag is not required for now.
231 static void Write(MessageWriter* aWriter, const paramType& aParam) {
232 WriteParam(aWriter,
233 static_cast<const mozilla::WidgetMouseEventBase&>(aParam));
234 WriteParam(aWriter,
235 static_cast<const mozilla::WidgetPointerHelper&>(aParam));
236 WriteParam(aWriter, aParam.mIgnoreRootScrollFrame);
237 WriteParam(aWriter, aParam.mClickEventPrevented);
238 WriteParam(aWriter, static_cast<paramType::ReasonType>(aParam.mReason));
239 WriteParam(aWriter, static_cast<paramType::ContextMenuTriggerType>(
240 aParam.mContextMenuTrigger));
241 WriteParam(aWriter, aParam.mExitFrom.isSome());
242 if (aParam.mExitFrom.isSome()) {
243 WriteParam(aWriter, static_cast<paramType::ExitFromType>(
244 aParam.mExitFrom.value()));
246 WriteParam(aWriter, aParam.mClickCount);
249 static bool Read(MessageReader* aReader, paramType* aResult) {
250 bool rv;
251 paramType::ReasonType reason = 0;
252 paramType::ContextMenuTriggerType contextMenuTrigger = 0;
253 bool hasExitFrom = false;
254 rv = ReadParam(aReader,
255 static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
256 ReadParam(aReader,
257 static_cast<mozilla::WidgetPointerHelper*>(aResult)) &&
258 ReadParam(aReader, &aResult->mIgnoreRootScrollFrame) &&
259 ReadParam(aReader, &aResult->mClickEventPrevented) &&
260 ReadParam(aReader, &reason) && ReadParam(aReader, &contextMenuTrigger);
261 aResult->mReason = static_cast<paramType::Reason>(reason);
262 aResult->mContextMenuTrigger =
263 static_cast<paramType::ContextMenuTrigger>(contextMenuTrigger);
264 rv = rv && ReadParam(aReader, &hasExitFrom);
265 if (hasExitFrom) {
266 paramType::ExitFromType exitFrom = 0;
267 rv = rv && ReadParam(aReader, &exitFrom);
268 aResult->mExitFrom = Some(static_cast<paramType::ExitFrom>(exitFrom));
270 rv = rv && ReadParam(aReader, &aResult->mClickCount);
271 return rv;
275 template <>
276 struct ParamTraits<mozilla::WidgetDragEvent> {
277 using paramType = mozilla::WidgetDragEvent;
279 static void Write(MessageWriter* aWriter, const paramType& aParam) {
280 WriteParam(aWriter, static_cast<const mozilla::WidgetMouseEvent&>(aParam));
281 WriteParam(aWriter, aParam.mUserCancelled);
282 WriteParam(aWriter, aParam.mDefaultPreventedOnContent);
283 WriteParam(aWriter, aParam.mInHTMLEditorEventListener);
286 static bool Read(MessageReader* aReader, paramType* aResult) {
287 bool rv =
288 ReadParam(aReader, static_cast<mozilla::WidgetMouseEvent*>(aResult)) &&
289 ReadParam(aReader, &aResult->mUserCancelled) &&
290 ReadParam(aReader, &aResult->mDefaultPreventedOnContent) &&
291 ReadParam(aReader, &aResult->mInHTMLEditorEventListener);
292 return rv;
296 template <>
297 struct ParamTraits<mozilla::WidgetPointerEvent> {
298 using paramType = mozilla::WidgetPointerEvent;
300 static void Write(MessageWriter* aWriter, const paramType& aParam) {
301 WriteParam(aWriter, static_cast<const mozilla::WidgetMouseEvent&>(aParam));
302 WriteParam(aWriter, aParam.mWidth);
303 WriteParam(aWriter, aParam.mHeight);
304 WriteParam(aWriter, aParam.mIsPrimary);
305 WriteParam(aWriter, aParam.mFromTouchEvent);
308 static bool Read(MessageReader* aReader, paramType* aResult) {
309 bool rv =
310 ReadParam(aReader, static_cast<mozilla::WidgetMouseEvent*>(aResult)) &&
311 ReadParam(aReader, &aResult->mWidth) &&
312 ReadParam(aReader, &aResult->mHeight) &&
313 ReadParam(aReader, &aResult->mIsPrimary) &&
314 ReadParam(aReader, &aResult->mFromTouchEvent);
315 return rv;
319 template <>
320 struct ParamTraits<mozilla::WidgetTouchEvent> {
321 using paramType = mozilla::WidgetTouchEvent;
323 static void Write(MessageWriter* aWriter, const paramType& aParam) {
324 WriteParam(aWriter, static_cast<const mozilla::WidgetInputEvent&>(aParam));
325 WriteParam(aWriter, aParam.mInputSource);
326 WriteParam(aWriter, aParam.mButton);
327 WriteParam(aWriter, aParam.mButtons);
328 // Sigh, Touch bites us again! We want to be able to do
329 // WriteParam(aWriter, aParam.mTouches);
330 const paramType::TouchArray& touches = aParam.mTouches;
331 WriteParam(aWriter, touches.Length());
332 for (uint32_t i = 0; i < touches.Length(); ++i) {
333 mozilla::dom::Touch* touch = touches[i];
334 WriteParam(aWriter, touch->mIdentifier);
335 WriteParam(aWriter, touch->mRefPoint);
336 WriteParam(aWriter, touch->mRadius);
337 WriteParam(aWriter, touch->mRotationAngle);
338 WriteParam(aWriter, touch->mForce);
339 WriteParam(aWriter, touch->tiltX);
340 WriteParam(aWriter, touch->tiltY);
341 WriteParam(aWriter, touch->twist);
345 static bool Read(MessageReader* aReader, paramType* aResult) {
346 paramType::TouchArray::size_type numTouches;
347 if (!ReadParam(aReader, static_cast<mozilla::WidgetInputEvent*>(aResult)) ||
348 !ReadParam(aReader, &aResult->mInputSource) ||
349 !ReadParam(aReader, &aResult->mButton) ||
350 !ReadParam(aReader, &aResult->mButtons) ||
351 !ReadParam(aReader, &numTouches)) {
352 return false;
354 for (uint32_t i = 0; i < numTouches; ++i) {
355 int32_t identifier;
356 mozilla::LayoutDeviceIntPoint refPoint;
357 mozilla::LayoutDeviceIntPoint radius;
358 float rotationAngle;
359 float force;
360 uint32_t tiltX;
361 uint32_t tiltY;
362 uint32_t twist;
363 if (!ReadParam(aReader, &identifier) || !ReadParam(aReader, &refPoint) ||
364 !ReadParam(aReader, &radius) || !ReadParam(aReader, &rotationAngle) ||
365 !ReadParam(aReader, &force) || !ReadParam(aReader, &tiltX) ||
366 !ReadParam(aReader, &tiltY) || !ReadParam(aReader, &twist)) {
367 return false;
369 auto* touch = new mozilla::dom::Touch(identifier, refPoint, radius,
370 rotationAngle, force);
371 touch->tiltX = tiltX;
372 touch->tiltY = tiltY;
373 touch->twist = twist;
374 aResult->mTouches.AppendElement(touch);
376 return true;
380 template <>
381 struct ParamTraits<mozilla::AlternativeCharCode> {
382 using paramType = mozilla::AlternativeCharCode;
384 static void Write(MessageWriter* aWriter, const paramType& aParam) {
385 WriteParam(aWriter, aParam.mUnshiftedCharCode);
386 WriteParam(aWriter, aParam.mShiftedCharCode);
389 static bool Read(MessageReader* aReader, paramType* aResult) {
390 return ReadParam(aReader, &aResult->mUnshiftedCharCode) &&
391 ReadParam(aReader, &aResult->mShiftedCharCode);
395 template <>
396 struct ParamTraits<mozilla::ShortcutKeyCandidate::ShiftState>
397 : public ContiguousEnumSerializerInclusive<
398 mozilla::ShortcutKeyCandidate::ShiftState,
399 mozilla::ShortcutKeyCandidate::ShiftState::Ignorable,
400 mozilla::ShortcutKeyCandidate::ShiftState::MatchExactly> {};
402 template <>
403 struct ParamTraits<mozilla::ShortcutKeyCandidate::SkipIfEarlierHandlerDisabled>
404 : public ContiguousEnumSerializerInclusive<
405 mozilla::ShortcutKeyCandidate::SkipIfEarlierHandlerDisabled,
406 mozilla::ShortcutKeyCandidate::SkipIfEarlierHandlerDisabled::No,
407 mozilla::ShortcutKeyCandidate::SkipIfEarlierHandlerDisabled::Yes> {};
409 template <>
410 struct ParamTraits<mozilla::ShortcutKeyCandidate> {
411 using paramType = mozilla::ShortcutKeyCandidate;
413 static void Write(MessageWriter* aWriter, const paramType& aParam) {
414 WriteParam(aWriter, aParam.mCharCode);
415 WriteParam(aWriter, aParam.mShiftState);
416 WriteParam(aWriter, aParam.mSkipIfEarlierHandlerDisabled);
419 static bool Read(MessageReader* aReader, paramType* aResult) {
420 return ReadParam(aReader, &aResult->mCharCode) &&
421 ReadParam(aReader, &aResult->mShiftState) &&
422 ReadParam(aReader, &aResult->mSkipIfEarlierHandlerDisabled);
426 template <>
427 struct ParamTraits<mozilla::WidgetKeyboardEvent> {
428 using paramType = mozilla::WidgetKeyboardEvent;
430 static void Write(MessageWriter* aWriter, const paramType& aParam) {
431 WriteParam(aWriter, static_cast<const mozilla::WidgetInputEvent&>(aParam));
432 WriteParam(aWriter,
433 static_cast<mozilla::KeyNameIndexType>(aParam.mKeyNameIndex));
434 WriteParam(aWriter,
435 static_cast<mozilla::CodeNameIndexType>(aParam.mCodeNameIndex));
436 WriteParam(aWriter, aParam.mKeyValue);
437 WriteParam(aWriter, aParam.mCodeValue);
438 WriteParam(aWriter, aParam.mKeyCode);
439 WriteParam(aWriter, aParam.mCharCode);
440 WriteParam(aWriter, aParam.mPseudoCharCode);
441 WriteParam(aWriter, aParam.mAlternativeCharCodes);
442 WriteParam(aWriter, aParam.mIsRepeat);
443 WriteParam(aWriter, aParam.mLocation);
444 WriteParam(aWriter, aParam.mUniqueId);
445 WriteParam(aWriter, aParam.mIsSynthesizedByTIP);
446 WriteParam(aWriter, aParam.mMaybeSkippableInRemoteProcess);
448 // An OS-specific native event might be attached in |mNativeKeyEvent|, but
449 // that cannot be copied across process boundaries.
451 WriteParam(aWriter, aParam.mEditCommandsForSingleLineEditor);
452 WriteParam(aWriter, aParam.mEditCommandsForMultiLineEditor);
453 WriteParam(aWriter, aParam.mEditCommandsForRichTextEditor);
454 WriteParam(aWriter, aParam.mEditCommandsForSingleLineEditorInitialized);
455 WriteParam(aWriter, aParam.mEditCommandsForMultiLineEditorInitialized);
456 WriteParam(aWriter, aParam.mEditCommandsForRichTextEditorInitialized);
459 static bool Read(MessageReader* aReader, paramType* aResult) {
460 mozilla::KeyNameIndexType keyNameIndex = 0;
461 mozilla::CodeNameIndexType codeNameIndex = 0;
462 if (ReadParam(aReader, static_cast<mozilla::WidgetInputEvent*>(aResult)) &&
463 ReadParam(aReader, &keyNameIndex) &&
464 ReadParam(aReader, &codeNameIndex) &&
465 ReadParam(aReader, &aResult->mKeyValue) &&
466 ReadParam(aReader, &aResult->mCodeValue) &&
467 ReadParam(aReader, &aResult->mKeyCode) &&
468 ReadParam(aReader, &aResult->mCharCode) &&
469 ReadParam(aReader, &aResult->mPseudoCharCode) &&
470 ReadParam(aReader, &aResult->mAlternativeCharCodes) &&
471 ReadParam(aReader, &aResult->mIsRepeat) &&
472 ReadParam(aReader, &aResult->mLocation) &&
473 ReadParam(aReader, &aResult->mUniqueId) &&
474 ReadParam(aReader, &aResult->mIsSynthesizedByTIP) &&
475 ReadParam(aReader, &aResult->mMaybeSkippableInRemoteProcess) &&
476 ReadParam(aReader, &aResult->mEditCommandsForSingleLineEditor) &&
477 ReadParam(aReader, &aResult->mEditCommandsForMultiLineEditor) &&
478 ReadParam(aReader, &aResult->mEditCommandsForRichTextEditor) &&
479 ReadParam(aReader,
480 &aResult->mEditCommandsForSingleLineEditorInitialized) &&
481 ReadParam(aReader,
482 &aResult->mEditCommandsForMultiLineEditorInitialized) &&
483 ReadParam(aReader,
484 &aResult->mEditCommandsForRichTextEditorInitialized)) {
485 aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
486 aResult->mCodeNameIndex =
487 static_cast<mozilla::CodeNameIndex>(codeNameIndex);
488 aResult->mNativeKeyEvent = nullptr;
489 return true;
491 return false;
495 template <>
496 struct ParamTraits<mozilla::TextRangeStyle> {
497 using paramType = mozilla::TextRangeStyle;
499 static void Write(MessageWriter* aWriter, const paramType& aParam) {
500 WriteParam(aWriter, aParam.mDefinedStyles);
501 WriteParam(aWriter, static_cast<mozilla::TextRangeStyle::LineStyleType>(
502 aParam.mLineStyle));
503 WriteParam(aWriter, aParam.mIsBoldLine);
504 WriteParam(aWriter, aParam.mForegroundColor);
505 WriteParam(aWriter, aParam.mBackgroundColor);
506 WriteParam(aWriter, aParam.mUnderlineColor);
509 static bool Read(MessageReader* aReader, paramType* aResult) {
510 mozilla::TextRangeStyle::LineStyleType lineStyle;
511 if (!ReadParam(aReader, &aResult->mDefinedStyles) ||
512 !ReadParam(aReader, &lineStyle) ||
513 !ReadParam(aReader, &aResult->mIsBoldLine) ||
514 !ReadParam(aReader, &aResult->mForegroundColor) ||
515 !ReadParam(aReader, &aResult->mBackgroundColor) ||
516 !ReadParam(aReader, &aResult->mUnderlineColor)) {
517 return false;
519 aResult->mLineStyle = mozilla::TextRangeStyle::ToLineStyle(lineStyle);
520 return true;
524 template <>
525 struct ParamTraits<mozilla::TextRange> {
526 using paramType = mozilla::TextRange;
528 static void Write(MessageWriter* aWriter, const paramType& aParam) {
529 WriteParam(aWriter, aParam.mStartOffset);
530 WriteParam(aWriter, aParam.mEndOffset);
531 WriteParam(aWriter, mozilla::ToRawTextRangeType(aParam.mRangeType));
532 WriteParam(aWriter, aParam.mRangeStyle);
535 static bool Read(MessageReader* aReader, paramType* aResult) {
536 mozilla::RawTextRangeType rawTextRangeType;
537 if (ReadParam(aReader, &aResult->mStartOffset) &&
538 ReadParam(aReader, &aResult->mEndOffset) &&
539 ReadParam(aReader, &rawTextRangeType) &&
540 ReadParam(aReader, &aResult->mRangeStyle)) {
541 aResult->mRangeType = mozilla::ToTextRangeType(rawTextRangeType);
542 return true;
544 return false;
548 template <>
549 struct ParamTraits<mozilla::TextRangeArray> {
550 using paramType = mozilla::TextRangeArray;
552 static void Write(MessageWriter* aWriter, const paramType& aParam) {
553 WriteParam(aWriter, aParam.Length());
554 for (uint32_t index = 0; index < aParam.Length(); index++) {
555 WriteParam(aWriter, aParam[index]);
559 static bool Read(MessageReader* aReader, paramType* aResult) {
560 paramType::size_type length;
561 if (!ReadParam(aReader, &length)) {
562 return false;
564 for (uint32_t index = 0; index < length; index++) {
565 mozilla::TextRange textRange;
566 if (!ReadParam(aReader, &textRange)) {
567 aResult->Clear();
568 return false;
570 aResult->AppendElement(textRange);
572 return true;
576 template <>
577 struct ParamTraits<mozilla::WidgetCompositionEvent> {
578 using paramType = mozilla::WidgetCompositionEvent;
580 static void Write(MessageWriter* aWriter, const paramType& aParam) {
581 WriteParam(aWriter, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
582 WriteParam(aWriter, aParam.mData);
583 WriteParam(aWriter, aParam.mNativeIMEContext);
584 WriteParam(aWriter, aParam.mCompositionId);
585 bool hasRanges = !!aParam.mRanges;
586 WriteParam(aWriter, hasRanges);
587 if (hasRanges) {
588 WriteParam(aWriter, *aParam.mRanges.get());
592 static bool Read(MessageReader* aReader, paramType* aResult) {
593 bool hasRanges;
594 if (!ReadParam(aReader, static_cast<mozilla::WidgetGUIEvent*>(aResult)) ||
595 !ReadParam(aReader, &aResult->mData) ||
596 !ReadParam(aReader, &aResult->mNativeIMEContext) ||
597 !ReadParam(aReader, &aResult->mCompositionId) ||
598 !ReadParam(aReader, &hasRanges)) {
599 return false;
602 if (!hasRanges) {
603 aResult->mRanges = nullptr;
604 } else {
605 aResult->mRanges = new mozilla::TextRangeArray();
606 if (!ReadParam(aReader, aResult->mRanges.get())) {
607 return false;
610 return true;
614 template <>
615 struct ParamTraits<mozilla::FontRange> {
616 using paramType = mozilla::FontRange;
618 static void Write(MessageWriter* aWriter, const paramType& aParam) {
619 WriteParam(aWriter, aParam.mStartOffset);
620 WriteParam(aWriter, aParam.mFontName);
621 WriteParam(aWriter, aParam.mFontSize);
624 static bool Read(MessageReader* aReader, paramType* aResult) {
625 return ReadParam(aReader, &aResult->mStartOffset) &&
626 ReadParam(aReader, &aResult->mFontName) &&
627 ReadParam(aReader, &aResult->mFontSize);
631 template <>
632 struct ParamTraits<mozilla::WidgetSelectionEvent> {
633 using paramType = mozilla::WidgetSelectionEvent;
635 static void Write(MessageWriter* aWriter, const paramType& aParam) {
636 WriteParam(aWriter, static_cast<const mozilla::WidgetGUIEvent&>(aParam));
637 WriteParam(aWriter, aParam.mOffset);
638 WriteParam(aWriter, aParam.mLength);
639 WriteParam(aWriter, aParam.mReversed);
640 WriteParam(aWriter, aParam.mExpandToClusterBoundary);
641 WriteParam(aWriter, aParam.mSucceeded);
642 WriteParam(aWriter, aParam.mUseNativeLineBreak);
645 static bool Read(MessageReader* aReader, paramType* aResult) {
646 return ReadParam(aReader, static_cast<mozilla::WidgetGUIEvent*>(aResult)) &&
647 ReadParam(aReader, &aResult->mOffset) &&
648 ReadParam(aReader, &aResult->mLength) &&
649 ReadParam(aReader, &aResult->mReversed) &&
650 ReadParam(aReader, &aResult->mExpandToClusterBoundary) &&
651 ReadParam(aReader, &aResult->mSucceeded) &&
652 ReadParam(aReader, &aResult->mUseNativeLineBreak);
656 template <>
657 struct ParamTraits<mozilla::widget::IMENotificationRequests> {
658 using paramType = mozilla::widget::IMENotificationRequests;
660 static void Write(MessageWriter* aWriter, const paramType& aParam) {
661 WriteParam(aWriter, aParam.mWantUpdates);
664 static bool Read(MessageReader* aReader, paramType* aResult) {
665 return ReadParam(aReader, &aResult->mWantUpdates);
669 template <>
670 struct ParamTraits<mozilla::widget::NativeIMEContext> {
671 using paramType = mozilla::widget::NativeIMEContext;
673 static void Write(MessageWriter* aWriter, const paramType& aParam) {
674 WriteParam(aWriter, aParam.mRawNativeIMEContext);
675 WriteParam(aWriter, aParam.mOriginProcessID);
678 static bool Read(MessageReader* aReader, paramType* aResult) {
679 return ReadParam(aReader, &aResult->mRawNativeIMEContext) &&
680 ReadParam(aReader, &aResult->mOriginProcessID);
684 template <>
685 struct ParamTraits<mozilla::widget::IMENotification::SelectionChangeDataBase> {
686 using paramType = mozilla::widget::IMENotification::SelectionChangeDataBase;
688 static void Write(MessageWriter* aWriter, const paramType& aParam) {
689 MOZ_RELEASE_ASSERT(aParam.mString);
690 WriteParam(aWriter, aParam.mOffset);
691 WriteParam(aWriter, *aParam.mString);
692 WriteParam(aWriter, aParam.mWritingModeBits);
693 WriteParam(aWriter, aParam.mIsInitialized);
694 WriteParam(aWriter, aParam.mHasRange);
695 WriteParam(aWriter, aParam.mReversed);
696 WriteParam(aWriter, aParam.mCausedByComposition);
697 WriteParam(aWriter, aParam.mCausedBySelectionEvent);
698 WriteParam(aWriter, aParam.mOccurredDuringComposition);
701 static bool Read(MessageReader* aReader, paramType* aResult) {
702 aResult->mString = new nsString();
703 return ReadParam(aReader, &aResult->mOffset) &&
704 ReadParam(aReader, aResult->mString) &&
705 ReadParam(aReader, &aResult->mWritingModeBits) &&
706 ReadParam(aReader, &aResult->mIsInitialized) &&
707 ReadParam(aReader, &aResult->mHasRange) &&
708 ReadParam(aReader, &aResult->mReversed) &&
709 ReadParam(aReader, &aResult->mCausedByComposition) &&
710 ReadParam(aReader, &aResult->mCausedBySelectionEvent) &&
711 ReadParam(aReader, &aResult->mOccurredDuringComposition);
715 template <>
716 struct ParamTraits<mozilla::widget::IMENotification::TextChangeDataBase> {
717 using paramType = mozilla::widget::IMENotification::TextChangeDataBase;
719 static void Write(MessageWriter* aWriter, const paramType& aParam) {
720 WriteParam(aWriter, aParam.mStartOffset);
721 WriteParam(aWriter, aParam.mRemovedEndOffset);
722 WriteParam(aWriter, aParam.mAddedEndOffset);
723 WriteParam(aWriter, aParam.mCausedOnlyByComposition);
724 WriteParam(aWriter, aParam.mIncludingChangesDuringComposition);
725 WriteParam(aWriter, aParam.mIncludingChangesWithoutComposition);
728 static bool Read(MessageReader* aReader, paramType* aResult) {
729 return ReadParam(aReader, &aResult->mStartOffset) &&
730 ReadParam(aReader, &aResult->mRemovedEndOffset) &&
731 ReadParam(aReader, &aResult->mAddedEndOffset) &&
732 ReadParam(aReader, &aResult->mCausedOnlyByComposition) &&
733 ReadParam(aReader, &aResult->mIncludingChangesDuringComposition) &&
734 ReadParam(aReader, &aResult->mIncludingChangesWithoutComposition);
738 template <>
739 struct ParamTraits<mozilla::widget::IMENotification::MouseButtonEventData> {
740 using paramType = mozilla::widget::IMENotification::MouseButtonEventData;
742 static void Write(MessageWriter* aWriter, const paramType& aParam) {
743 WriteParam(aWriter, aParam.mEventMessage);
744 WriteParam(aWriter, aParam.mOffset);
745 WriteParam(aWriter, aParam.mCursorPos);
746 WriteParam(aWriter, aParam.mCharRect);
747 WriteParam(aWriter, aParam.mButton);
748 WriteParam(aWriter, aParam.mButtons);
749 WriteParam(aWriter, aParam.mModifiers);
752 static bool Read(MessageReader* aReader, paramType* aResult) {
753 return ReadParam(aReader, &aResult->mEventMessage) &&
754 ReadParam(aReader, &aResult->mOffset) &&
755 ReadParam(aReader, &aResult->mCursorPos) &&
756 ReadParam(aReader, &aResult->mCharRect) &&
757 ReadParam(aReader, &aResult->mButton) &&
758 ReadParam(aReader, &aResult->mButtons) &&
759 ReadParam(aReader, &aResult->mModifiers);
763 template <>
764 struct ParamTraits<mozilla::widget::IMENotification> {
765 using paramType = mozilla::widget::IMENotification;
767 static void Write(MessageWriter* aWriter, const paramType& aParam) {
768 WriteParam(aWriter,
769 static_cast<mozilla::widget::IMEMessageType>(aParam.mMessage));
770 switch (aParam.mMessage) {
771 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
772 WriteParam(aWriter, aParam.mSelectionChangeData);
773 return;
774 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
775 WriteParam(aWriter, aParam.mTextChangeData);
776 return;
777 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
778 WriteParam(aWriter, aParam.mMouseButtonEventData);
779 return;
780 default:
781 return;
785 static bool Read(MessageReader* aReader, paramType* aResult) {
786 mozilla::widget::IMEMessageType IMEMessage = 0;
787 if (!ReadParam(aReader, &IMEMessage)) {
788 return false;
790 aResult->mMessage = static_cast<mozilla::widget::IMEMessage>(IMEMessage);
791 switch (aResult->mMessage) {
792 case mozilla::widget::NOTIFY_IME_OF_SELECTION_CHANGE:
793 return ReadParam(aReader, &aResult->mSelectionChangeData);
794 case mozilla::widget::NOTIFY_IME_OF_TEXT_CHANGE:
795 return ReadParam(aReader, &aResult->mTextChangeData);
796 case mozilla::widget::NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
797 return ReadParam(aReader, &aResult->mMouseButtonEventData);
798 default:
799 return true;
804 template <>
805 struct ParamTraits<mozilla::widget::IMEEnabled>
806 : ContiguousEnumSerializer<mozilla::widget::IMEEnabled,
807 mozilla::widget::IMEEnabled::Disabled,
808 mozilla::widget::IMEEnabled::Unknown> {};
810 template <>
811 struct ParamTraits<mozilla::widget::IMEState::Open>
812 : ContiguousEnumSerializerInclusive<
813 mozilla::widget::IMEState::Open,
814 mozilla::widget::IMEState::Open::OPEN_STATE_NOT_SUPPORTED,
815 mozilla::widget::IMEState::Open::CLOSED> {};
817 template <>
818 struct ParamTraits<mozilla::widget::IMEState> {
819 using paramType = mozilla::widget::IMEState;
821 static void Write(MessageWriter* aWriter, const paramType& aParam) {
822 WriteParam(aWriter, aParam.mEnabled);
823 WriteParam(aWriter, aParam.mOpen);
826 static bool Read(MessageReader* aReader, paramType* aResult) {
827 return ReadParam(aReader, &aResult->mEnabled) &&
828 ReadParam(aReader, &aResult->mOpen);
832 template <>
833 struct ParamTraits<mozilla::widget::InputContext::Origin>
834 : ContiguousEnumSerializerInclusive<
835 mozilla::widget::InputContext::Origin,
836 mozilla::widget::InputContext::Origin::ORIGIN_MAIN,
837 mozilla::widget::InputContext::Origin::ORIGIN_CONTENT> {};
839 template <>
840 struct ParamTraits<mozilla::widget::InputContext> {
841 using paramType = mozilla::widget::InputContext;
843 static void Write(MessageWriter* aWriter, const paramType& aParam) {
844 WriteParam(aWriter, aParam.mIMEState);
845 WriteParam(aWriter, aParam.mHTMLInputType);
846 WriteParam(aWriter, aParam.mHTMLInputMode);
847 WriteParam(aWriter, aParam.mActionHint);
848 WriteParam(aWriter, aParam.mAutocapitalize);
849 WriteParam(aWriter, aParam.mAutocorrect);
850 WriteParam(aWriter, aParam.mOrigin);
851 WriteParam(aWriter, aParam.mHasHandledUserInput);
852 WriteParam(aWriter, aParam.mInPrivateBrowsing);
853 mozilla::ipc::WriteIPDLParam(aWriter, aWriter->GetActor(), aParam.mURI);
856 static bool Read(MessageReader* aReader, paramType* aResult) {
857 return ReadParam(aReader, &aResult->mIMEState) &&
858 ReadParam(aReader, &aResult->mHTMLInputType) &&
859 ReadParam(aReader, &aResult->mHTMLInputMode) &&
860 ReadParam(aReader, &aResult->mActionHint) &&
861 ReadParam(aReader, &aResult->mAutocapitalize) &&
862 ReadParam(aReader, &aResult->mAutocorrect) &&
863 ReadParam(aReader, &aResult->mOrigin) &&
864 ReadParam(aReader, &aResult->mHasHandledUserInput) &&
865 ReadParam(aReader, &aResult->mInPrivateBrowsing) &&
866 mozilla::ipc::ReadIPDLParam(aReader, aReader->GetActor(),
867 address_of(aResult->mURI));
871 template <>
872 struct ParamTraits<mozilla::widget::InputContextAction::Cause>
873 : ContiguousEnumSerializerInclusive<
874 mozilla::widget::InputContextAction::Cause,
875 mozilla::widget::InputContextAction::Cause::CAUSE_UNKNOWN,
876 mozilla::widget::InputContextAction::Cause::
877 CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT> {};
879 template <>
880 struct ParamTraits<mozilla::widget::InputContextAction::FocusChange>
881 : ContiguousEnumSerializerInclusive<
882 mozilla::widget::InputContextAction::FocusChange,
883 mozilla::widget::InputContextAction::FocusChange::FOCUS_NOT_CHANGED,
884 mozilla::widget::InputContextAction::FocusChange::WIDGET_CREATED> {};
886 template <>
887 struct ParamTraits<mozilla::widget::InputContextAction> {
888 using paramType = mozilla::widget::InputContextAction;
890 static void Write(MessageWriter* aWriter, const paramType& aParam) {
891 WriteParam(aWriter, aParam.mCause);
892 WriteParam(aWriter, aParam.mFocusChange);
895 static bool Read(MessageReader* aReader, paramType* aResult) {
896 return ReadParam(aReader, &aResult->mCause) &&
897 ReadParam(aReader, &aResult->mFocusChange);
901 template <>
902 struct ParamTraits<mozilla::WritingMode> {
903 using paramType = mozilla::WritingMode;
905 static void Write(MessageWriter* aWriter, const paramType& aParam) {
906 WriteParam(aWriter, aParam.mWritingMode._0);
909 static bool Read(MessageReader* aReader, paramType* aResult) {
910 return ReadParam(aReader, &aResult->mWritingMode._0);
914 template <>
915 struct ParamTraits<mozilla::ContentCache::Selection> {
916 using paramType = mozilla::ContentCache::Selection;
918 static void Write(MessageWriter* aWriter, const paramType& aParam) {
919 WriteParam(aWriter, aParam.mAnchor);
920 WriteParam(aWriter, aParam.mFocus);
921 WriteParam(aWriter, aParam.mWritingMode);
922 WriteParam(aWriter, aParam.mHasRange);
923 WriteParam(aWriter, aParam.mAnchorCharRects[0]);
924 WriteParam(aWriter, aParam.mAnchorCharRects[1]);
925 WriteParam(aWriter, aParam.mFocusCharRects[0]);
926 WriteParam(aWriter, aParam.mFocusCharRects[1]);
927 WriteParam(aWriter, aParam.mRect);
930 static bool Read(MessageReader* aReader, paramType* aResult) {
931 return ReadParam(aReader, &aResult->mAnchor) &&
932 ReadParam(aReader, &aResult->mFocus) &&
933 ReadParam(aReader, &aResult->mWritingMode) &&
934 ReadParam(aReader, &aResult->mHasRange) &&
935 ReadParam(aReader, &aResult->mAnchorCharRects[0]) &&
936 ReadParam(aReader, &aResult->mAnchorCharRects[1]) &&
937 ReadParam(aReader, &aResult->mFocusCharRects[0]) &&
938 ReadParam(aReader, &aResult->mFocusCharRects[1]) &&
939 ReadParam(aReader, &aResult->mRect);
943 template <>
944 struct ParamTraits<mozilla::ContentCache::Caret> {
945 using paramType = mozilla::ContentCache::Caret;
947 static void Write(MessageWriter* aWriter, const paramType& aParam) {
948 WriteParam(aWriter, aParam.mOffset);
949 WriteParam(aWriter, aParam.mRect);
952 static bool Read(MessageReader* aReader, paramType* aResult) {
953 return ReadParam(aReader, &aResult->mOffset) &&
954 ReadParam(aReader, &aResult->mRect);
958 template <>
959 struct ParamTraits<mozilla::ContentCache::TextRectArray> {
960 using paramType = mozilla::ContentCache::TextRectArray;
962 static void Write(MessageWriter* aWriter, const paramType& aParam) {
963 WriteParam(aWriter, aParam.mStart);
964 WriteParam(aWriter, aParam.mRects);
967 static bool Read(MessageReader* aReader, paramType* aResult) {
968 return ReadParam(aReader, &aResult->mStart) &&
969 ReadParam(aReader, &aResult->mRects);
973 template <>
974 struct ParamTraits<mozilla::ContentCache> {
975 using paramType = mozilla::ContentCache;
977 static void Write(MessageWriter* aWriter, const paramType& aParam) {
978 WriteParam(aWriter, aParam.mCompositionStart);
979 WriteParam(aWriter, aParam.mText);
980 WriteParam(aWriter, aParam.mSelection);
981 WriteParam(aWriter, aParam.mFirstCharRect);
982 WriteParam(aWriter, aParam.mCaret);
983 WriteParam(aWriter, aParam.mTextRectArray);
984 WriteParam(aWriter, aParam.mLastCommitStringTextRectArray);
985 WriteParam(aWriter, aParam.mEditorRect);
988 static bool Read(MessageReader* aReader, paramType* aResult) {
989 return ReadParam(aReader, &aResult->mCompositionStart) &&
990 ReadParam(aReader, &aResult->mText) &&
991 ReadParam(aReader, &aResult->mSelection) &&
992 ReadParam(aReader, &aResult->mFirstCharRect) &&
993 ReadParam(aReader, &aResult->mCaret) &&
994 ReadParam(aReader, &aResult->mTextRectArray) &&
995 ReadParam(aReader, &aResult->mLastCommitStringTextRectArray) &&
996 ReadParam(aReader, &aResult->mEditorRect);
1000 template <>
1001 struct ParamTraits<mozilla::widget::CandidateWindowPosition> {
1002 using paramType = mozilla::widget::CandidateWindowPosition;
1004 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1005 WriteParam(aWriter, aParam.mPoint);
1006 WriteParam(aWriter, aParam.mRect);
1007 WriteParam(aWriter, aParam.mExcludeRect);
1010 static bool Read(MessageReader* aReader, paramType* aResult) {
1011 return ReadParam(aReader, &aResult->mPoint) &&
1012 ReadParam(aReader, &aResult->mRect) &&
1013 ReadParam(aReader, &aResult->mExcludeRect);
1017 // InputData.h
1019 template <>
1020 struct ParamTraits<mozilla::InputType>
1021 : public ContiguousEnumSerializerInclusive<
1022 mozilla::InputType, mozilla::InputType::MULTITOUCH_INPUT,
1023 mozilla::kHighestInputType> {};
1025 template <>
1026 struct ParamTraits<mozilla::InputData> {
1027 using paramType = mozilla::InputData;
1029 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1030 WriteParam(aWriter, aParam.mInputType);
1031 WriteParam(aWriter, aParam.mTimeStamp);
1032 WriteParam(aWriter, aParam.modifiers);
1033 WriteParam(aWriter, aParam.mFocusSequenceNumber);
1034 WriteParam(aWriter, aParam.mLayersId);
1037 static bool Read(MessageReader* aReader, paramType* aResult) {
1038 return ReadParam(aReader, &aResult->mInputType) &&
1039 ReadParam(aReader, &aResult->mTimeStamp) &&
1040 ReadParam(aReader, &aResult->modifiers) &&
1041 ReadParam(aReader, &aResult->mFocusSequenceNumber) &&
1042 ReadParam(aReader, &aResult->mLayersId);
1046 template <>
1047 struct ParamTraits<mozilla::SingleTouchData::HistoricalTouchData> {
1048 using paramType = mozilla::SingleTouchData::HistoricalTouchData;
1050 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1051 WriteParam(aWriter, aParam.mTimeStamp);
1052 WriteParam(aWriter, aParam.mScreenPoint);
1053 WriteParam(aWriter, aParam.mLocalScreenPoint);
1054 WriteParam(aWriter, aParam.mRadius);
1055 WriteParam(aWriter, aParam.mRotationAngle);
1056 WriteParam(aWriter, aParam.mForce);
1059 static bool Read(MessageReader* aReader, paramType* aResult) {
1060 return (ReadParam(aReader, &aResult->mTimeStamp) &&
1061 ReadParam(aReader, &aResult->mScreenPoint) &&
1062 ReadParam(aReader, &aResult->mLocalScreenPoint) &&
1063 ReadParam(aReader, &aResult->mRadius) &&
1064 ReadParam(aReader, &aResult->mRotationAngle) &&
1065 ReadParam(aReader, &aResult->mForce));
1069 template <>
1070 struct ParamTraits<mozilla::SingleTouchData> {
1071 using paramType = mozilla::SingleTouchData;
1073 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1074 WriteParam(aWriter, aParam.mHistoricalData);
1075 WriteParam(aWriter, aParam.mIdentifier);
1076 WriteParam(aWriter, aParam.mScreenPoint);
1077 WriteParam(aWriter, aParam.mLocalScreenPoint);
1078 WriteParam(aWriter, aParam.mRadius);
1079 WriteParam(aWriter, aParam.mRotationAngle);
1080 WriteParam(aWriter, aParam.mForce);
1081 WriteParam(aWriter, aParam.mTiltX);
1082 WriteParam(aWriter, aParam.mTiltY);
1083 WriteParam(aWriter, aParam.mTwist);
1086 static bool Read(MessageReader* aReader, paramType* aResult) {
1087 return (ReadParam(aReader, &aResult->mHistoricalData) &&
1088 ReadParam(aReader, &aResult->mIdentifier) &&
1089 ReadParam(aReader, &aResult->mScreenPoint) &&
1090 ReadParam(aReader, &aResult->mLocalScreenPoint) &&
1091 ReadParam(aReader, &aResult->mRadius) &&
1092 ReadParam(aReader, &aResult->mRotationAngle) &&
1093 ReadParam(aReader, &aResult->mForce) &&
1094 ReadParam(aReader, &aResult->mTiltX) &&
1095 ReadParam(aReader, &aResult->mTiltY) &&
1096 ReadParam(aReader, &aResult->mTwist));
1100 template <>
1101 struct ParamTraits<mozilla::MultiTouchInput::MultiTouchType>
1102 : public ContiguousEnumSerializerInclusive<
1103 mozilla::MultiTouchInput::MultiTouchType,
1104 mozilla::MultiTouchInput::MultiTouchType::MULTITOUCH_START,
1105 mozilla::MultiTouchInput::sHighestMultiTouchType> {};
1107 template <>
1108 struct ParamTraits<mozilla::MultiTouchInput> {
1109 using paramType = mozilla::MultiTouchInput;
1111 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1112 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1113 WriteParam(aWriter, aParam.mType);
1114 WriteParam(aWriter, aParam.mTouches);
1115 WriteParam(aWriter, aParam.mHandledByAPZ);
1116 WriteParam(aWriter, aParam.mScreenOffset);
1117 WriteParam(aWriter, aParam.mButton);
1118 WriteParam(aWriter, aParam.mButtons);
1121 static bool Read(MessageReader* aReader, paramType* aResult) {
1122 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1123 ReadParam(aReader, &aResult->mType) &&
1124 ReadParam(aReader, &aResult->mTouches) &&
1125 ReadParam(aReader, &aResult->mHandledByAPZ) &&
1126 ReadParam(aReader, &aResult->mScreenOffset) &&
1127 ReadParam(aReader, &aResult->mButton) &&
1128 ReadParam(aReader, &aResult->mButtons);
1132 template <>
1133 struct ParamTraits<mozilla::MouseInput::MouseType>
1134 : public ContiguousEnumSerializerInclusive<
1135 mozilla::MouseInput::MouseType,
1136 mozilla::MouseInput::MouseType::MOUSE_NONE,
1137 mozilla::MouseInput::sHighestMouseType> {};
1139 template <>
1140 struct ParamTraits<mozilla::MouseInput::ButtonType>
1141 : public ContiguousEnumSerializerInclusive<
1142 mozilla::MouseInput::ButtonType,
1143 mozilla::MouseInput::ButtonType::PRIMARY_BUTTON,
1144 mozilla::MouseInput::sHighestButtonType> {};
1146 template <>
1147 struct ParamTraits<mozilla::MouseInput> {
1148 using paramType = mozilla::MouseInput;
1150 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1151 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1152 WriteParam(aWriter, aParam.mButtonType);
1153 WriteParam(aWriter, aParam.mType);
1154 WriteParam(aWriter, aParam.mInputSource);
1155 WriteParam(aWriter, aParam.mButtons);
1156 WriteParam(aWriter, aParam.mOrigin);
1157 WriteParam(aWriter, aParam.mLocalOrigin);
1158 WriteParam(aWriter, aParam.mHandledByAPZ);
1159 WriteParam(aWriter, aParam.mPreventClickEvent);
1162 static bool Read(MessageReader* aReader, paramType* aResult) {
1163 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1164 ReadParam(aReader, &aResult->mButtonType) &&
1165 ReadParam(aReader, &aResult->mType) &&
1166 ReadParam(aReader, &aResult->mInputSource) &&
1167 ReadParam(aReader, &aResult->mButtons) &&
1168 ReadParam(aReader, &aResult->mOrigin) &&
1169 ReadParam(aReader, &aResult->mLocalOrigin) &&
1170 ReadParam(aReader, &aResult->mHandledByAPZ) &&
1171 ReadParam(aReader, &aResult->mPreventClickEvent);
1175 template <>
1176 struct ParamTraits<mozilla::PanGestureInput::PanGestureType>
1177 : public ContiguousEnumSerializerInclusive<
1178 mozilla::PanGestureInput::PanGestureType,
1179 mozilla::PanGestureInput::PanGestureType::PANGESTURE_MAYSTART,
1180 mozilla::PanGestureInput::sHighestPanGestureType> {};
1182 template <>
1183 struct ParamTraits<mozilla::PanGestureInput::PanDeltaType>
1184 : public ContiguousEnumSerializerInclusive<
1185 mozilla::PanGestureInput::PanDeltaType,
1186 mozilla::PanGestureInput::PanDeltaType::PANDELTA_PAGE,
1187 mozilla::PanGestureInput::sHighestPanDeltaType> {};
1189 template <>
1190 struct ParamTraits<mozilla::PanGestureInput>
1191 : BitfieldHelper<mozilla::PanGestureInput> {
1192 using paramType = mozilla::PanGestureInput;
1194 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1195 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1196 WriteParam(aWriter, aParam.mType);
1197 WriteParam(aWriter, aParam.mPanStartPoint);
1198 WriteParam(aWriter, aParam.mPanDisplacement);
1199 WriteParam(aWriter, aParam.mLocalPanStartPoint);
1200 WriteParam(aWriter, aParam.mLocalPanDisplacement);
1201 WriteParam(aWriter, aParam.mLineOrPageDeltaX);
1202 WriteParam(aWriter, aParam.mLineOrPageDeltaY);
1203 WriteParam(aWriter, aParam.mUserDeltaMultiplierX);
1204 WriteParam(aWriter, aParam.mUserDeltaMultiplierY);
1205 WriteParam(aWriter, aParam.mDeltaType);
1206 WriteParam(aWriter, aParam.mHandledByAPZ);
1207 WriteParam(aWriter, aParam.mMayTriggerSwipe);
1208 WriteParam(aWriter, aParam.mOverscrollBehaviorAllowsSwipe);
1209 WriteParam(aWriter, aParam.mSimulateMomentum);
1210 WriteParam(aWriter, aParam.mIsNoLineOrPageDelta);
1213 static bool Read(MessageReader* aReader, paramType* aResult) {
1214 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1215 ReadParam(aReader, &aResult->mType) &&
1216 ReadParam(aReader, &aResult->mPanStartPoint) &&
1217 ReadParam(aReader, &aResult->mPanDisplacement) &&
1218 ReadParam(aReader, &aResult->mLocalPanStartPoint) &&
1219 ReadParam(aReader, &aResult->mLocalPanDisplacement) &&
1220 ReadParam(aReader, &aResult->mLineOrPageDeltaX) &&
1221 ReadParam(aReader, &aResult->mLineOrPageDeltaY) &&
1222 ReadParam(aReader, &aResult->mUserDeltaMultiplierX) &&
1223 ReadParam(aReader, &aResult->mUserDeltaMultiplierY) &&
1224 ReadParam(aReader, &aResult->mDeltaType) &&
1225 ReadBoolForBitfield(aReader, aResult, &paramType::SetHandledByAPZ) &&
1226 ReadBoolForBitfield(aReader, aResult,
1227 &paramType::SetMayTriggerSwipe) &&
1228 ReadBoolForBitfield(aReader, aResult,
1229 &paramType::SetOverscrollBehaviorAllowsSwipe) &&
1230 ReadBoolForBitfield(aReader, aResult,
1231 &paramType::SetSimulateMomentum) &&
1232 ReadBoolForBitfield(aReader, aResult,
1233 &paramType::SetIsNoLineOrPageDelta);
1237 template <>
1238 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureType>
1239 : public ContiguousEnumSerializerInclusive<
1240 mozilla::PinchGestureInput::PinchGestureType,
1241 mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START,
1242 mozilla::PinchGestureInput::sHighestPinchGestureType> {};
1244 template <>
1245 struct ParamTraits<mozilla::PinchGestureInput::PinchGestureSource>
1246 : public ContiguousEnumSerializerInclusive<
1247 mozilla::PinchGestureInput::PinchGestureSource,
1248 // Set the min to TOUCH, to ensure UNKNOWN is never sent over IPC
1249 mozilla::PinchGestureInput::PinchGestureSource::TOUCH,
1250 mozilla::PinchGestureInput::sHighestPinchGestureSource> {};
1252 template <>
1253 struct ParamTraits<mozilla::PinchGestureInput> {
1254 using paramType = mozilla::PinchGestureInput;
1256 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1257 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1258 WriteParam(aWriter, aParam.mType);
1259 WriteParam(aWriter, aParam.mSource);
1260 WriteParam(aWriter, aParam.mScreenOffset);
1261 WriteParam(aWriter, aParam.mFocusPoint);
1262 WriteParam(aWriter, aParam.mLocalFocusPoint);
1263 WriteParam(aWriter, aParam.mCurrentSpan);
1264 WriteParam(aWriter, aParam.mPreviousSpan);
1265 WriteParam(aWriter, aParam.mLineOrPageDeltaY);
1266 WriteParam(aWriter, aParam.mHandledByAPZ);
1269 static bool Read(MessageReader* aReader, paramType* aResult) {
1270 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1271 ReadParam(aReader, &aResult->mType) &&
1272 ReadParam(aReader, &aResult->mSource) &&
1273 ReadParam(aReader, &aResult->mScreenOffset) &&
1274 ReadParam(aReader, &aResult->mFocusPoint) &&
1275 ReadParam(aReader, &aResult->mLocalFocusPoint) &&
1276 ReadParam(aReader, &aResult->mCurrentSpan) &&
1277 ReadParam(aReader, &aResult->mPreviousSpan) &&
1278 ReadParam(aReader, &aResult->mLineOrPageDeltaY) &&
1279 ReadParam(aReader, &aResult->mHandledByAPZ);
1283 template <>
1284 struct ParamTraits<mozilla::TapGestureInput::TapGestureType>
1285 : public ContiguousEnumSerializerInclusive<
1286 mozilla::TapGestureInput::TapGestureType,
1287 mozilla::TapGestureInput::TapGestureType::TAPGESTURE_LONG,
1288 mozilla::TapGestureInput::sHighestTapGestureType> {};
1290 template <>
1291 struct ParamTraits<mozilla::TapGestureInput> {
1292 using paramType = mozilla::TapGestureInput;
1294 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1295 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1296 WriteParam(aWriter, aParam.mType);
1297 WriteParam(aWriter, aParam.mPoint);
1298 WriteParam(aWriter, aParam.mLocalPoint);
1301 static bool Read(MessageReader* aReader, paramType* aResult) {
1302 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1303 ReadParam(aReader, &aResult->mType) &&
1304 ReadParam(aReader, &aResult->mPoint) &&
1305 ReadParam(aReader, &aResult->mLocalPoint);
1309 template <>
1310 struct ParamTraits<mozilla::ScrollWheelInput::ScrollDeltaType>
1311 : public ContiguousEnumSerializerInclusive<
1312 mozilla::ScrollWheelInput::ScrollDeltaType,
1313 mozilla::ScrollWheelInput::ScrollDeltaType::SCROLLDELTA_LINE,
1314 mozilla::ScrollWheelInput::sHighestScrollDeltaType> {};
1316 template <>
1317 struct ParamTraits<mozilla::ScrollWheelInput::ScrollMode>
1318 : public ContiguousEnumSerializerInclusive<
1319 mozilla::ScrollWheelInput::ScrollMode,
1320 mozilla::ScrollWheelInput::ScrollMode::SCROLLMODE_INSTANT,
1321 mozilla::ScrollWheelInput::sHighestScrollMode> {};
1323 template <>
1324 struct ParamTraits<mozilla::WheelDeltaAdjustmentStrategy>
1325 : public ContiguousEnumSerializer<
1326 mozilla::WheelDeltaAdjustmentStrategy,
1327 mozilla::WheelDeltaAdjustmentStrategy(0),
1328 mozilla::WheelDeltaAdjustmentStrategy::eSentinel> {};
1330 template <>
1331 struct ParamTraits<mozilla::layers::APZWheelAction>
1332 : public ContiguousEnumSerializerInclusive<
1333 mozilla::layers::APZWheelAction,
1334 mozilla::layers::APZWheelAction::Scroll,
1335 mozilla::layers::kHighestAPZWheelAction> {};
1337 template <>
1338 struct ParamTraits<mozilla::ScrollWheelInput> {
1339 using paramType = mozilla::ScrollWheelInput;
1341 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1342 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1343 WriteParam(aWriter, aParam.mDeltaType);
1344 WriteParam(aWriter, aParam.mScrollMode);
1345 WriteParam(aWriter, aParam.mOrigin);
1346 WriteParam(aWriter, aParam.mHandledByAPZ);
1347 WriteParam(aWriter, aParam.mDeltaX);
1348 WriteParam(aWriter, aParam.mDeltaY);
1349 WriteParam(aWriter, aParam.mWheelTicksX);
1350 WriteParam(aWriter, aParam.mWheelTicksY);
1351 WriteParam(aWriter, aParam.mLocalOrigin);
1352 WriteParam(aWriter, aParam.mLineOrPageDeltaX);
1353 WriteParam(aWriter, aParam.mLineOrPageDeltaY);
1354 WriteParam(aWriter, aParam.mScrollSeriesNumber);
1355 WriteParam(aWriter, aParam.mUserDeltaMultiplierX);
1356 WriteParam(aWriter, aParam.mUserDeltaMultiplierY);
1357 WriteParam(aWriter, aParam.mMayHaveMomentum);
1358 WriteParam(aWriter, aParam.mIsMomentum);
1359 WriteParam(aWriter, aParam.mAllowToOverrideSystemScrollSpeed);
1360 WriteParam(aWriter, aParam.mWheelDeltaAdjustmentStrategy);
1361 WriteParam(aWriter, aParam.mAPZAction);
1364 static bool Read(MessageReader* aReader, paramType* aResult) {
1365 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1366 ReadParam(aReader, &aResult->mDeltaType) &&
1367 ReadParam(aReader, &aResult->mScrollMode) &&
1368 ReadParam(aReader, &aResult->mOrigin) &&
1369 ReadParam(aReader, &aResult->mHandledByAPZ) &&
1370 ReadParam(aReader, &aResult->mDeltaX) &&
1371 ReadParam(aReader, &aResult->mDeltaY) &&
1372 ReadParam(aReader, &aResult->mWheelTicksX) &&
1373 ReadParam(aReader, &aResult->mWheelTicksY) &&
1374 ReadParam(aReader, &aResult->mLocalOrigin) &&
1375 ReadParam(aReader, &aResult->mLineOrPageDeltaX) &&
1376 ReadParam(aReader, &aResult->mLineOrPageDeltaY) &&
1377 ReadParam(aReader, &aResult->mScrollSeriesNumber) &&
1378 ReadParam(aReader, &aResult->mUserDeltaMultiplierX) &&
1379 ReadParam(aReader, &aResult->mUserDeltaMultiplierY) &&
1380 ReadParam(aReader, &aResult->mMayHaveMomentum) &&
1381 ReadParam(aReader, &aResult->mIsMomentum) &&
1382 ReadParam(aReader, &aResult->mAllowToOverrideSystemScrollSpeed) &&
1383 ReadParam(aReader, &aResult->mWheelDeltaAdjustmentStrategy) &&
1384 ReadParam(aReader, &aResult->mAPZAction);
1388 template <>
1389 struct ParamTraits<mozilla::KeyboardInput::KeyboardEventType>
1390 : public ContiguousEnumSerializer<
1391 mozilla::KeyboardInput::KeyboardEventType,
1392 mozilla::KeyboardInput::KeyboardEventType::KEY_DOWN,
1393 mozilla::KeyboardInput::KeyboardEventType::KEY_SENTINEL> {};
1395 template <>
1396 struct ParamTraits<mozilla::KeyboardInput> {
1397 using paramType = mozilla::KeyboardInput;
1399 static void Write(MessageWriter* aWriter, const paramType& aParam) {
1400 WriteParam(aWriter, static_cast<const mozilla::InputData&>(aParam));
1401 WriteParam(aWriter, aParam.mType);
1402 WriteParam(aWriter, aParam.mKeyCode);
1403 WriteParam(aWriter, aParam.mCharCode);
1404 WriteParam(aWriter, aParam.mShortcutCandidates);
1405 WriteParam(aWriter, aParam.mHandledByAPZ);
1408 static bool Read(MessageReader* aReader, paramType* aResult) {
1409 return ReadParam(aReader, static_cast<mozilla::InputData*>(aResult)) &&
1410 ReadParam(aReader, &aResult->mType) &&
1411 ReadParam(aReader, &aResult->mKeyCode) &&
1412 ReadParam(aReader, &aResult->mCharCode) &&
1413 ReadParam(aReader, &aResult->mShortcutCandidates) &&
1414 ReadParam(aReader, &aResult->mHandledByAPZ);
1418 } // namespace IPC
1420 #endif // nsGUIEventIPC_h__