1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef TABMESSAGE_UTILS_H
8 #define TABMESSAGE_UTILS_H
10 #include "ipc/EnumSerializer.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/dom/Event.h"
13 #include "nsIRemoteTab.h"
14 #include "nsPIDOMWindow.h"
16 #include "mozilla/dom/EffectsInfo.h"
17 #include "mozilla/layers/LayersMessageUtils.h"
18 #include "TabMessageTypes.h"
19 #include "X11UndefineNone.h"
24 struct ParamTraits
<nsSizeMode
>
25 : public ContiguousEnumSerializer
<nsSizeMode
, nsSizeMode_Normal
,
26 nsSizeMode_Invalid
> {};
29 struct ParamTraits
<nsIRemoteTab::NavigationType
>
30 : public ContiguousEnumSerializerInclusive
<
31 nsIRemoteTab::NavigationType
,
32 nsIRemoteTab::NavigationType::NAVIGATE_BACK
,
33 nsIRemoteTab::NavigationType::NAVIGATE_URL
> {};
36 struct ParamTraits
<mozilla::dom::EffectsInfo
> {
37 typedef mozilla::dom::EffectsInfo paramType
;
39 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
40 WriteParam(aWriter
, aParam
.mVisibleRect
);
41 WriteParam(aWriter
, aParam
.mRasterScale
);
42 WriteParam(aWriter
, aParam
.mTransformToAncestorScale
);
45 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
46 return ReadParam(aReader
, &aResult
->mVisibleRect
) &&
47 ReadParam(aReader
, &aResult
->mRasterScale
) &&
48 ReadParam(aReader
, &aResult
->mTransformToAncestorScale
);
53 struct ParamTraits
<mozilla::WhenToScroll
>
54 : public ContiguousEnumSerializerInclusive
<
55 mozilla::WhenToScroll
, mozilla::WhenToScroll::Always
,
56 mozilla::WhenToScroll::IfNotFullyVisible
> {};
59 struct ParamTraits
<mozilla::ScrollFlags
>
60 : public BitFlagsEnumSerializer
<mozilla::ScrollFlags
,
61 mozilla::ScrollFlags::ALL_BITS
> {};
64 struct ParamTraits
<mozilla::WhereToScroll
> {
65 using paramType
= mozilla::WhereToScroll
;
67 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
68 WriteParam(aWriter
, aParam
.mPercentage
);
71 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
72 return ReadParam(aReader
, &aResult
->mPercentage
);
77 struct ParamTraits
<mozilla::ScrollAxis
> {
78 typedef mozilla::ScrollAxis paramType
;
80 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
81 WriteParam(aWriter
, aParam
.mWhereToScroll
);
82 WriteParam(aWriter
, aParam
.mWhenToScroll
);
83 WriteParam(aWriter
, aParam
.mOnlyIfPerceivedScrollableDirection
);
86 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
87 if (!ReadParam(aReader
, &aResult
->mWhereToScroll
)) {
90 if (!ReadParam(aReader
, &aResult
->mWhenToScroll
)) {
94 // We can't set mOnlyIfPerceivedScrollableDirection directly since it's
97 if (!ReadParam(aReader
, &value
)) {
100 aResult
->mOnlyIfPerceivedScrollableDirection
= value
;
107 struct ParamTraits
<mozilla::dom::EmbedderElementEventType
>
108 : public ContiguousEnumSerializer
<
109 mozilla::dom::EmbedderElementEventType
,
110 mozilla::dom::EmbedderElementEventType::NoEvent
,
111 mozilla::dom::EmbedderElementEventType::EndGuard_
> {};
115 #endif // TABMESSAGE_UTILS_H