Diff
Modified: trunk/Source/WebCore/ChangeLog (265541 => 265542)
--- trunk/Source/WebCore/ChangeLog 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebCore/ChangeLog 2020-08-12 07:35:52 UTC (rev 265542)
@@ -1,3 +1,21 @@
+2020-08-12 Carlos Garcia Campos <[email protected]>
+
+ REGRESSION(r261570): [GTK] Fails to send drop event to _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=215032
+
+ Reviewed by Darin Adler.
+
+ Add support for custom data in drag and drop operations too.
+
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::Pasteboard::write): Se custom data on m_selectionData.
+ (WebCore::Pasteboard::read): Initialize the content origin also for drag and drop pasteboards.
+ (WebCore::Pasteboard::hasData): For drag and drop pasteboards return true also if m_selectionData has custom data.
+ (WebCore::Pasteboard::typesSafeForBindings): Implement this for drag and drop pasteboards.
+ (WebCore::Pasteboard::readOrigin): Ditto.
+ (WebCore::Pasteboard::readStringInCustomData): Ditto.
+ (WebCore::Pasteboard::writeCustomData): Ditto.
+
2020-08-11 James Darpinian <[email protected]>
[WebGL2] Depth formats can have mipmaps in WebGL 2
Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (265541 => 265542)
--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2020-08-12 07:35:52 UTC (rev 265542)
@@ -184,6 +184,9 @@
m_selectionData->setText(pasteboardContent.text);
m_selectionData->setMarkup(pasteboardContent.markup);
m_selectionData->setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete);
+ PasteboardCustomData customData;
+ customData.setOrigin(pasteboardContent.contentOrigin);
+ m_selectionData->setCustomData(customData.createSharedBuffer());
} else {
SelectionData data;
data.setText(pasteboardContent.text);
@@ -253,6 +256,8 @@
void Pasteboard::read(PasteboardWebContentReader& reader, WebContentReadingPolicy policy, Optional<size_t>)
{
+ reader.contentOrigin = readOrigin();
+
if (m_selectionData) {
if (m_selectionData->hasMarkup() && reader.readHTML(m_selectionData->markup()))
return;
@@ -269,8 +274,6 @@
return;
}
- reader.contentOrigin = readOrigin();
-
auto types = platformStrategies()->pasteboardStrategy()->types(m_name);
if (types.contains("text/html"_s)) {
auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, "text/html"_s);
@@ -319,15 +322,32 @@
bool Pasteboard::hasData()
{
if (m_selectionData)
- return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage();
+ return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage() || m_selectionData->hasCustomData();
return !platformStrategies()->pasteboardStrategy()->types(m_name).isEmpty();
}
Vector<String> Pasteboard::typesSafeForBindings(const String& origin)
{
- if (m_selectionData)
- return { };
+ if (m_selectionData) {
+ ListHashSet<String> types;
+ if (auto* buffer = m_selectionData->customData()) {
+ auto customData = PasteboardCustomData::fromSharedBuffer(*buffer);
+ if (customData.origin() == origin) {
+ for (auto& type : customData.orderedTypes())
+ types.add(type);
+ }
+ }
+ if (m_selectionData->hasText())
+ types.add("text/plain"_s);
+ if (m_selectionData->hasMarkup())
+ types.add("text/html"_s);
+ if (m_selectionData->hasURIList())
+ types.add("text/uri-list"_s);
+
+ return copyToVector(types);
+ }
+
return platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_name, origin);
}
@@ -356,8 +376,12 @@
String Pasteboard::readOrigin()
{
- if (m_selectionData)
+ if (m_selectionData) {
+ if (auto* buffer = m_selectionData->customData())
+ return PasteboardCustomData::fromSharedBuffer(*buffer).origin();
+
return { };
+ }
// FIXME: cache custom data?
if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType()))
@@ -395,8 +419,12 @@
String Pasteboard::readStringInCustomData(const String& type)
{
- if (m_selectionData)
+ if (m_selectionData) {
+ if (auto* buffer = m_selectionData->customData())
+ return PasteboardCustomData::fromSharedBuffer(*buffer).readStringInCustomData(type);
+
return { };
+ }
// FIXME: cache custom data?
if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType()))
@@ -429,8 +457,17 @@
void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>& data)
{
- if (m_selectionData)
+ if (m_selectionData) {
+ if (!data.isEmpty()) {
+ const auto& customData = data[0];
+ customData.forEachPlatformString([this] (auto& type, auto& string) {
+ writeString(type, string);
+ });
+ if (customData.hasSameOriginCustomData() || !customData.origin().isEmpty())
+ m_selectionData->setCustomData(customData.createSharedBuffer());
+ }
return;
+ }
platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_name);
}
Modified: trunk/Source/WebKit/ChangeLog (265541 => 265542)
--- trunk/Source/WebKit/ChangeLog 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebKit/ChangeLog 2020-08-12 07:35:52 UTC (rev 265542)
@@ -1,3 +1,25 @@
+2020-08-12 Carlos Garcia Campos <[email protected]>
+
+ REGRESSION(r261570): [GTK] Fails to send drop event to _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=215032
+
+ Reviewed by Darin Adler.
+
+ Handle custom data in drag and drop operations.
+
+ * UIProcess/API/gtk/DragSourceGtk3.cpp:
+ (WebKit::DragSource::DragSource):
+ (WebKit::DragSource::begin):
+ * UIProcess/API/gtk/DragSourceGtk4.cpp:
+ (WebKit::DragSource::begin):
+ * UIProcess/API/gtk/DropTargetGtk3.cpp:
+ (WebKit::DropTarget::DropTarget):
+ (WebKit::DropTarget::accept):
+ (WebKit::DropTarget::dataReceived):
+ * UIProcess/API/gtk/DropTargetGtk4.cpp:
+ (WebKit::DropTarget::DropTarget):
+ (WebKit::DropTarget::accept):
+
2020-08-11 Jer Noble <[email protected]>
[Mac] Add Experimental Feature preference for SW VP9
Modified: trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp (265541 => 265542)
--- trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk3.cpp 2020-08-12 07:35:52 UTC (rev 265542)
@@ -31,12 +31,13 @@
#include "WebKitWebViewBasePrivate.h"
#include <WebCore/GRefPtrGtk.h>
#include <WebCore/GtkUtilities.h>
+#include <WebCore/PasteboardCustomData.h>
#include <gtk/gtk.h>
namespace WebKit {
using namespace WebCore;
-enum DragTargetType { Markup, Text, Image, URIList, NetscapeURL, SmartPaste };
+enum DragTargetType { Markup, Text, Image, URIList, NetscapeURL, SmartPaste, Custom };
DragSource::DragSource(GtkWidget* webView)
: m_webView(webView)
@@ -74,7 +75,12 @@
case DragTargetType::SmartPaste:
gtk_selection_data_set_text(data, "", -1);
break;
+ case DragTargetType::Custom: {
+ auto* buffer = drag.m_selectionData->customData();
+ gtk_selection_data_set(data, gdk_atom_intern_static_string(PasteboardCustomData::gtkType()), 8, reinterpret_cast<const guchar*>(buffer->data()), buffer->size());
+ break;
}
+ }
}), this);
g_signal_connect(m_webView, "drag-end", G_CALLBACK(+[](GtkWidget*, GdkDragContext* context, gpointer userData) {
@@ -128,6 +134,8 @@
gtk_target_list_add_image_targets(list.get(), DragTargetType::Image, TRUE);
if (m_selectionData->canSmartReplace())
gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, DragTargetType::SmartPaste);
+ if (m_selectionData->hasCustomData())
+ gtk_target_list_add(list.get(), gdk_atom_intern_static_string(PasteboardCustomData::gtkType()), 0, DragTargetType::Custom);
m_drag = gtk_drag_begin_with_coordinates(m_webView, list.get(), dragOperationToGdkDragActions(operationMask), GDK_BUTTON_PRIMARY, nullptr, -1, -1);
if (image) {
Modified: trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp (265541 => 265542)
--- trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp 2020-08-12 07:35:52 UTC (rev 265542)
@@ -30,6 +30,7 @@
#include "WebKitWebViewBasePrivate.h"
#include <WebCore/GtkUtilities.h>
+#include <WebCore/PasteboardCustomData.h>
#include <gtk/gtk.h>
namespace WebKit {
@@ -86,6 +87,11 @@
providers.append(gdk_content_provider_new_for_bytes("application/vnd.webkitgtk.smartpaste", bytes.get()));
}
+ if (m_selectionData->hasCustomData()) {
+ GRefPtr<GBytes> bytes = m_selectionData->customData()->createGBytes();
+ providers.append(gdk_content_provider_new_for_bytes(PasteboardCustomData::gtkType(), bytes.get()));
+ }
+
auto* surface = gtk_native_get_surface(gtk_widget_get_native(m_webView));
auto* device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(m_webView)));
GRefPtr<GdkContentProvider> provider = adoptGRef(gdk_content_provider_new_union(providers.data(), providers.size()));
Modified: trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp (265541 => 265542)
--- trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk3.cpp 2020-08-12 07:35:52 UTC (rev 265542)
@@ -32,6 +32,7 @@
#include <WebCore/DragData.h>
#include <WebCore/GRefPtrGtk.h>
#include <WebCore/GtkUtilities.h>
+#include <WebCore/PasteboardCustomData.h>
#include <gtk/gtk.h>
#include <wtf/glib/GUniquePtr.h>
@@ -38,7 +39,7 @@
namespace WebKit {
using namespace WebCore;
-enum DropTargetType { Markup, Text, URIList, NetscapeURL, SmartPaste };
+enum DropTargetType { Markup, Text, URIList, NetscapeURL, SmartPaste, Custom };
DropTarget::DropTarget(GtkWidget* webView)
: m_webView(webView)
@@ -50,6 +51,7 @@
gtk_target_list_add_uri_targets(list.get(), DropTargetType::URIList);
gtk_target_list_add(list.get(), gdk_atom_intern_static_string("_NETSCAPE_URL"), 0, DropTargetType::NetscapeURL);
gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, DropTargetType::SmartPaste);
+ gtk_target_list_add(list.get(), gdk_atom_intern_static_string(PasteboardCustomData::gtkType()), 0, DropTargetType::Custom);
gtk_drag_dest_set(m_webView, static_cast<GtkDestDefaults>(0), nullptr, 0,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK));
gtk_drag_dest_set_target_list(m_webView, list.get());
@@ -114,7 +116,8 @@
"text/html",
"_NETSCAPE_URL",
"text/uri-list",
- "application/vnd.webkitgtk.smartpaste"
+ "application/vnd.webkitgtk.smartpaste",
+ "org.webkitgtk.WebKit.custom-pasteboard-data"
};
Vector<GdkAtom, 4> targets;
for (unsigned i = 0; i < G_N_ELEMENTS(supportedTargets); ++i) {
@@ -200,7 +203,14 @@
case DropTargetType::SmartPaste:
m_selectionData->setCanSmartReplace(true);
break;
+ case DropTargetType::Custom: {
+ int length;
+ const auto* customData = gtk_selection_data_get_data_with_length(data, &length);
+ if (length)
+ m_selectionData->setCustomData(SharedBuffer::create(customData, static_cast<size_t>(length)));
+ break;
}
+ }
if (--m_dataRequestCount)
return;
Modified: trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk4.cpp (265541 => 265542)
--- trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk4.cpp 2020-08-12 04:08:16 UTC (rev 265541)
+++ trunk/Source/WebKit/UIProcess/API/gtk/DropTargetGtk4.cpp 2020-08-12 07:35:52 UTC (rev 265542)
@@ -31,6 +31,7 @@
#include "WebKitWebViewBasePrivate.h"
#include <WebCore/DragData.h>
#include <WebCore/GtkUtilities.h>
+#include <WebCore/PasteboardCustomData.h>
#include <gtk/gtk.h>
#include <wtf/glib/GUniquePtr.h>
@@ -48,6 +49,7 @@
gdk_content_formats_builder_add_mime_type(formatsBuilder, "text/uri-list");
gdk_content_formats_builder_add_mime_type(formatsBuilder, "_NETSCAPE_URL");
gdk_content_formats_builder_add_mime_type(formatsBuilder, "application/vnd.webkitgtk.smartpaste");
+ gdk_content_formats_builder_add_mime_type(formatsBuilder, PasteboardCustomData::gtkType());
auto* target = gtk_drop_target_async_new(gdk_content_formats_builder_free_to_formats(formatsBuilder),
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK));
g_signal_connect(target, "accept", G_CALLBACK(+[](GtkDropTargetAsync*, GdkDrop* gdkDrop, gpointer userData) -> gboolean {
@@ -130,7 +132,8 @@
"text/html",
"_NETSCAPE_URL",
"text/uri-list",
- "application/vnd.webkitgtk.smartpaste"
+ "application/vnd.webkitgtk.smartpaste",
+ "org.webkitgtk.WebKit.custom-pasteboard-data"
};
for (unsigned i = 0; i < G_N_ELEMENTS(supportedMimeTypes); ++i) {
@@ -173,6 +176,10 @@
m_selectionData->setURIList(String::fromUTF8(reinterpret_cast<const char*>(uriListData), length));
} else if (mimeType == "application/vnd.webkitgtk.smartpaste")
m_selectionData->setCanSmartReplace(true);
+ else if (mimeType == PasteboardCustomData::gtkType()) {
+ if (g_bytes_get_size(data.get()))
+ m_selectionData->setCustomData(SharedBuffer::create(data.get()));
+ }
didLoadData();
});