/* * Copyright (c) 2023, Kenneth Myhra * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::XHR { // https://xhr.spec.whatwg.org/#formdataentryvalue using FormDataEntryValue = Variant, DeprecatedString>; // https://xhr.spec.whatwg.org/#interface-formdata class FormData : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(FormData, Bindings::PlatformObject); public: virtual ~FormData() override; static WebIDL::ExceptionOr> construct_impl(JS::Realm&, Optional> form = {}); static WebIDL::ExceptionOr> construct_impl(JS::Realm&, HashMap> entry_list); WebIDL::ExceptionOr append(DeprecatedString const& name, DeprecatedString const& value); WebIDL::ExceptionOr append(DeprecatedString const& name, JS::NonnullGCPtr const& blob_value, Optional const& filename = {}); void delete_(DeprecatedString const& name); Variant, DeprecatedString, Empty> get(DeprecatedString const& name); Vector get_all(DeprecatedString const& name); bool has(DeprecatedString const& name); WebIDL::ExceptionOr set(DeprecatedString const& name, DeprecatedString const& value); WebIDL::ExceptionOr set(DeprecatedString const& name, JS::NonnullGCPtr const& blob_value, Optional const& filename = {}); private: explicit FormData(JS::Realm&, HashMap> entry_list = {}); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr append_impl(String const& name, Variant, String> const& value, Optional const& filename = {}); WebIDL::ExceptionOr set_impl(String const& name, Variant, String> const& value, Optional const& filename = {}); HashMap> m_entry_list; }; }