
A DataTransferItem is associated with a DataTransfer, and points to an item in the drag data store. We don't yet support removing items from the store, but when we do, we will clear the index stored here to set the DataTransferItem's mode to "disabled".
35 lines
1,006 B
C++
35 lines
1,006 B
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/HTML/DragDataStore.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> create(JS::Realm&, JS::NonnullGCPtr<DataTransfer>, size_t item_index);
|
|
virtual ~DataTransferItem() override;
|
|
|
|
private:
|
|
DataTransferItem(JS::Realm&, JS::NonnullGCPtr<DataTransfer>, size_t item_index);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
|
|
|
JS::NonnullGCPtr<DataTransfer> m_data_transfer;
|
|
Optional<size_t> m_item_index;
|
|
};
|
|
|
|
}
|