LibWeb: Return the same DataTransfer.types() array if unmodified

This commit is contained in:
Tim Ledbetter 2025-09-05 22:19:09 +01:00 committed by Jelle Raaijmakers
parent 3fc7613bf1
commit 3099459504
Notes: github-actions[bot] 2025-09-12 10:31:31 +00:00
3 changed files with 6 additions and 1 deletions

View file

@ -74,6 +74,8 @@ void DataTransfer::visit_edges(JS::Cell::Visitor& visitor)
Base::visit_edges(visitor);
visitor.visit(m_items);
visitor.visit(m_item_list);
VISIT_CACHED_ATTRIBUTE(types);
}
void DataTransfer::set_drop_effect(String const& drop_effect)
@ -374,6 +376,7 @@ 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.
set_cached_types(nullptr);
m_types = move(types);
}

View file

@ -9,6 +9,7 @@
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/HTML/DragDataStore.h>
#include <LibWeb/WebIDL/CachedAttribute.h>
namespace Web::HTML {
@ -53,6 +54,7 @@ public:
GC::Ref<DataTransferItemList> items();
ReadonlySpan<String> types() const;
DEFINE_CACHED_ATTRIBUTE(types);
String get_data(String const& format) const;
void clear_data(Optional<String> maybe_format = {});
GC::Ref<FileAPI::FileList> files() const;

View file

@ -14,7 +14,7 @@ interface DataTransfer {
[FIXME] undefined setDragImage(Element image, long x, long y);
// old interface
readonly attribute FrozenArray<DOMString> types;
[CachedAttribute] readonly attribute FrozenArray<DOMString> types;
DOMString getData(DOMString format);
[FIXME] undefined setData(DOMString format, DOMString data);
undefined clearData(optional DOMString format);