2009-06-30 Zan Dobersek <zandobersek@gmail.com>
authorjmalonzo@webkit.org <jmalonzo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 02:16:13 +0000 (02:16 +0000)
committerjmalonzo@webkit.org <jmalonzo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 02:16:13 +0000 (02:16 +0000)
        Reviewed by Gustavo Noronha.

        [GTK] Drag and drop support
        https://bugs.webkit.org/show_bug.cgi?id=23642

        Define DragImageRef as GdkPixbuf and implement essential
        functions which manipulate drag images.

        * platform/DragImage.h:
        * platform/gtk/DragImageGtk.cpp:
        (WebCore::dragImageSize):
        (WebCore::deleteDragImage):
        (WebCore::scaleDragImage):
        (WebCore::createDragImageFromImage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45414 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/DragImage.h
WebCore/platform/gtk/DragImageGtk.cpp

index a160dd1..06795b1 100644 (file)
@@ -1,3 +1,20 @@
+2009-06-30  Zan Dobersek  <zandobersek@gmail.com>
+
+        Reviewed by Gustavo Noronha.
+
+        [GTK] Drag and drop support
+        https://bugs.webkit.org/show_bug.cgi?id=23642
+
+        Define DragImageRef as GdkPixbuf and implement essential
+        functions which manipulate drag images.
+
+        * platform/DragImage.h:
+        * platform/gtk/DragImageGtk.cpp:
+        (WebCore::dragImageSize):
+        (WebCore::deleteDragImage):
+        (WebCore::scaleDragImage):
+        (WebCore::createDragImageFromImage):
+
 2009-06-30  Maxime Simon  <simon.maxime@gmail.com>
 
         Reviewed by Eric Seidel.
index 744e450..a9039db 100644 (file)
@@ -46,6 +46,8 @@ typedef struct HBITMAP__* HBITMAP;
 class wxDragImage;
 #elif PLATFORM(CHROMIUM)
 #include "DragImageRef.h"
+#elif PLATFORM(GTK)
+typedef struct _GdkPixbuf GdkPixbuf;
 #endif
 
 //We need to #define YOffset as it needs to be shared with WebKit
@@ -69,7 +71,7 @@ namespace WebCore {
 #elif PLATFORM(WX)
     typedef wxDragImage* DragImageRef;
 #elif PLATFORM(GTK)
-    typedef void* DragImageRef;
+    typedef GdkPixbuf* DragImageRef;
 #endif
     
     IntSize dragImageSize(DragImageRef);
index 4ddae3a..4c77830 100644 (file)
 #include "CachedImage.h"
 #include "Image.h"
 
+#include <gtk/gtk.h>
+
 namespace WebCore {
 
-IntSize dragImageSize(DragImageRef)
+IntSize dragImageSize(DragImageRef image)
 {
+    if (image)
+        return IntSize(gdk_pixbuf_get_width(image), gdk_pixbuf_get_height(image));
+
     return IntSize(0, 0);
 }
 
-void deleteDragImage(DragImageRef)
+void deleteDragImage(DragImageRef image)
 {
+    if (image)
+        g_object_unref(image);
 }
 
-DragImageRef scaleDragImage(DragImageRef image, FloatSize)
+DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
 {
-    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_BILINEAR);
+        deleteDragImage(image);
+        return scaledImage;
+    }
+
+    return 0;
 }
 
 DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
@@ -41,9 +58,9 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
     return image;
 }
 
-DragImageRef createDragImageFromImage(Image*)
+DragImageRef createDragImageFromImage(Image* image)
 {
-    return 0;
+    return image->getGdkPixbuf();
 }
 
 DragImageRef createDragImageIconForCachedImage(CachedImage*)