LibWeb: Add an empty DataTransferItem IDL implementation

This commit is contained in:
Timothy Flynn 2024-08-15 12:18:56 -04:00 committed by Andreas Kling
parent b6c99c27af
commit 9e3c6921ab
Notes: github-actions[bot] 2024-08-19 11:31:06 +00:00
7 changed files with 79 additions and 0 deletions

View file

@ -74,6 +74,7 @@ DOMStringList
DOMStringMap
DOMTokenList
DataTransfer
DataTransferItem
DataView
Date
DisposableStack

View file

@ -275,6 +275,7 @@ set(SOURCES
HTML/CustomElements/CustomElementReactionNames.cpp
HTML/CustomElements/CustomElementRegistry.cpp
HTML/DataTransfer.cpp
HTML/DataTransferItem.cpp
HTML/Dates.cpp
HTML/DecodedImageData.cpp
HTML/DedicatedWorkerGlobalScope.cpp

View file

@ -353,6 +353,7 @@ class CloseWatcher;
class CloseWatcherManager;
class CustomElementDefinition;
class CustomElementRegistry;
class DataTransferItem;
class DecodedImageData;
class DocumentState;
class DOMParser;

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/DataTransferItemPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/DataTransferItem.h>
namespace Web::HTML {
JS_DEFINE_ALLOCATOR(DataTransferItem);
JS::NonnullGCPtr<DataTransferItem> DataTransferItem::construct_impl(JS::Realm& realm)
{
return realm.heap().allocate<DataTransferItem>(realm, realm);
}
DataTransferItem::DataTransferItem(JS::Realm& realm)
: PlatformObject(realm)
{
}
DataTransferItem::~DataTransferItem() = default;
void DataTransferItem::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(DataTransferItem);
}
}

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dnd.html#the-datatransferitem-interface
class DataTransferItem : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DataTransferItem, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DataTransferItem);
public:
static JS::NonnullGCPtr<DataTransferItem> construct_impl(JS::Realm&);
virtual ~DataTransferItem() override;
private:
DataTransferItem(JS::Realm&);
virtual void initialize(JS::Realm&) override;
};
}

View file

@ -0,0 +1,12 @@
#import <FileAPI/File.idl>
callback FunctionStringCallback = undefined (DOMString data);
// https://html.spec.whatwg.org/multipage/dnd.html#datatransferitem
[Exposed=Window]
interface DataTransferItem {
[FIXME] readonly attribute DOMString kind;
[FIXME] readonly attribute DOMString type;
[FIXME] undefined getAsString(FunctionStringCallback? _callback);
[FIXME] File? getAsFile();
};

View file

@ -102,6 +102,7 @@ libweb_js_bindings(HTML/CloseEvent)
libweb_js_bindings(HTML/CloseWatcher)
libweb_js_bindings(HTML/CustomElements/CustomElementRegistry)
libweb_js_bindings(HTML/DataTransfer)
libweb_js_bindings(HTML/DataTransferItem)
libweb_js_bindings(HTML/DedicatedWorkerGlobalScope GLOBAL)
libweb_js_bindings(HTML/DOMParser)
libweb_js_bindings(HTML/DOMStringList)