mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 23:30:20 +00:00
LibWeb: Implement separate DataTransfer factories for IDL / internal use
The IDL constructor has to take separate steps than a DataTransfer that is internally constructed. Notably, an IDL-created object has its own drag data store, and that store is placed in a read-write mode.
This commit is contained in:
parent
f7c4165dde
commit
5c9287aa99
Notes:
github-actions[bot]
2024-08-22 12:22:55 +00:00
Author: https://github.com/trflynn89
Commit: 5c9287aa99
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1158
Reviewed-by: https://github.com/shannonbooth
5 changed files with 34 additions and 14 deletions
|
@ -27,14 +27,31 @@ ENUMERATE_DATA_TRANSFER_EFFECTS
|
|||
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DataTransfer> DataTransfer::construct_impl(JS::Realm& realm)
|
||||
JS::NonnullGCPtr<DataTransfer> DataTransfer::create(JS::Realm& realm, NonnullRefPtr<DragDataStore> drag_data_store)
|
||||
{
|
||||
return realm.heap().allocate<DataTransfer>(realm, realm);
|
||||
return realm.heap().allocate<DataTransfer>(realm, realm, move(drag_data_store));
|
||||
}
|
||||
|
||||
DataTransfer::DataTransfer(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
// https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer
|
||||
JS::NonnullGCPtr<DataTransfer> DataTransfer::construct_impl(JS::Realm& realm)
|
||||
{
|
||||
// 1. Set the drag data store's item list to be an empty list.
|
||||
auto drag_data_store = DragDataStore::create();
|
||||
|
||||
// 2. Set the drag data store's mode to read/write mode.
|
||||
drag_data_store->set_mode(DragDataStore::Mode::ReadWrite);
|
||||
|
||||
// 3. Set the dropEffect and effectAllowed to "none".
|
||||
// NOTE: This is done by the default-initializers.
|
||||
|
||||
return realm.heap().allocate<DataTransfer>(realm, realm, move(drag_data_store));
|
||||
}
|
||||
|
||||
DataTransfer::DataTransfer(JS::Realm& realm, NonnullRefPtr<DragDataStore> drag_data_store)
|
||||
: PlatformObject(realm)
|
||||
, m_associated_drag_data_store(move(drag_data_store))
|
||||
{
|
||||
update_data_transfer_types_list();
|
||||
}
|
||||
|
||||
DataTransfer::~DataTransfer() = default;
|
||||
|
@ -195,12 +212,6 @@ JS::NonnullGCPtr<FileAPI::FileList> DataTransfer::files() const
|
|||
return files;
|
||||
}
|
||||
|
||||
void DataTransfer::associate_with_drag_data_store(NonnullRefPtr<DragDataStore> drag_data_store)
|
||||
{
|
||||
m_associated_drag_data_store = move(drag_data_store);
|
||||
update_data_transfer_types_list();
|
||||
}
|
||||
|
||||
void DataTransfer::disassociate_with_drag_data_store()
|
||||
{
|
||||
m_associated_drag_data_store.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue