mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 00:38:48 +00:00
This does not implement any of the IDL methods, but GitHub requires the interface exists to upload files via an <input type="file"> element. Their JS handles uploads via this element and via drag-and-drop in one function, and check if the uploaded file is `instanceof DataTransfer` to decide how to handle it.
33 lines
751 B
C++
33 lines
751 B
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/HTML/DataTransfer.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
JS_DEFINE_ALLOCATOR(DataTransfer);
|
|
|
|
JS::NonnullGCPtr<DataTransfer> DataTransfer::construct_impl(JS::Realm& realm)
|
|
{
|
|
return realm.heap().allocate<DataTransfer>(realm, realm);
|
|
}
|
|
|
|
DataTransfer::DataTransfer(JS::Realm& realm)
|
|
: PlatformObject(realm)
|
|
{
|
|
}
|
|
|
|
DataTransfer::~DataTransfer() = default;
|
|
|
|
void DataTransfer::initialize(JS::Realm& realm)
|
|
{
|
|
Base::initialize(realm);
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::DataTransferPrototype>(realm, "DataTransfer"_fly_string));
|
|
}
|
|
|
|
}
|