mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-22 23:55:12 +00:00
LibWeb: Implement DataTransferItemList.prototype.add()
This commit is contained in:
committed by
Andreas Kling
parent
b3bfd02e64
commit
74d9cfbf2a
@@ -220,12 +220,46 @@ JS::NonnullGCPtr<FileAPI::FileList> DataTransfer::files() const
|
||||
return files;
|
||||
}
|
||||
|
||||
Optional<DragDataStore::Mode> DataTransfer::mode() const
|
||||
{
|
||||
if (m_associated_drag_data_store)
|
||||
return m_associated_drag_data_store->mode();
|
||||
return {};
|
||||
}
|
||||
|
||||
void DataTransfer::disassociate_with_drag_data_store()
|
||||
{
|
||||
m_associated_drag_data_store.clear();
|
||||
update_data_transfer_types_list();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DataTransferItem> DataTransfer::add_item(DragDataStoreItem item)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
|
||||
VERIFY(m_associated_drag_data_store);
|
||||
m_associated_drag_data_store->add_item(move(item));
|
||||
|
||||
auto data_transfer_item = DataTransferItem::create(realm, *this, m_associated_drag_data_store->size() - 1);
|
||||
m_item_list.append(data_transfer_item);
|
||||
|
||||
update_data_transfer_types_list();
|
||||
|
||||
return data_transfer_item;
|
||||
}
|
||||
|
||||
bool DataTransfer::contains_item_with_type(DragDataStoreItem::Kind kind, String const& type) const
|
||||
{
|
||||
VERIFY(m_associated_drag_data_store);
|
||||
|
||||
for (auto const& item : m_associated_drag_data_store->item_list()) {
|
||||
if (item.kind == kind && item.type_string.equals_ignoring_ascii_case(type))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#concept-datatransfer-types
|
||||
void DataTransfer::update_data_transfer_types_list()
|
||||
{
|
||||
@@ -259,5 +293,4 @@ void DataTransfer::update_data_transfer_types_list()
|
||||
// 3. Set the DataTransfer object's types array to the result of creating a frozen array from L.
|
||||
m_types = move(types);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user