mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 02:33:03 +00:00
LibWeb: Add a factory method to create a DataTransferItem
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".
This commit is contained in:
parent
5c9287aa99
commit
c82fec0a8c
Notes:
github-actions[bot]
2024-08-22 12:22:50 +00:00
Author: https://github.com/trflynn89
Commit: c82fec0a8c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1158
Reviewed-by: https://github.com/shannonbooth
2 changed files with 23 additions and 2 deletions
|
@ -7,14 +7,22 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/DataTransferItemPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/DataTransfer.h>
|
||||
#include <LibWeb/HTML/DataTransferItem.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(DataTransferItem);
|
||||
|
||||
DataTransferItem::DataTransferItem(JS::Realm& realm)
|
||||
JS::NonnullGCPtr<DataTransferItem> DataTransferItem::create(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer, size_t item_index)
|
||||
{
|
||||
return realm.heap().allocate<DataTransferItem>(realm, realm, data_transfer, item_index);
|
||||
}
|
||||
|
||||
DataTransferItem::DataTransferItem(JS::Realm& realm, JS::NonnullGCPtr<DataTransfer> data_transfer, size_t item_index)
|
||||
: PlatformObject(realm)
|
||||
, m_data_transfer(data_transfer)
|
||||
, m_item_index(item_index)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,4 +34,10 @@ void DataTransferItem::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(DataTransferItem);
|
||||
}
|
||||
|
||||
void DataTransferItem::visit_edges(JS::Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_data_transfer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue