Commit Graph

10 Commits

Author SHA1 Message Date
Timothy Flynn
77a96886e2 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.

(cherry picked from commit 5c9287aa99e52886a3d144c26de6a54980a53db6)
2024-11-01 22:04:14 -04:00
Timothy Flynn
d14a26b9e7 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.

(cherry picked from commit f7c4165dde9cc1f3c84fbc49c8496dea3a898491)
2024-11-01 22:04:14 -04:00
Timothy Flynn
39f991bb68 LibWeb: Implement the DataTransfer items attribute
(cherry picked from commit 1b703629548950882063495679b9307519271b92)
2024-11-01 22:04:14 -04:00
Timothy Flynn
4e820d36e2 LibWeb: Implement DataTransfer.prototype.getData()
This is used by Google Lens. It will always return the empty string when
dragging an image onto the Google Lens search field.

(cherry picked from commit 535f03b6cf664071e03b7f3c95116fa89c33122b)
2024-11-01 22:04:14 -04:00
Timothy Flynn
a3050819d2 LibWeb: Implement the DataTransfer files attribute
(cherry picked from commit 4bb9168712d6e706465ded9e1b6764a039651ea0)
2024-11-01 19:58:08 -04:00
Timothy Flynn
7085b7f127 LibWeb: Implement the DataTransfer types attribute
(cherry picked from commit 9f4e3c7e25bbc94a479a2a96cdbe85c47f634627)
2024-11-01 19:58:08 -04:00
Timothy Flynn
87d2766cd7 LibWeb: Implement the DataTransfer effect attributes
(cherry picked from commit 3674e037f38119e7b497b4a5c90707ff94cf44bb)
2024-11-01 19:58:08 -04:00
Shannon Booth
bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
Timothy Flynn
c2ef506b4a LibWeb: Add an empty DataTransfer IDL implementation
This does not implement any of the IDL methods, but GitHub requires the
interface exists to upload files via an <input type="file"> element.
Their JS handles uploads via this element and via drag-and-drop in one
function, and check if the uploaded file is `instanceof DataTransfer` to
decide how to handle it.
2024-03-14 10:10:33 +01:00