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