Bug 211779 - [GTK4] Add support for drag and drop operations
Summary: [GTK4] Add support for drag and drop operations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on: 211723
Blocks: GTK4
  Show dependency treegraph
 
Reported: 2020-05-12 06:34 PDT by Carlos Garcia Campos
Modified: 2020-05-20 05:39 PDT (History)
2 users (show)

See Also:


Attachments
Patch (24.55 KB, patch)
2020-05-12 06:37 PDT, Carlos Garcia Campos
aperez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2020-05-12 06:34:42 PDT
.
Comment 1 Carlos Garcia Campos 2020-05-12 06:37:16 PDT
Created attachment 399123 [details]
Patch
Comment 2 Adrian Perez 2020-05-12 15:55:00 PDT
Comment on attachment 399123 [details]
Patch

This was easier to follow after having read all the other patches in the series =)

Patch LGTM, but I see an opportunity to avoid unnecessary copying of data. Please
take a look and consider whether it may be good to apply the suggested change before
landing.

View in context: https://bugs.webkit.org/attachment.cgi?id=399123&action=review

> Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:64
> +GdkTexture* BitmapImage::gdkTexture()

Nice refactor :)

> Source/WebKit/UIProcess/API/gtk/DragSourceGtk4.cpp:59
> +        GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(markup.data(), markup.length()));

This (and the ones below) makes one copy if data into a CString, then another copy
with g_bytes_new(). We could get the inner CStringBuffer from the CString, which
is reference counted, and use that with g_bytes_new_with_free_func(). Rough idea:

  CString markup = m_selectionData->markup().utf8();
  RefPtr<CStringBuffer> buffer = markup.buffer();
  GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_with_free_func(buffer->data(), buffer->length(),
      [](void* data) { RefPtr<CStringBuffer> buffer = adoptRef(static_cast<CStringBuffer*>(data)); },
      buffer.leakRef()));
Comment 3 Carlos Garcia Campos 2020-05-20 05:39:30 PDT
Committed r261911: <https://trac.webkit.org/changeset/261911>