From fc12402b49c52116001cb679de19ebfe6d3815c5 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Fri, 23 Feb 2024 17:25:37 +0100 Subject: [PATCH] LibWeb: Add abstract class Serializable This adds the abstract class Serializable which platform objects defined as Serializable objects can implement to support their appropriate serialization and deserialization steps. --- .../Libraries/LibWeb/Bindings/Serializable.h | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Userland/Libraries/LibWeb/Bindings/Serializable.h diff --git a/Userland/Libraries/LibWeb/Bindings/Serializable.h b/Userland/Libraries/LibWeb/Bindings/Serializable.h new file mode 100644 index 0000000000..0cc8570987 --- /dev/null +++ b/Userland/Libraries/LibWeb/Bindings/Serializable.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024, Kenneth Myhra + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::Bindings { + +// https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects +class Serializable { +public: + virtual ~Serializable() = default; + + virtual StringView interface_name() const = 0; + + // https://html.spec.whatwg.org/multipage/structured-data.html#serialization-steps + virtual WebIDL::ExceptionOr serialization_steps(HTML::SerializationRecord&, bool for_storage) = 0; + // https://html.spec.whatwg.org/multipage/structured-data.html#deserialization-steps + virtual WebIDL::ExceptionOr deserialization_steps(ReadonlySpan const&, size_t& position) = 0; +}; + +}