[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mrobinson at webkit.org
mrobinson at webkit.org
Wed Dec 22 13:29:08 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 7173b39420aaada5a3b11e39e48d61ac53c42eea
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Sep 16 20:51:09 2010 +0000
2010-09-16 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Implement dissolveDragImageToFraction
https://bugs.webkit.org/show_bug.cgi?id=45826
* wtf/gobject/GTypedefs.h: Added forward declarations for GtkWindow and GdkEventExpose.
2010-09-16 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Implement dissolveDragImageToFraction
https://bugs.webkit.org/show_bug.cgi?id=45826
Convert the drag image from a GdkPixbuf to a Cairo surface. Not only
might this allow code to be shared between Cairo ports it prevents a
full data copy when the image is not resized and makes the implementation
of dissolveDragImageToFraction more straight-forward.
This feature is covered by manual-tests/drag-image.html.
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::maxDragImageSize): Make the maximum size of the drag
image a little smaller.
* platform/DragImage.h: Changed the drag image type to be a cairo_surface_t*.
* platform/gtk/DragImageGtk.cpp:
(WebCore::dragImageSize): Reimplemented to reflect new drag image type.
(WebCore::deleteDragImage): Ditto.
(WebCore::scaleDragImage): Ditto.
(WebCore::dissolveDragImageToFraction): Filled the stub of this function.
(WebCore::createDragImageFromImage): Reimplemented to reflect new drag image type.
* platform/gtk/GtkVersioning.h: Added definition for gtk_widget_get_realized for older GTK+s.
2010-09-16 Martin Robinson <mrobinson at igalia.com>
Reviewed by Xan Lopez.
[GTK] Implement dissolveDragImageToFraction
https://bugs.webkit.org/show_bug.cgi?id=45826
To support full alpha in the drag icon, changed the drag icon to be a
GtkWindow with an RGBA colormap. Added logic to support painting the drag
image to this window during the expose event.
* WebCoreSupport/DragClientGtk.cpp:
(WebKit::dragIconWindowExposeEventCallback): Added.
(WebKit::DragClient::DragClient): Initialize the new drag icon window.
(WebKit::DragClient::~DragClient): Disconnect the expose event signal.
(WebKit::DragClient::startDrag): Resize the drag icon window the appropriate size and
if necessary, set its colormap.
(WebKit::DragClient::dragIconWindowExposeEvent): Added.
* WebCoreSupport/DragClientGtk.h: Added new member and method declarations.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 2ccdc96..1a3d4bd 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-16 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Implement dissolveDragImageToFraction
+ https://bugs.webkit.org/show_bug.cgi?id=45826
+
+ * wtf/gobject/GTypedefs.h: Added forward declarations for GtkWindow and GdkEventExpose.
+
2010-09-16 Eric Uhrhane <ericu at chromium.org>
Reviewed by Jian Li.
diff --git a/JavaScriptCore/wtf/gobject/GTypedefs.h b/JavaScriptCore/wtf/gobject/GTypedefs.h
index e79ba33..b1600c2 100644
--- a/JavaScriptCore/wtf/gobject/GTypedefs.h
+++ b/JavaScriptCore/wtf/gobject/GTypedefs.h
@@ -45,6 +45,7 @@ typedef struct _GdkCursor GdkCursor;
typedef struct _GdkDragContext GdkDragContext;
typedef struct _GdkDrawable GdkDrawable;
typedef struct _GdkEventConfigure GdkEventConfigure;
+typedef struct _GdkEventExpose GdkEventExpose;
typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GError GError;
typedef struct _GFile GFile;
@@ -79,6 +80,7 @@ typedef struct _GtkStyle GtkStyle;
typedef struct _GtkTargetList GtkTargetList;
typedef struct _GtkThemeParts GtkThemeParts;
typedef struct _GtkWidget GtkWidget;
+typedef struct _GtkWindow GtkWindow;
#ifdef GTK_API_VERSION_2
typedef struct _GdkRectangle GdkRectangle;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 02e8619..506d0e1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-09-16 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Implement dissolveDragImageToFraction
+ https://bugs.webkit.org/show_bug.cgi?id=45826
+
+ Convert the drag image from a GdkPixbuf to a Cairo surface. Not only
+ might this allow code to be shared between Cairo ports it prevents a
+ full data copy when the image is not resized and makes the implementation
+ of dissolveDragImageToFraction more straight-forward.
+
+ This feature is covered by manual-tests/drag-image.html.
+
+ * page/gtk/DragControllerGtk.cpp:
+ (WebCore::DragController::maxDragImageSize): Make the maximum size of the drag
+ image a little smaller.
+ * platform/DragImage.h: Changed the drag image type to be a cairo_surface_t*.
+ * platform/gtk/DragImageGtk.cpp:
+ (WebCore::dragImageSize): Reimplemented to reflect new drag image type.
+ (WebCore::deleteDragImage): Ditto.
+ (WebCore::scaleDragImage): Ditto.
+ (WebCore::dissolveDragImageToFraction): Filled the stub of this function.
+ (WebCore::createDragImageFromImage): Reimplemented to reflect new drag image type.
+ * platform/gtk/GtkVersioning.h: Added definition for gtk_widget_get_realized for older GTK+s.
+
2010-09-15 David Hyatt <hyatt at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/page/gtk/DragControllerGtk.cpp b/WebCore/page/gtk/DragControllerGtk.cpp
index c064a87..5f9044f 100644
--- a/WebCore/page/gtk/DragControllerGtk.cpp
+++ b/WebCore/page/gtk/DragControllerGtk.cpp
@@ -58,8 +58,7 @@ DragOperation DragController::dragOperation(DragData* dragData)
const IntSize& DragController::maxDragImageSize()
{
- static const IntSize maxDragImageSize(400, 400);
-
+ static const IntSize maxDragImageSize(200, 200);
return maxDragImageSize;
}
diff --git a/WebCore/platform/DragImage.h b/WebCore/platform/DragImage.h
index 483e2d0..a4aad47 100644
--- a/WebCore/platform/DragImage.h
+++ b/WebCore/platform/DragImage.h
@@ -48,7 +48,7 @@ class wxDragImage;
#elif PLATFORM(CHROMIUM)
#include "DragImageRef.h"
#elif PLATFORM(GTK)
-typedef struct _GdkPixbuf GdkPixbuf;
+typedef struct _cairo_surface cairo_surface_t;
#elif PLATFORM(HAIKU)
class BBitmap;
#elif PLATFORM(BREWMP)
@@ -75,7 +75,7 @@ namespace WebCore {
#elif PLATFORM(WX)
typedef wxDragImage* DragImageRef;
#elif PLATFORM(GTK)
- typedef GdkPixbuf* DragImageRef;
+ typedef cairo_surface_t* DragImageRef;
#elif PLATFORM(HAIKU)
typedef BBitmap* DragImageRef;
#elif PLATFORM(BREWMP)
diff --git a/WebCore/platform/gtk/DragImageGtk.cpp b/WebCore/platform/gtk/DragImageGtk.cpp
index 4c77830..9d0d838 100644
--- a/WebCore/platform/gtk/DragImageGtk.cpp
+++ b/WebCore/platform/gtk/DragImageGtk.cpp
@@ -1,4 +1,6 @@
/*
+ * 2010 Igalia S.L
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -19,15 +21,15 @@
#include "CachedImage.h"
#include "Image.h"
-
-#include <gtk/gtk.h>
+#include "PlatformRefPtrCairo.h"
+#include <cairo.h>
namespace WebCore {
IntSize dragImageSize(DragImageRef image)
{
if (image)
- return IntSize(gdk_pixbuf_get_width(image), gdk_pixbuf_get_height(image));
+ return IntSize(cairo_image_surface_get_width(image), cairo_image_surface_get_height(image));
return IntSize(0, 0);
}
@@ -35,32 +37,45 @@ IntSize dragImageSize(DragImageRef image)
void deleteDragImage(DragImageRef image)
{
if (image)
- g_object_unref(image);
+ cairo_surface_destroy(image);
}
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
{
- 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;
- }
+ if (!image)
+ return 0;
- return 0;
+ int newWidth = scale.width() * cairo_image_surface_get_width(image);
+ int newHeight = scale.height() * cairo_image_surface_get_height(image);
+ cairo_surface_t* scaledSurface = cairo_surface_create_similar(image, CAIRO_CONTENT_COLOR_ALPHA, newWidth, newHeight);
+
+ PlatformRefPtr<cairo_t> context = adoptPlatformRef(cairo_create(scaledSurface));
+ cairo_scale(context.get(), scale.width(), scale.height());
+ cairo_pattern_set_extend(cairo_get_source(context.get()), CAIRO_EXTEND_PAD);
+ cairo_pattern_set_filter(cairo_get_source(context.get()), CAIRO_FILTER_BEST);
+ cairo_set_operator(context.get(), CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface(context.get(), image, 0, 0);
+ cairo_paint(context.get());
+
+ deleteDragImage(image);
+ return scaledSurface;
}
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
+DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
{
+ if (!image)
+ return 0;
+
+ PlatformRefPtr<cairo_t> context = adoptPlatformRef(cairo_create(image));
+ cairo_set_operator(context.get(), CAIRO_OPERATOR_DEST_IN);
+ cairo_set_source_rgba(context.get(), 0, 0, 0, fraction);
+ cairo_paint(context.get());
return image;
}
DragImageRef createDragImageFromImage(Image* image)
{
- return image->getGdkPixbuf();
+ return cairo_surface_reference(image->nativeImageForCurrentFrame());
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
diff --git a/WebCore/platform/gtk/GtkVersioning.h b/WebCore/platform/gtk/GtkVersioning.h
index 2c6b00a..867e14f 100644
--- a/WebCore/platform/gtk/GtkVersioning.h
+++ b/WebCore/platform/gtk/GtkVersioning.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
#endif // GTK_CHECK_VERSION(2, 21, 2)
#if !GTK_CHECK_VERSION(2, 20, 0)
+#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget)
#define gtk_widget_set_realized(widget, TRUE) GTK_WIDGET_SET_FLAGS((widget), GTK_REALIZED)
#define gtk_range_get_min_slider_size(range) (range)->min_slider_size
#endif // GTK_CHECK_VERSION(2, 20, 0)
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 11da8d6..5383fd4 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-16 Martin Robinson <mrobinson at igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Implement dissolveDragImageToFraction
+ https://bugs.webkit.org/show_bug.cgi?id=45826
+
+ To support full alpha in the drag icon, changed the drag icon to be a
+ GtkWindow with an RGBA colormap. Added logic to support painting the drag
+ image to this window during the expose event.
+
+ * WebCoreSupport/DragClientGtk.cpp:
+ (WebKit::dragIconWindowExposeEventCallback): Added.
+ (WebKit::DragClient::DragClient): Initialize the new drag icon window.
+ (WebKit::DragClient::~DragClient): Disconnect the expose event signal.
+ (WebKit::DragClient::startDrag): Resize the drag icon window the appropriate size and
+ if necessary, set its colormap.
+ (WebKit::DragClient::dragIconWindowExposeEvent): Added.
+ * WebCoreSupport/DragClientGtk.h: Added new member and method declarations.
+
2010-09-14 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Carlson and Martin Robinson.
diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
index 5720099..cc75d36 100644
--- a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
@@ -34,16 +34,30 @@
#include "RenderObject.h"
#include "webkitprivate.h"
#include "webkitwebview.h"
+#include <gdk/gdk.h>
#include <gtk/gtk.h>
using namespace WebCore;
namespace WebKit {
+static gboolean dragIconWindowExposeEventCallback(GtkWidget* widget, GdkEventExpose* event, DragClient* client)
+{
+ client->dragIconWindowExposeEvent(widget, event);
+ return TRUE;
+}
+
DragClient::DragClient(WebKitWebView* webView)
: m_webView(webView)
, m_startPos(0, 0)
+ , m_dragIconWindow(gtk_window_new(GTK_WINDOW_POPUP))
{
+ g_signal_connect(m_dragIconWindow.get(), "expose-event", G_CALLBACK(dragIconWindowExposeEventCallback), this);
+}
+
+DragClient::~DragClient()
+{
+ g_signal_handlers_disconnect_by_func(m_dragIconWindow.get(), (gpointer) dragIconWindowExposeEventCallback, this);
}
void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*)
@@ -83,12 +97,38 @@ void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin,
// happen if a drag is followed very quickly by another click (like in the DRT).
webView->priv->previousClickTime = 0;
- if (image)
- gtk_drag_set_icon_pixbuf(context, image, eventPos.x() - dragImageOrigin.x(), eventPos.y() - dragImageOrigin.y());
- else
+ // This strategy originally comes from Chromium:
+ // src/chrome/browser/gtk/tab_contents_drag_source.cc
+ if (image) {
+ m_dragImage = image;
+ IntSize imageSize(cairo_image_surface_get_width(image), cairo_image_surface_get_height(image));
+ gtk_window_resize(GTK_WINDOW(m_dragIconWindow.get()), imageSize.width(), imageSize.height());
+
+ if (!gtk_widget_get_realized(m_dragIconWindow.get())) {
+ GdkScreen* screen = gtk_widget_get_screen(m_dragIconWindow.get());
+ GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen);
+ if (rgba)
+ gtk_widget_set_colormap(m_dragIconWindow.get(), rgba);
+ }
+
+ IntSize origin = eventPos - dragImageOrigin;
+ gtk_drag_set_icon_widget(context, m_dragIconWindow.get(),
+ origin.width(), origin.height());
+ } else
gtk_drag_set_icon_default(context);
}
+void DragClient::dragIconWindowExposeEvent(GtkWidget* widget, GdkEventExpose* event)
+{
+ PlatformRefPtr<cairo_t> context = adoptPlatformRef(gdk_cairo_create(event->window));
+ cairo_rectangle(context.get(), 0, 0,
+ cairo_image_surface_get_width(m_dragImage.get()),
+ cairo_image_surface_get_height(m_dragImage.get()));
+ cairo_set_operator(context.get(), CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface(context.get(), m_dragImage.get(), 0, 0);
+ cairo_fill(context.get());
+}
+
DragImageRef DragClient::createDragImageForLink(KURL&, const String&, Frame*)
{
notImplemented();
diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.h b/WebKit/gtk/WebCoreSupport/DragClientGtk.h
index 514852e..2ab7e2d 100644
--- a/WebKit/gtk/WebCoreSupport/DragClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.h
@@ -31,6 +31,8 @@
#define DragClientGtk_h
#include "DragClient.h"
+#include "GRefPtr.h"
+#include "PlatformRefPtrCairo.h"
typedef struct _WebKitWebView WebKitWebView;
@@ -39,6 +41,7 @@ namespace WebKit {
class DragClient : public WebCore::DragClient {
public:
DragClient(WebKitWebView*);
+ ~DragClient();
virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
@@ -51,9 +54,13 @@ namespace WebKit {
virtual void dragControllerDestroyed();
+ void dragIconWindowExposeEvent(GtkWidget*, GdkEventExpose*);
+
private:
WebKitWebView* m_webView;
WebCore::IntPoint m_startPos;
+ PlatformRefPtr<GtkWidget> m_dragIconWindow;
+ PlatformRefPtr<cairo_surface_t> m_dragImage;
};
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list