TabMessageUtils.h (3323B)
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/. */ 6 7 #ifndef TABMESSAGE_UTILS_H 8 #define TABMESSAGE_UTILS_H 9 10 #include "TabMessageTypes.h" 11 #include "X11UndefineNone.h" 12 #include "ipc/EnumSerializer.h" 13 #include "mozilla/dom/EffectsInfo.h" 14 #include "mozilla/dom/Event.h" 15 #include "mozilla/layers/LayersMessageUtils.h" 16 #include "nsCOMPtr.h" 17 #include "nsIRemoteTab.h" 18 #include "nsPIDOMWindow.h" 19 20 namespace IPC { 21 22 template <> 23 struct ParamTraits<nsSizeMode> 24 : public ContiguousEnumSerializer<nsSizeMode, nsSizeMode_Normal, 25 nsSizeMode_Invalid> {}; 26 27 template <> 28 struct ParamTraits<nsIRemoteTab::NavigationType> 29 : public ContiguousEnumSerializerInclusive< 30 nsIRemoteTab::NavigationType, 31 nsIRemoteTab::NavigationType::NAVIGATE_BACK, 32 nsIRemoteTab::NavigationType::NAVIGATE_URL> {}; 33 34 template <> 35 struct ParamTraits<mozilla::dom::EffectsInfo> { 36 typedef mozilla::dom::EffectsInfo paramType; 37 38 static void Write(MessageWriter* aWriter, const paramType& aParam) { 39 WriteParam(aWriter, aParam.mVisibleRect); 40 WriteParam(aWriter, aParam.mRasterScale); 41 WriteParam(aWriter, aParam.mTransformToAncestorScale); 42 } 43 44 static bool Read(MessageReader* aReader, paramType* aResult) { 45 return ReadParam(aReader, &aResult->mVisibleRect) && 46 ReadParam(aReader, &aResult->mRasterScale) && 47 ReadParam(aReader, &aResult->mTransformToAncestorScale); 48 } 49 }; 50 51 template <> 52 struct ParamTraits<mozilla::WhenToScroll> 53 : public ContiguousEnumSerializerInclusive< 54 mozilla::WhenToScroll, mozilla::WhenToScroll::Always, 55 mozilla::WhenToScroll::IfNotFullyVisible> {}; 56 57 template <> 58 struct ParamTraits<mozilla::ScrollFlags> 59 : public BitFlagsEnumSerializer<mozilla::ScrollFlags, 60 mozilla::ScrollFlags::ALL_BITS> {}; 61 62 template <> 63 struct ParamTraits<mozilla::WhereToScroll> { 64 using paramType = mozilla::WhereToScroll; 65 66 static void Write(MessageWriter* aWriter, const paramType& aParam) { 67 WriteParam(aWriter, aParam.mPercentage); 68 } 69 70 static bool Read(MessageReader* aReader, paramType* aResult) { 71 return ReadParam(aReader, &aResult->mPercentage); 72 } 73 }; 74 75 template <> 76 struct ParamTraits<mozilla::ScrollAxis> { 77 typedef mozilla::ScrollAxis paramType; 78 79 static void Write(MessageWriter* aWriter, const paramType& aParam) { 80 WriteParam(aWriter, aParam.mWhereToScroll); 81 WriteParam(aWriter, aParam.mWhenToScroll); 82 } 83 84 static bool Read(MessageReader* aReader, paramType* aResult) { 85 if (!ReadParam(aReader, &aResult->mWhereToScroll)) { 86 return false; 87 } 88 if (!ReadParam(aReader, &aResult->mWhenToScroll)) { 89 return false; 90 } 91 return true; 92 } 93 }; 94 95 template <> 96 struct ParamTraits<mozilla::dom::EmbedderElementEventType> 97 : public ContiguousEnumSerializer< 98 mozilla::dom::EmbedderElementEventType, 99 mozilla::dom::EmbedderElementEventType::NoEvent, 100 mozilla::dom::EmbedderElementEventType::EndGuard_> {}; 101 102 } // namespace IPC 103 104 #endif // TABMESSAGE_UTILS_H