Changeset 97012 in webkit
- Timestamp:
- Oct 8, 2011 10:46:00 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 22 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r97009 r97012 1 2011-10-03 Carlos Garcia Campos <cgarcia@igalia.com> and Martin Robinson <mrobinson@igalia.com> 2 3 [GTK] Implement drag and drop support in WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=63706 5 6 Reviewed by Philippe Normand. 7 8 * platform/DragData.h: 9 * platform/gtk/DataObjectGtk.cpp: 10 (WebCore::DataObjectGtk::text): Mark as const. 11 (WebCore::DataObjectGtk::markup): Ditto. 12 (WebCore::DataObjectGtk::urlLabel): Ditto. 13 * platform/gtk/DataObjectGtk.h: Remove unused member 14 m_dragContext. 15 (WebCore::DataObjectGtk::url): Mark as const. 16 (WebCore::DataObjectGtk::uriList): Ditto. 17 (WebCore::DataObjectGtk::filenames): Ditto. 18 (WebCore::DataObjectGtk::image): Ditto. 19 (WebCore::DataObjectGtk::hasText): Ditto. 20 (WebCore::DataObjectGtk::hasMarkup): Ditto. 21 (WebCore::DataObjectGtk::hasURIList): Ditto. 22 (WebCore::DataObjectGtk::hasURL): Ditto. 23 (WebCore::DataObjectGtk::hasFilenames): Ditto. 24 (WebCore::DataObjectGtk::hasImage): Ditto. 25 * platform/gtk/DragIcon.cpp: Added. A helper which takes care of 26 creating a transparent drag window for drags. 27 * platform/gtk/DragIcon.h: Added. 28 1 29 2011-10-08 Abhishek Arya <inferno@chromium.org> 2 30 -
trunk/Source/WebCore/GNUmakefile.list.am
r96966 r97012 4009 4009 Source/WebCore/platform/gtk/DataObjectGtk.h \ 4010 4010 Source/WebCore/platform/gtk/DragDataGtk.cpp \ 4011 Source/WebCore/platform/gtk/DragIcon.cpp \ 4012 Source/WebCore/platform/gtk/DragIcon.h \ 4011 4013 Source/WebCore/platform/gtk/DragImageGtk.cpp \ 4012 4014 Source/WebCore/platform/gtk/EventLoopGtk.cpp \ -
trunk/Source/WebCore/platform/DragData.h
r95922 r97012 121 121 #endif 122 122 123 #if PLATFORM(QT) 123 #if PLATFORM(QT) || PLATFORM(GTK) 124 124 // This constructor should used only by WebKit2 IPC because DragData 125 125 // is initialized by the decoder and not in the constructor. -
trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp
r95901 r97012 34 34 } 35 35 36 String DataObjectGtk::text() 36 String DataObjectGtk::text() const 37 37 { 38 38 if (m_range) … … 41 41 } 42 42 43 String DataObjectGtk::markup() 43 String DataObjectGtk::markup() const 44 44 { 45 45 if (m_range) … … 134 134 } 135 135 136 String DataObjectGtk::urlLabel() 136 String DataObjectGtk::urlLabel() const 137 137 { 138 138 if (hasText()) -
trunk/Source/WebCore/platform/gtk/DataObjectGtk.h
r95901 r97012 37 37 } 38 38 39 const KURL& url() { return m_url; }40 const String& uriList() { return m_uriList; }41 const Vector<String>& filenames() { return m_filenames; }42 GdkPixbuf* image() { return m_image.get(); }39 const KURL& url() const { return m_url; } 40 const String& uriList() const { return m_uriList; } 41 const Vector<String>& filenames() const { return m_filenames; } 42 GdkPixbuf* image() const { return m_image.get(); } 43 43 void setRange(PassRefPtr<Range> newRange) { m_range = newRange; } 44 44 void setImage(GdkPixbuf* newImage) { m_image = newImage; } 45 void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; }46 45 void setURL(const KURL&, const String&); 47 bool hasText() { return m_range || !m_text.isEmpty(); }48 bool hasMarkup() { return m_range || !m_markup.isEmpty(); }49 bool hasURIList() { return !m_uriList.isEmpty(); }50 bool hasURL() { return !m_url.isEmpty() && m_url.isValid(); }51 bool hasFilenames() { return !m_filenames.isEmpty(); }52 bool hasImage() { return m_image; }46 bool hasText() const { return m_range || !m_text.isEmpty(); } 47 bool hasMarkup() const { return m_range || !m_markup.isEmpty(); } 48 bool hasURIList() const { return !m_uriList.isEmpty(); } 49 bool hasURL() const { return !m_url.isEmpty() && m_url.isValid(); } 50 bool hasFilenames() const { return !m_filenames.isEmpty(); } 51 bool hasImage() const { return m_image; } 53 52 void clearURIList() { m_uriList = ""; } 54 53 void clearURL() { m_url = KURL(); } 55 54 void clearImage() { m_image = 0; } 56 GdkDragContext* dragContext() { return m_dragContext.get(); }57 55 58 String text() ;59 String markup() ;56 String text() const; 57 String markup() const; 60 58 void setText(const String&); 61 59 void setMarkup(const String&); 62 60 void setURIList(const String&); 63 String urlLabel() ;61 String urlLabel() const; 64 62 void clear(); 65 63 void clearText(); … … 75 73 Vector<String> m_filenames; 76 74 GRefPtr<GdkPixbuf> m_image; 77 GRefPtr<GdkDragContext> m_dragContext;78 75 RefPtr<Range> m_range; 79 76 }; -
trunk/Source/WebCore/platform/gtk/DragIcon.h
r97011 r97012 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.4 2 * Copyright (C) 2011 Igalia S.L. 5 3 * … … 26 24 */ 27 25 28 #ifndef WebKitWebViewBasePrivate_h29 #define WebKitWebViewBasePrivate_h26 #ifndef DragIcon_h 27 #define DragIcon_h 30 28 31 #include "WebKitWebViewBase.h" 32 #include "WebPageProxy.h" 33 #include <WebKit2/WebKit2.h> 29 #include "IntPoint.h" 30 #include <RefPtrCairo.h> 34 31 35 using namespace WebKit; 32 namespace WebCore { 36 33 37 G_BEGIN_DECLS 34 class DragIcon { 35 public: 36 DragIcon(); 37 virtual ~DragIcon(); 38 38 39 WebKitWebViewBase* webkitWebViewBaseCreate(WebContext*, WebPageGroup*); 39 void draw(cairo_t*); 40 void setImage(cairo_surface_t*); 41 void useForDrag(GdkDragContext*); 42 void useForDrag(GdkDragContext*, const IntPoint& hotspot); 40 43 41 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*); 44 private: 45 GtkWidget* m_window; 46 RefPtr<cairo_surface_t> m_image; 47 IntSize m_imageSize; 48 }; 42 49 43 WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*); 50 } 44 51 45 void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef); 46 47 void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*); 48 49 void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*); 50 51 G_END_DECLS 52 53 #endif // WebKitWebViewBasePrivate_h 52 #endif // DragIcon_h -
trunk/Source/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
r96299 r97012 43 43 namespace WebKit { 44 44 45 #ifdef GTK_API_VERSION_246 static gboolean dragIconWindowDrawEventCallback(GtkWidget* widget, GdkEventExpose* event, DragClient* client)47 {48 RefPtr<cairo_t> context = adoptRef(gdk_cairo_create(event->window));49 client->drawDragIconWindow(widget, context.get());50 return TRUE;51 }52 #else53 static gboolean dragIconWindowDrawEventCallback(GtkWidget* widget, cairo_t* context, DragClient* client)54 {55 if (!gdk_cairo_get_clip_rectangle(context, 0))56 return FALSE;57 client->drawDragIconWindow(widget, context);58 return TRUE;59 }60 #endif // GTK_API_VERSION_261 62 45 DragClient::DragClient(WebKitWebView* webView) 63 46 : m_webView(webView) 64 47 , m_startPos(0, 0) 65 , m_dragIconWindow(gtk_window_new(GTK_WINDOW_POPUP))66 48 { 67 #ifdef GTK_API_VERSION_268 g_signal_connect(m_dragIconWindow, "expose-event", G_CALLBACK(dragIconWindowDrawEventCallback), this);69 #else70 g_signal_connect(m_dragIconWindow, "draw", G_CALLBACK(dragIconWindowDrawEventCallback), this);71 #endif72 49 } 73 50 74 51 DragClient::~DragClient() 75 52 { 76 gtk_widget_destroy(m_dragIconWindow);77 53 } 78 54 … … 114 90 webView->priv->clickCounter.reset(); 115 91 116 // This strategy originally comes from Chromium:117 // src/chrome/browser/gtk/tab_contents_drag_source.cc118 92 if (image) { 119 m_dragImage = image; 120 IntSize imageSize(cairo_image_surface_get_width(image), cairo_image_surface_get_height(image)); 121 gtk_window_resize(GTK_WINDOW(m_dragIconWindow), imageSize.width(), imageSize.height()); 122 123 if (!gtk_widget_get_realized(m_dragIconWindow)) { 124 GdkScreen* screen = gtk_widget_get_screen(m_dragIconWindow); 125 #ifdef GTK_API_VERSION_2 126 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); 127 if (rgba) 128 gtk_widget_set_colormap(m_dragIconWindow, rgba); 129 #else 130 GdkVisual* visual = gdk_screen_get_rgba_visual(screen); 131 if (!visual) 132 visual = gdk_screen_get_system_visual(screen); 133 gtk_widget_set_visual(m_dragIconWindow, visual); 134 #endif // GTK_API_VERSION_2 135 } 136 137 IntSize origin = eventPos - dragImageOrigin; 138 gtk_drag_set_icon_widget(context, m_dragIconWindow, 139 origin.width(), origin.height()); 93 m_dragIcon.setImage(image); 94 m_dragIcon.useForDrag(context, IntPoint(eventPos - dragImageOrigin)); 140 95 } else 141 96 gtk_drag_set_icon_default(context); 142 }143 144 void DragClient::drawDragIconWindow(GtkWidget* widget, cairo_t* context)145 {146 cairo_rectangle(context, 0, 0,147 cairo_image_surface_get_width(m_dragImage.get()),148 cairo_image_surface_get_height(m_dragImage.get()));149 cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);150 cairo_set_source_surface(context, m_dragImage.get(), 0, 0);151 cairo_fill(context);152 97 } 153 98 -
trunk/Source/WebKit/gtk/WebCoreSupport/DragClientGtk.h
r77870 r97012 32 32 33 33 #include "DragClient.h" 34 #include "DragIcon.h" 34 35 #include "GRefPtr.h" 35 #include "RefPtrCairo.h"36 36 37 37 typedef struct _WebKitWebView WebKitWebView; … … 54 54 virtual void dragControllerDestroyed(); 55 55 56 void drawDragIconWindow(GtkWidget*, cairo_t*);57 58 56 private: 59 57 WebKitWebView* m_webView; 60 58 WebCore::IntPoint m_startPos; 61 GtkWidget* m_dragIconWindow; 62 RefPtr<cairo_surface_t> m_dragImage; 59 WebCore::DragIcon m_dragIcon; 63 60 }; 64 61 } -
trunk/Source/WebKit2/ChangeLog
r97010 r97012 1 2011-10-03 Carlos Garcia Campos <cgarcia@igalia.com> and Martin Robinson <mrobinson@igalia.com> 2 3 [GTK] Implement drag and drop support in WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=63706 5 6 Reviewed by Philippe Normand. 7 8 * GNUmakefile.am: Add new files to compilation. 9 * Shared/gtk/ArgumentCodersGtk.cpp: Added. 10 (CoreIPC::encodeImage): Encode a GdkPixbuf. 11 (CoreIPC::decodeImage): Decode a GdkPixbuf. 12 (CoreIPC::encodeDataObject): Encode a DataObjectGtk. 13 (CoreIPC::decodeDataObject): Decode a DataObjectGtk. 14 (CoreIPC::::encode): Encode DragData. 15 (CoreIPC::::decode): Decode DragData. 16 * Shared/gtk/ArgumentCodersGtk.h: 17 * UIProcess/API/gtk/PageClientImpl.cpp: 18 (WebKit::PageClientImpl::startDrag): 19 * UIProcess/API/gtk/PageClientImpl.h: 20 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 21 (webkit_web_view_base_init): Set the view as a potential drop destination. 22 (webkitWebViewBaseDragDataGet): Added, delegate to GtkDragAndDropHelper. 23 (webkitWebViewBaseDragEnd): Ditto. 24 (webkitWebViewBaseDragDataReceived): Ditto. 25 (webkitWebViewBaseDragEnter): Ditto. 26 (webkitWebViewBaseDragMotion): Ditto. 27 (doDragLeaveLater): Ditto. 28 (webkitWebViewBaseDragLeave): Ditto. 29 (webkitWebViewBaseDragDrop): Ditto. 30 (webkit_web_view_base_class_init): Override GtkWidget drag and drop methods. 31 (webkitWebViewBaseStartDrag): Calls gtk_drag_begin() to start a drag operation. 32 * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Add webkitWebViewBaseStartDrag(). 33 * UIProcess/PageClient.h: Add startDrag(). 34 * UIProcess/WebPageProxy.cpp: 35 (WebKit::WebPageProxy::performDragControllerAction): Share the Qt version. 36 * UIProcess/WebPageProxy.h: 37 * UIProcess/WebPageProxy.messages.in: 38 * WebProcess/WebCoreSupport/WebDragClient.cpp: 39 * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp: Added. 40 * WebProcess/WebPage/WebPage.cpp: Add drag support for GTK+. 41 * WebProcess/WebPage/WebPage.h: Ditto. 42 * WebProcess/WebPage/WebPage.messages.in: Ditto. 43 1 44 2011-10-08 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> 2 45 -
trunk/Source/WebKit2/GNUmakefile.am
r96821 r97012 284 284 Source/WebKit2/Shared/cairo/LayerTreeContextCairo.cpp \ 285 285 Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp \ 286 Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h \ 287 Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp \ 286 288 Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \ 287 289 Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp \ … … 750 752 Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp \ 751 753 Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp \ 754 Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp \ 752 755 Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp \ 753 756 Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp \ -
trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
r97011 r97012 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.4 2 * Copyright (C) 2011 Igalia S.L. 5 3 * … … 26 24 */ 27 25 28 #ifndef WebKitWebViewBasePrivate_h29 #define WebKitWebViewBasePrivate_h26 #ifndef ArgumentCodersGtk_h 27 #define ArgumentCodersGtk_h 30 28 31 #include "WebKitWebViewBase.h" 32 #include "WebPageProxy.h" 33 #include <WebKit2/WebKit2.h> 29 #include "ArgumentCoders.h" 34 30 35 using namespace WebKit; 31 namespace WebCore { 32 class DataObjectGtk; 33 class DragData; 34 } 36 35 37 G_BEGIN_DECLS 36 namespace CoreIPC { 38 37 39 WebKitWebViewBase* webkitWebViewBaseCreate(WebContext*, WebPageGroup*); 38 template<> struct ArgumentCoder<WebCore::DragData> { 39 static void encode(ArgumentEncoder*, const WebCore::DragData&); 40 static bool decode(ArgumentDecoder*, WebCore::DragData&); 41 }; 40 42 41 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*); 43 } // namespace CoreIPC 42 44 43 WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*); 44 45 void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef); 46 47 void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*); 48 49 void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*); 50 51 G_END_DECLS 52 53 #endif // WebKitWebViewBasePrivate_h 45 #endif // ArgumentCodersGtk_h -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r95901 r97012 286 286 } 287 287 288 void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) 289 { 290 webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage); 291 } 292 288 293 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
r95901 r97012 88 88 virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned); 89 89 virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned); 90 virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage); 90 91 91 92 #if USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r96680 r97012 26 26 #include "WebKitPrivate.h" 27 27 #include "WebPageProxy.h" 28 #include <WebCore/DragIcon.h> 28 29 #include <WebKit2/WKBase.h> 29 30 #include <WebKit2/WKRetainPtr.h> -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
r95901 r97012 29 29 #include "WebKitWebViewBase.h" 30 30 31 #include "ClipboardGtk.h" 32 #include "ClipboardUtilitiesGtk.h" 33 #include "DataObjectGtk.h" 34 #include "DragData.h" 31 35 #include "DrawingAreaProxyImpl.h" 32 36 #include "GOwnPtrGtk.h" 33 37 #include "GtkClickCounter.h" 38 #include "GtkUtilities.h" 34 39 #include "GtkVersioning.h" 35 40 #include "NativeWebKeyboardEvent.h" … … 38 43 #include "NotImplemented.h" 39 44 #include "PageClientImpl.h" 45 #include "PasteboardHelper.h" 40 46 #include "RefPtrCairo.h" 41 47 #include "WebContext.h" … … 43 49 #include "WebKitWebViewBasePrivate.h" 44 50 #include "WebPageProxy.h" 51 #include <WebCore/DragIcon.h> 52 #include <WebCore/GtkDragAndDropHelper.h> 53 #include <WebCore/RefPtrCairo.h> 45 54 #include <WebCore/Region.h> 46 55 #include <WebKit2/WKContext.h> … … 58 67 GtkClickCounter clickCounter; 59 68 CString tooltipText; 69 GtkDragAndDropHelper dragAndDropHelper; 70 DragIcon dragIcon; 60 71 }; 61 72 … … 133 144 priv->shouldForwardNextKeyEvent = FALSE; 134 145 135 gtk_widget_set_double_buffered(GTK_WIDGET(webkitWebViewBase), FALSE); 136 gtk_widget_set_can_focus(GTK_WIDGET(webkitWebViewBase), TRUE); 146 GtkWidget* viewWidget = GTK_WIDGET(webkitWebViewBase); 147 gtk_widget_set_double_buffered(viewWidget, FALSE); 148 gtk_widget_set_can_focus(viewWidget, TRUE); 137 149 priv->imContext = gtk_im_multicontext_new(); 138 150 139 priv->pageClient = PageClientImpl::create(GTK_WIDGET(webkitWebViewBase)); 151 priv->pageClient = PageClientImpl::create(viewWidget); 152 153 priv->dragAndDropHelper.setWidget(viewWidget); 154 155 gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0, 156 static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); 157 gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList()); 140 158 } 141 159 … … 291 309 // receives a hit test result. 292 310 gtk_tooltip_set_text(tooltip, priv->tooltipText.data()); 311 return TRUE; 312 } 313 314 static void webkitWebViewBaseDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint time) 315 { 316 WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info); 317 } 318 319 static void webkitWebViewBaseDragEnd(GtkWidget* widget, GdkDragContext* context) 320 { 321 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 322 if (!webViewBase->priv->dragAndDropHelper.handleDragEnd(context)) 323 return; 324 325 GdkDevice* device = gdk_drag_context_get_device(context); 326 int x = 0, y = 0; 327 gdk_device_get_window_at_position(device, &x, &y); 328 int xRoot = 0, yRoot = 0; 329 gdk_device_get_position(device, 0, &xRoot, &yRoot); 330 webViewBase->priv->pageProxy->dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), 331 gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context))); 332 } 333 334 static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time) 335 { 336 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 337 OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info)); 338 if (!dragData) 339 return; 340 341 webViewBase->priv->pageProxy->resetDragOperation(); 342 webViewBase->priv->pageProxy->dragEntered(dragData.get()); 343 DragOperation operation = webViewBase->priv->pageProxy->dragOperation(); 344 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 345 } 346 347 static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) 348 { 349 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 350 OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragMotion(context, IntPoint(x, y), time)); 351 if (!dragData) 352 return TRUE; 353 354 webViewBase->priv->pageProxy->dragUpdated(dragData.get()); 355 DragOperation operation = webViewBase->priv->pageProxy->dragOperation(); 356 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 357 return TRUE; 358 } 359 360 static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened) 361 { 362 // Don't call dragExited if we have just received a drag-drop signal. This 363 // happens in the case of a successful drop onto the view. 364 if (dropHappened) 365 return; 366 367 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 368 webViewBase->priv->pageProxy->dragExited(dragData); 369 webViewBase->priv->pageProxy->resetDragOperation(); 370 } 371 372 static void webkitWebViewBaseDragLeave(GtkWidget* widget, GdkDragContext* context, guint time) 373 { 374 WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback); 375 } 376 377 static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) 378 { 379 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); 380 OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragDrop(context, IntPoint(x, y))); 381 if (!dragData) 382 return FALSE; 383 384 SandboxExtension::Handle handle; 385 webViewBase->priv->pageProxy->performDrag(dragData.get(), String(), handle); 386 gtk_drag_finish(context, TRUE, FALSE, time); 293 387 return TRUE; 294 388 } … … 309 403 widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent; 310 404 widgetClass->query_tooltip = webkitWebViewBaseQueryTooltip; 405 widgetClass->drag_end = webkitWebViewBaseDragEnd; 406 widgetClass->drag_data_get = webkitWebViewBaseDragDataGet; 407 widgetClass->drag_motion = webkitWebViewBaseDragMotion; 408 widgetClass->drag_leave = webkitWebViewBaseDragLeave; 409 widgetClass->drag_drop = webkitWebViewBaseDragDrop; 410 widgetClass->drag_data_received = webkitWebViewBaseDragDataReceived; 311 411 312 412 GObjectClass* gobjectClass = G_OBJECT_CLASS(webkitWebViewBaseClass); … … 356 456 } 357 457 458 void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) 459 { 460 WebKitWebViewBasePrivate* priv = webViewBase->priv; 461 462 RefPtr<DataObjectGtk> dataObject(dragData.platformData()); 463 GRefPtr<GtkTargetList> targetList(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get())); 464 GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event()); 465 GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(webViewBase), 466 targetList.get(), 467 dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()), 468 1, /* button */ 469 currentEvent.get()); 470 priv->dragAndDropHelper.startedDrag(context, dataObject.get()); 471 472 473 // A drag starting should prevent a double-click from happening. This might 474 // happen if a drag is followed very quickly by another click (like in the DRT). 475 priv->clickCounter.reset(); 476 477 if (dragImage) { 478 RefPtr<cairo_surface_t> image(dragImage->createCairoSurface()); 479 priv->dragIcon.setImage(image.get()); 480 priv->dragIcon.useForDrag(context); 481 } else 482 gtk_drag_set_icon_default(context); 483 } 484 358 485 void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase* webkitWebViewBase) 359 486 { -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
r95901 r97012 49 49 void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*); 50 50 51 void webkitWebViewBaseStartDrag(WebKitWebViewBase*, const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage); 52 51 53 G_END_DECLS 52 54 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r95901 r97012 104 104 virtual void didChangeContentsSize(const WebCore::IntSize&) = 0; 105 105 virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0; 106 #endif 106 107 108 #if PLATFORM(QT) || PLATFORM(GTK) 107 109 virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) = 0; 108 110 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r97000 r97012 84 84 #endif 85 85 86 #if PLATFORM(GTK) 87 #include "ArgumentCodersGtk.h" 88 #endif 89 86 90 #ifndef NDEBUG 87 91 #include <wtf/RefCountedLeakCounter.h> … … 790 794 process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), 791 795 dragData->draggingSourceOperationMask(), dragData->dragDataMap(), dragData->flags()), m_pageID); 792 #elif PLATFORM(QT) 796 #elif PLATFORM(QT) || PLATFORM(GTK) 793 797 process()->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID); 794 798 #else … … 802 806 } 803 807 804 #if PLATFORM(QT) 808 #if PLATFORM(QT) || PLATFORM(GTK) 805 809 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle) 806 810 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r96645 r97012 468 468 void startDragDrop(const WebCore::IntPoint& imagePoint, const WebCore::IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, uint64_t fileSize, const String& pathname, const SharedMemory::Handle& fileContentHandle, const WebCore::IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag); 469 469 #endif 470 #if PLATFORM(QT) 470 #if PLATFORM(QT) || PLATFORM(GTK) 471 471 void startDrag(const WebCore::DragData&, const ShareableBitmap::Handle& dragImage); 472 472 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r96413 r97012 213 213 StartDragDrop(WebCore::IntPoint imagePoint, WebCore::IntPoint dragPoint, uint64_t okEffect, HashMap<UINT,Vector<String> > dataMap, uint64_t fileSize, String pathname, WebKit::SharedMemory::Handle fileContentHandle, WebCore::IntSize dragImageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag) 214 214 #endif 215 #if PLATFORM(QT) 215 #if PLATFORM(QT) || PLATFORM(GTK) 216 216 StartDrag(WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage) 217 217 #endif -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
r95901 r97012 53 53 } 54 54 55 #if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(QT) 55 #if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(QT) && !PLATFORM(GTK) 56 56 void WebDragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) 57 57 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r96880 r97012 1787 1787 } 1788 1788 1789 #elif PLATFORM(QT) 1789 #elif PLATFORM(QT) || PLATFORM(GTK) 1790 1790 void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dragData) 1791 1791 { 1792 1792 if (!m_page) { 1793 1793 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone)); 1794 #if PLATFORM(QT) 1794 1795 QMimeData* data = const_cast<QMimeData*>(dragData.platformData()); 1796 #elif PLATFORM(GTK) 1797 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData()); 1798 #endif 1795 1799 delete data; 1796 1800 return; … … 1819 1823 } 1820 1824 // DragData does not delete its platformData so we need to do that here. 1825 #if PLATFORM(QT) 1821 1826 QMimeData* data = const_cast<QMimeData*>(dragData.platformData()); 1827 #elif PLATFORM(GTK) 1828 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData()); 1829 #endif 1822 1830 delete data; 1823 1831 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r96740 r97012 62 62 #endif 63 63 64 #if PLATFORM(GTK) 65 #include "ArgumentCodersGtk.h" 66 #endif 67 64 68 #if ENABLE(TOUCH_EVENTS) 65 69 #include <WebCore/PlatformTouchEvent.h> … … 397 401 #if PLATFORM(WIN) 398 402 void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap&, uint32_t flags); 399 #elif PLATFORM(QT) 403 #elif PLATFORM(QT) || PLATFORM(GTK) 400 404 void performDragControllerAction(uint64_t action, WebCore::DragData); 401 405 #else -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r96645 r97012 129 129 PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, HashMap<UINT,Vector<String>> dataMap, uint32_t flags) 130 130 #endif 131 #if PLATFORM(QT) 131 #if PLATFORM(QT) || PLATFORM(GTK) 132 132 PerformDragControllerAction(uint64_t action, WebCore::DragData dragData) 133 133 #endif 134 #if !PLATFORM(WIN) && !PLATFORM(QT) 134 #if !PLATFORM(WIN) && !PLATFORM(QT) && !PLATFORM(GTK) 135 135 PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle) 136 136 #endif
Note: See TracChangeset
for help on using the changeset viewer.