From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- dom/canvas/WebGLIpdl.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'dom/canvas/WebGLIpdl.h') diff --git a/dom/canvas/WebGLIpdl.h b/dom/canvas/WebGLIpdl.h index 45a5c5ad64..4c81393b70 100644 --- a/dom/canvas/WebGLIpdl.h +++ b/dom/canvas/WebGLIpdl.h @@ -18,6 +18,8 @@ #include "TupleUtils.h" #include "WebGLTypes.h" +#include + namespace mozilla { namespace webgl { @@ -652,6 +654,32 @@ struct ParamTraits> final { } }; +// - + +template +struct ParamTraits> final { + using T = std::optional; + + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, bool{in}); + if (in) { + WriteParam(writer, *in); + } + } + + static bool Read(MessageReader* const reader, T* const out) { + bool isSome; + if (!ReadParam(reader, &isSome)) return false; + + if (!isSome) { + out->reset(); + return true; + } + out->emplace(); + return ReadParam(reader, &**out); + } +}; + } // namespace IPC #endif -- cgit v1.2.3