[Webkit-unassigned] [Bug 23642] [GTK] Drag and drop support
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Apr 24 14:16:06 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=23642
------- Comment #11 from xan.lopez at gmail.com 2009-04-24 14:16 PDT -------
(From update of attachment 29738)
> + CachedImage* cachedImage = getCachedImage(element);
> + if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded())
Isn't it impossible that something returned by cachedImage fails for ->image()
?
> + return;
> + GdkPixbuf* pixbuf = cachedImage->image()->getGdkPixbuf();
> + if (pixbuf)
> + m_dragClipboard->setImage(pixbuf);;
> +
> + m_dragClipboard->setText(url.string());
> + m_dragClipboard->setUrl(url.string());
> + m_dragClipboard->setUrlLabel(label);
> }
>
> -void ClipboardGtk::writeRange(Range*, Frame*)
> +void ClipboardGtk::writeURL(const KURL& url, const String& label, Frame*)
> {
> - notImplemented();
> + if (!m_dragClipboard)
> + return;
> +
> + m_dragClipboard->setText(url.string());
> + m_dragClipboard->setUrl(url.string());
> + m_dragClipboard->setUrlLabel(label);
Make the first function call the second one perhaps?
> diff --git a/WebCore/platform/gtk/ClipboardGtk.h b/WebCore/platform/gtk/ClipboardGtk.h
> index b8b4ddf..4e7ef38 100644
> --- a/WebCore/platform/gtk/ClipboardGtk.h
> +++ b/WebCore/platform/gtk/ClipboardGtk.h
> @@ -24,13 +24,14 @@
> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> */
>
> -#ifndef ClipboardGdk_h
> -#define ClipboardGdk_h
> +#ifndef ClipboardGtk_h
> +#define ClipboardGtk_h
>
> - return image;
> + if (image) {
> + IntSize imageSize = dragImageSize(image);
> + GdkPixbuf* scaledImage = gdk_pixbuf_scale_simple(image, imageSize.width() * scale.width(), imageSize.height() * scale.height(), GDK_INTERP_NEAREST);
The docs recommend GDK_INTER_BILINEAR here, any reason not to use it?
> +
> +#if GTK_CHECK_VERSION(2,10,0)
> + GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
> + GdkAtom netscapeUrl = gdk_atom_intern_static_string("_NETSCAPE_URL");
> +#else
> + GdkAtom textHtml = gdk_atom_intern("text/html", false);
> + GdkAtom netscapeUrl = gdk_atom_intern("_NETSCAPE_URL", false);
> +#endif
We require GTK+ 2.10 now, so you can get rid of this.
> +
> + GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView),
> + targetList,
> + dragAction,
> + 1,
> + event);
Indentation?
> +static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_)
> +{
> + DragClipboard* clipboard = DragClipboard::clipboard();
> + char* data;
> +
> + switch (info) {
> + case WEBKIT_WEB_VIEW_TARGET_INFO_HTML:
> + data = g_strdup((clipboard->html().isEmpty() || clipboard->html().isNull())
> + ? clipboard->text().utf8().data() : clipboard->html().utf8().data());
> + gtk_selection_data_set(selection_data,
> + selection_data->target,
> + 8,
> + reinterpret_cast<guchar*>(data),
> + strlen(data));
> +
> + g_free(data);
> + return;
> + case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT:
> + data = g_strdup(clipboard->text().utf8().data());
> + gtk_selection_data_set(selection_data,
> + selection_data->target,
> + 8,
> + reinterpret_cast<guchar*>(data),
> + strlen(data));
> + g_free(data);
> + return;
> + case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE:
> + gtk_selection_data_set_pixbuf(selection_data, clipboard->image());
> + return;
> + case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
> + data = g_strdup_printf("%s\r\n%s\r\n",
> + clipboard->url().utf8().data(),
> + (clipboard->urlLabel().isEmpty() || clipboard->urlLabel().isNull())
> + ? clipboard->url().utf8().data() : clipboard->urlLabel().utf8().data());
> + gtk_selection_data_set(selection_data,
> + selection_data->target,
> + 8,
> + reinterpret_cast<guchar*>(data),
> + strlen(data));
> +
> + g_free(data);
> + return;
> + case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
> + data = g_strdup_printf("%s\n%s",
> + clipboard->url().utf8().data(),
> + (clipboard->urlLabel().isEmpty() || clipboard->urlLabel().isNull())
> + ? clipboard->url().utf8().data() : clipboard->urlLabel().utf8().data());
> +
> + gtk_selection_data_set(selection_data,
> + selection_data->target,
> + 8,
> + reinterpret_cast<guchar*>(data),
> + strlen(data));
> +
> + g_free(data);
> + return;
> + }
The indentation seems to be really wrong here in some places.
> +}
> +
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list