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 mozilla_a11y_IPCTypes_h
8 #define mozilla_a11y_IPCTypes_h
11 # include "mozilla/a11y/AccAttributes.h"
12 # include "mozilla/a11y/AccTypes.h"
13 # include "mozilla/a11y/CacheConstants.h"
14 # include "mozilla/a11y/Role.h"
15 # include "mozilla/a11y/AccGroupInfo.h"
16 # include "mozilla/GfxMessageUtils.h"
17 # include "ipc/EnumSerializer.h"
18 # include "ipc/IPCMessageUtilsSpecializations.h"
23 struct ParamTraits
<mozilla::a11y::role
>
24 : public ContiguousEnumSerializerInclusive
<mozilla::a11y::role
,
25 mozilla::a11y::role::NOTHING
,
26 mozilla::a11y::role::LAST_ROLE
> {
30 struct ParamTraits
<mozilla::a11y::AccType
>
31 : public ContiguousEnumSerializerInclusive
<
32 mozilla::a11y::AccType
, mozilla::a11y::AccType::eNoType
,
33 mozilla::a11y::AccType::eLastAccType
> {};
36 struct ParamTraits
<mozilla::a11y::AccGenericType
>
37 : public BitFlagsEnumSerializer
<
38 mozilla::a11y::AccGenericType
,
39 mozilla::a11y::AccGenericType::eAllGenericTypes
> {};
42 struct ParamTraits
<mozilla::a11y::CacheUpdateType
>
43 : public ContiguousEnumSerializerInclusive
<
44 mozilla::a11y::CacheUpdateType
,
45 mozilla::a11y::CacheUpdateType::Initial
,
46 mozilla::a11y::CacheUpdateType::Update
> {};
49 struct ParamTraits
<mozilla::a11y::FontSize
> {
50 typedef mozilla::a11y::FontSize paramType
;
52 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
53 WriteParam(aWriter
, aParam
.mValue
);
56 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
57 return ReadParam(aReader
, &(aResult
->mValue
));
62 struct ParamTraits
<mozilla::a11y::DeleteEntry
> {
63 typedef mozilla::a11y::DeleteEntry paramType
;
65 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
66 WriteParam(aWriter
, aParam
.mValue
);
69 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
70 return ReadParam(aReader
, &(aResult
->mValue
));
75 struct ParamTraits
<mozilla::a11y::AccGroupInfo
> {
76 typedef mozilla::a11y::AccGroupInfo paramType
;
78 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
79 MOZ_ASSERT_UNREACHABLE("Cannot serialize AccGroupInfo");
82 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
83 MOZ_ASSERT_UNREACHABLE("Cannot de-serialize AccGroupInfo");
89 struct ParamTraits
<mozilla::a11y::Color
> {
90 typedef mozilla::a11y::Color paramType
;
92 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
93 WriteParam(aWriter
, aParam
.mValue
);
96 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
97 return ReadParam(aReader
, &(aResult
->mValue
));
102 struct ParamTraits
<mozilla::a11y::AccAttributes
*> {
103 typedef mozilla::a11y::AccAttributes paramType
;
105 static void Write(MessageWriter
* aWriter
, const paramType
* aParam
) {
107 WriteParam(aWriter
, true);
111 WriteParam(aWriter
, false);
112 uint32_t count
= aParam
->mData
.Count();
113 WriteParam(aWriter
, count
);
114 for (auto iter
= aParam
->mData
.ConstIter(); !iter
.Done(); iter
.Next()) {
115 RefPtr
<nsAtom
> key
= iter
.Key();
116 WriteParam(aWriter
, key
);
117 const paramType::AttrValueType
& data
= iter
.Data();
118 WriteParam(aWriter
, data
);
122 static bool Read(MessageReader
* aReader
, RefPtr
<paramType
>* aResult
) {
124 if (!ReadParam(aReader
, &isNull
)) {
133 *aResult
= mozilla::MakeRefPtr
<mozilla::a11y::AccAttributes
>();
135 if (!ReadParam(aReader
, &count
)) {
138 for (uint32_t i
= 0; i
< count
; ++i
) {
140 if (!ReadParam(aReader
, &key
)) {
143 paramType::AttrValueType
val(0);
144 if (!ReadParam(aReader
, &val
)) {
147 (*aResult
)->mData
.InsertOrUpdate(key
, std::move(val
));
157 typedef uint32_t role
;
159 } // namespace mozilla
160 #endif // ACCESSIBILITY
163 * Since IPDL does not support preprocessing, this header file allows us to
164 * define types used by PDocAccessible differently depending on platform.
167 #if defined(MOZ_WIDGET_COCOA)
168 # if defined(ACCESSIBILITY)
169 # include "mozilla/a11y/PlatformExtTypes.h"
173 struct ParamTraits
<mozilla::a11y::EWhichRange
>
174 : public ContiguousEnumSerializerInclusive
<
175 mozilla::a11y::EWhichRange
, mozilla::a11y::EWhichRange::eLeftWord
,
176 mozilla::a11y::EWhichRange::eStyle
> {};
183 typedef uint32_t EWhichRange
;
185 } // namespace mozilla
186 # endif // defined(ACCESSIBILITY)
187 #endif // defined(MOZ_WIDGET_COCOA)
189 #endif // mozilla_a11y_IPCTypes_h