1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:37:34 +00:00

LibWeb: Add a Transferable interface to model the transferable property

This property is only shared by MessagePort and a few Image related APIs
but is important for the Structured{De}SerializeWithTransfer AOs.
This commit is contained in:
Andrew Kaster 2023-12-07 15:52:08 -07:00 committed by Andreas Kling
parent 512624f31a
commit e21d1078a0
4 changed files with 107 additions and 5 deletions

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibIPC/Forward.h>
#include <LibWeb/HTML/StructuredSerialize.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Bindings {
// https://html.spec.whatwg.org/multipage/structured-data.html#transferable-objects
class Transferable {
public:
virtual ~Transferable() = default;
// NOTE: It is an error to call Base::transfer_steps in your impl
virtual WebIDL::ExceptionOr<void> transfer_steps(HTML::TransferDataHolder&) = 0;
// NOTE: It is an error to call Base::transfer_receiving_steps in your impl
virtual WebIDL::ExceptionOr<void> transfer_receiving_steps(HTML::TransferDataHolder const&) = 0;
virtual HTML::TransferType primary_interface() const = 0;
bool is_detached() const { return m_detached; }
void set_detached(bool b) { m_detached = b; }
private:
// https://html.spec.whatwg.org/multipage/structured-data.html#detached
bool m_detached = false;
};
}