LibWeb: Make the drag data store reference counted

Ownership of the drag data store is a bit weird. In a normal drag-and-
drop operation, the DragAndDropEventHandler owns the store. When events
are fired for the operation, the DataTransfer object assigned to those
events are "associated" with the store. We currently represent that with
an Optional<DragDataStore&>.

However, it's also possible to create DataTransfer objects from scripts.
Those objects create their own drag data store. This puts DataTransfer
in a weird situation where it may own a store or just reference one.

Rather than coming up with something like Variant<DDS, DDS&> or using
MaybeOwned<DDS> here, we can get by with just making the store reference
counted.
This commit is contained in:
Timothy Flynn 2024-08-21 06:39:02 -04:00 committed by Andreas Kling
commit f7c4165dde
Notes: github-actions[bot] 2024-08-22 12:23:00 +00:00
6 changed files with 24 additions and 15 deletions

View file

@ -9,6 +9,11 @@
namespace Web::HTML {
NonnullRefPtr<DragDataStore> DragDataStore::create()
{
return adopt_ref(*new DragDataStore());
}
DragDataStore::DragDataStore()
: m_allowed_effects_state(DataTransferEffect::uninitialized)
{