LayoutMessageUtils.h (1683B)
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 LAYOUT_GENERIC_LAYOUTMESSAGEUTILS_H_ 8 #define LAYOUT_GENERIC_LAYOUTMESSAGEUTILS_H_ 9 10 #include "ipc/EnumSerializer.h" 11 #include "ipc/IPCMessageUtils.h" 12 #include "mozilla/AspectRatio.h" 13 #include "mozilla/webrender/WebRenderTypes.h" 14 #include "nsIFrame.h" 15 16 namespace IPC { 17 18 template <> 19 struct ParamTraits<mozilla::IntrinsicSize> { 20 using paramType = mozilla::IntrinsicSize; 21 22 static void Write(MessageWriter* aWriter, const paramType& aParam) { 23 WriteParam(aWriter, aParam.width); 24 WriteParam(aWriter, aParam.height); 25 } 26 27 static bool Read(MessageReader* aReader, paramType* aResult) { 28 return ReadParam(aReader, &aResult->width) && 29 ReadParam(aReader, &aResult->height); 30 } 31 }; 32 33 template <> 34 struct ParamTraits<mozilla::AspectRatio> { 35 using paramType = mozilla::AspectRatio; 36 37 static void Write(MessageWriter* aWriter, const paramType& aParam) { 38 WriteParam(aWriter, aParam.mRatio); 39 } 40 41 static bool Read(MessageReader* aReader, paramType* aResult) { 42 return ReadParam(aReader, &aResult->mRatio); 43 } 44 }; 45 46 template <> 47 struct ParamTraits<mozilla::StyleImageRendering> 48 : public ContiguousEnumSerializerInclusive< 49 mozilla::StyleImageRendering, mozilla::StyleImageRendering::Auto, 50 mozilla::StyleImageRendering::Optimizequality> {}; 51 52 } // namespace IPC 53 54 #endif // LAYOUT_GENERIC_LAYOUTMESSAGEUTILS_H_