no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / ipc / TabMessageUtils.h
blob794d3dffa25f409e7c1caee6eea9a84e45b4f620
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"
15 #include "nsCOMPtr.h"
16 #include "mozilla/dom/EffectsInfo.h"
17 #include "mozilla/layers/LayersMessageUtils.h"
18 #include "TabMessageTypes.h"
19 #include "X11UndefineNone.h"
21 namespace IPC {
23 template <>
24 struct ParamTraits<nsSizeMode>
25 : public ContiguousEnumSerializer<nsSizeMode, nsSizeMode_Normal,
26 nsSizeMode_Invalid> {};
28 template <>
29 struct ParamTraits<nsIRemoteTab::NavigationType>
30 : public ContiguousEnumSerializerInclusive<
31 nsIRemoteTab::NavigationType,
32 nsIRemoteTab::NavigationType::NAVIGATE_BACK,
33 nsIRemoteTab::NavigationType::NAVIGATE_URL> {};
35 template <>
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);
52 template <>
53 struct ParamTraits<mozilla::WhenToScroll>
54 : public ContiguousEnumSerializerInclusive<
55 mozilla::WhenToScroll, mozilla::WhenToScroll::Always,
56 mozilla::WhenToScroll::IfNotFullyVisible> {};
58 template <>
59 struct ParamTraits<mozilla::ScrollFlags>
60 : public BitFlagsEnumSerializer<mozilla::ScrollFlags,
61 mozilla::ScrollFlags::ALL_BITS> {};
63 template <>
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);
76 template <>
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)) {
88 return false;
90 if (!ReadParam(aReader, &aResult->mWhenToScroll)) {
91 return false;
94 // We can't set mOnlyIfPerceivedScrollableDirection directly since it's
95 // a bitfield.
96 bool value;
97 if (!ReadParam(aReader, &value)) {
98 return false;
100 aResult->mOnlyIfPerceivedScrollableDirection = value;
102 return true;
106 template <>
107 struct ParamTraits<mozilla::dom::EmbedderElementEventType>
108 : public ContiguousEnumSerializer<
109 mozilla::dom::EmbedderElementEventType,
110 mozilla::dom::EmbedderElementEventType::NoEvent,
111 mozilla::dom::EmbedderElementEventType::EndGuard_> {};
113 } // namespace IPC
115 #endif // TABMESSAGE_UTILS_H