/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_WidgetMessageUtils_h #define mozilla_WidgetMessageUtils_h #include "ipc/IPCMessageUtils.h" #include "mozilla/LookAndFeel.h" #include "mozilla/widget/ThemeChangeKind.h" #include "nsIWidget.h" namespace IPC { template <> struct ParamTraits { typedef LookAndFeelInt paramType; static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam.id)); WriteParam(aMsg, aParam.value); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { int32_t id, value; if (ReadParam(aMsg, aIter, &id) && ReadParam(aMsg, aIter, &value)) { aResult->id = static_cast(id); aResult->value = value; return true; } return false; } }; template <> struct ParamTraits : public BitFlagsEnumSerializer { }; template <> struct ParamTraits { typedef LookAndFeelFont paramType; static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.haveFont); WriteParam(aMsg, aParam.fontName); WriteParam(aMsg, aParam.pixelHeight); WriteParam(aMsg, aParam.italic); WriteParam(aMsg, aParam.bold); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->haveFont) && ReadParam(aMsg, aIter, &aResult->fontName) && ReadParam(aMsg, aIter, &aResult->pixelHeight) && ReadParam(aMsg, aIter, &aResult->italic) && ReadParam(aMsg, aIter, &aResult->bold); } }; template <> struct ParamTraits { using paramType = LookAndFeelColor; using idType = std::underlying_type::type; static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam.id)); WriteParam(aMsg, aParam.color); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { idType id; nscolor color; if (ReadParam(aMsg, aIter, &id) && ReadParam(aMsg, aIter, &color)) { aResult->id = static_cast(id); aResult->color = color; return true; } return false; } }; template <> struct ParamTraits { typedef LookAndFeelCache paramType; static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.mInts); WriteParam(aMsg, aParam.mFonts); WriteParam(aMsg, aParam.mColors); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mInts) && ReadParam(aMsg, aIter, &aResult->mFonts) && ReadParam(aMsg, aIter, &aResult->mColors); } }; template <> struct ParamTraits : public ContiguousEnumSerializerInclusive {}; template <> struct ParamTraits : public ContiguousEnumSerializer {}; } // namespace IPC #endif // WidgetMessageUtils_h