Changeset 58885 in webkit
- Timestamp:
- May 6, 2010 9:32:42 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r58878 r58885 1 2010-05-06 Martin Robinson <mrobinson@webkit.org> 2 3 Reviewed by Gustavo Noronha Silva. 4 5 [GTK] Enable DOM clipboard and drag-and-drop access 6 https://bugs.webkit.org/show_bug.cgi?id=30623 7 8 Convert dragging portion of drag-and-drop to use DataObjectGtk. 9 10 * wtf/gobject/GRefPtr.h: Add forward declarations for GObject functions. 11 1 12 2010-05-06 Steve Block <steveblock@google.com> 2 13 -
trunk/JavaScriptCore/wtf/gobject/GRefPtr.h
r55149 r58885 28 28 29 29 typedef struct _GHashTable GHashTable; 30 typedef void* gpointer; 31 extern "C" void g_object_unref(gpointer object); 32 extern "C" gpointer g_object_ref_sink(gpointer object); 30 33 31 34 namespace WTF { -
trunk/WebCore/ChangeLog
r58884 r58885 1 2010-05-06 Martin Robinson <mrobinson@webkit.org> 2 3 Reviewed by Gustavo Noronha Silva. 4 5 [GTK] Enable DOM clipboard and drag-and-drop access 6 https://bugs.webkit.org/show_bug.cgi?id=30623 7 8 Convert dragging portion of drag-and-drop to use DataObjectGtk. 9 10 No new tests, because functionality has not changed. 11 12 * page/gtk/EventHandlerGtk.cpp: 13 (WebCore::EventHandler::createDraggingClipboard): Pass the DataObjectGtk as a parameter here. 14 * platform/gtk/ClipboardGtk.h: 15 (WebCore::ClipboardGtk::create): Take the DataObject as a parameter instead of creating it here. 16 (WebCore::ClipboardGtk::helper): Added. 17 (WebCore::ClipboardGtk::dataObject): Added. 18 * platform/gtk/PasteboardHelper.h: Make targetListForDataObject a public method. 19 1 20 2010-05-06 Pavel Feldman <pfeldman@chromium.org> 2 21 -
trunk/WebCore/page/gtk/EventHandlerGtk.cpp
r48735 r58885 97 97 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const 98 98 { 99 return ClipboardGtk::create(ClipboardWritable, true);99 return ClipboardGtk::create(ClipboardWritable, DataObjectGtk::create(), true); 100 100 } 101 101 -
trunk/WebCore/platform/gtk/ClipboardGtk.h
r58470 r58885 46 46 } 47 47 48 static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, bool isForDragging)48 static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, PassRefPtr<DataObjectGtk> dataObject, bool isForDragging) 49 49 { 50 return adoptRef(new ClipboardGtk(policy, DataObjectGtk::create(), isForDragging));50 return adoptRef(new ClipboardGtk(policy, dataObject, isForDragging)); 51 51 } 52 52 virtual ~ClipboardGtk(); … … 74 74 virtual bool hasData(); 75 75 76 PasteboardHelper* helper() { return m_helper; } 77 PassRefPtr<DataObjectGtk> dataObject() { return m_dataObject; } 78 76 79 private: 77 80 ClipboardGtk(ClipboardAccessPolicy, GtkClipboard*); -
trunk/WebCore/platform/gtk/PasteboardHelper.h
r58470 r58885 3 3 * Copyright (C) 2009 Holger Hans Peter Freyther 4 4 * Copyright (C) 2010 Martin Robinson <mrobinson@webkit.org> 5 * Copyright (C) 2010 Igalia S.L. 5 6 * All rights reserved. 6 7 * … … 50 51 GtkClipboard* getPrimarySelectionClipboard(Frame*) const; 51 52 GtkTargetList* targetList() const; 53 GtkTargetList* targetListForDataObject(DataObjectGtk*); 52 54 void fillSelectionData(GtkSelectionData*, guint, DataObjectGtk*); 53 55 void writeClipboardContents(GtkClipboard*, GClosure* closure = 0); … … 63 65 private: 64 66 GtkTargetList* m_targetList; 65 GtkTargetList* targetListForDataObject(DataObjectGtk*);66 67 }; 67 68 -
trunk/WebKit/gtk/ChangeLog
r58703 r58885 1 2010-05-06 Martin Robinson <mrobinson@webkit.org> 2 3 Reviewed by Gustavo Noronha Silva. 4 5 [GTK] Enable DOM clipboard and drag-and-drop access 6 https://bugs.webkit.org/show_bug.cgi?id=30623 7 8 Convert dragging portion of drag-and-drop to use DataObjectGtk. 9 10 * WebCoreSupport/DragClientGtk.cpp: 11 (WebKit::DragClient::willPerformDragDestinationAction): Remove the notImplemented. It is implemented, it's just a no-op. 12 (WebKit::DragClient::startDrag): Start the drag context via the ClipboardGtk and PasteboardHelper now. 13 * WebCoreSupport/DragClientGtk.h: Small style fix. 14 * webkit/webkitprivate.h: Add a HashMap of contexts and DataObjects here to to represent all current drag operations. 15 * webkit/webkitwebview.cpp: 16 (webkit_web_view_dispose): Clear all data objects during disposal. 17 (webkit_web_view_drag_end): When a drag is over, just remove it from the map. 18 (webkit_web_view_drag_data_get): To get the drag data, just grab it from the DataObject. 19 1 20 2010-05-03 Abhishek Arya <inferno@chromium.org> 2 21 -
trunk/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
r47497 r58885 1 1 /* 2 * Copyright (C) Igalia S.L. 3 * 2 4 * This library is free software; you can redistribute it and/or 3 5 * modify it under the terms of the GNU Lesser General Public … … 18 20 #include "DragClientGtk.h" 19 21 22 #include "ClipboardGtk.h" 23 #include "DataObjectGtk.h" 20 24 #include "Document.h" 21 25 #include "Element.h" 22 26 #include "Frame.h" 27 #include "GRefPtrGtk.h" 23 28 #include "NotImplemented.h" 29 #include "PasteboardHelper.h" 24 30 #include "RenderObject.h" 31 #include "webkitprivate.h" 25 32 #include "webkitwebview.h" 26 33 … … 42 49 void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*) 43 50 { 44 notImplemented();45 51 } 46 52 … … 62 68 } 63 69 64 void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* , Frame* frame, bool linkDrag)70 void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool linkDrag) 65 71 { 66 Element* targetElement = frame->document()->elementFromPoint(m_startPos.x(), m_startPos.y()); 67 bool imageDrag = false; 68 69 if (targetElement) 70 imageDrag = targetElement->renderer()->isImage(); 71 72 GdkAtom textHtml = gdk_atom_intern_static_string("text/html"); 73 GdkAtom netscapeUrl = gdk_atom_intern_static_string("_NETSCAPE_URL"); 74 75 GtkTargetList* targetList = gtk_target_list_new(NULL, 0); 76 gtk_target_list_add(targetList, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML); 77 gtk_target_list_add_text_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT); 78 79 if (linkDrag || imageDrag) { 80 gtk_target_list_add(targetList, netscapeUrl, 0, WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL); 81 gtk_target_list_add_uri_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST); 82 } 83 84 if (imageDrag) 85 gtk_target_list_add_image_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE, false); 72 ClipboardGtk* clipboardGtk = reinterpret_cast<ClipboardGtk*>(clipboard); 86 73 87 74 GdkDragAction dragAction = GDK_ACTION_COPY; 88 if (linkDrag) { 89 dragAction = GDK_ACTION_LINK; 90 if (imageDrag) 91 dragAction = (GdkDragAction)(dragAction | GDK_ACTION_COPY); 92 } 75 if (linkDrag) 76 dragAction = (GdkDragAction) (dragAction | GDK_ACTION_LINK); 93 77 78 WebKitWebView* webView = webkit_web_frame_get_web_view(kit(frame)); 79 RefPtr<DataObjectGtk> dataObject = clipboardGtk->dataObject(); 80 81 GRefPtr<GtkTargetList> targetList(clipboardGtk->helper()->targetListForDataObject(dataObject.get())); 94 82 GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS); 95 83 reinterpret_cast<GdkEventButton*>(event)->window = gtk_widget_get_window(GTK_WIDGET(m_webView)); 96 84 reinterpret_cast<GdkEventButton*>(event)->time = GDK_CURRENT_TIME; 97 85 98 GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), 99 targetList, dragAction, 1, event); 100 g_object_ref(context); 86 GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView), targetList.get(), dragAction, 1, event); 87 webView->priv->draggingDataObjects.set(context, dataObject); 101 88 102 89 if (image) … … 104 91 else 105 92 gtk_drag_set_icon_default(context); 106 107 gtk_target_list_unref(targetList);108 93 } 109 94 -
trunk/WebKit/gtk/WebCoreSupport/DragClientGtk.h
r47243 r58885 52 52 virtual void dragControllerDestroyed(); 53 53 54 55 56 54 private: 55 WebKitWebView* m_webView; 56 WebCore::IntPoint m_startPos; 57 57 }; 58 58 } -
trunk/WebKit/gtk/webkit/webkitprivate.h
r57986 r58885 3 3 * Copyright (C) 2008 Jan Michael C. Alonzo 4 4 * Copyright (C) 2008 Collabora Ltd. 5 * Copyright (C) 2010 Igalia S.L. 5 6 * 6 7 * This library is free software; you can redistribute it and/or … … 47 48 #include "ArchiveResource.h" 48 49 #include "BackForwardList.h" 50 #include "DataObjectGtk.h" 49 51 #include <enchant.h> 50 52 #include "GOwnPtr.h" … … 150 152 GHashTable* subResources; 151 153 char* tooltipText; 154 155 HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects; 152 156 }; 153 157 -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r58703 r58885 1125 1125 } 1126 1126 1127 priv->draggingDataObjects.clear(); 1128 1127 1129 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); 1128 1130 } … … 1235 1237 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) 1236 1238 { 1237 g_object_unref(context); 1238 } 1239 1240 struct DNDContentsRequest 1241 { 1242 gint info; 1243 GtkSelectionData* dnd_selection_data; 1244 1245 gboolean is_url_label_request; 1246 gchar* url; 1247 }; 1248 1249 void clipboard_contents_received(GtkClipboard* clipboard, GtkSelectionData* selection_data, gpointer data) 1250 { 1251 DNDContentsRequest* contents_request = reinterpret_cast<DNDContentsRequest*>(data); 1252 1253 if (contents_request->is_url_label_request) { 1254 // We have received contents of the label clipboard. Use them to form 1255 // required structures. When formed, enhance the dnd's selection data 1256 // with them and return. 1257 1258 // If the label is empty, use the url itself. 1259 gchar* url_label = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); 1260 if (!url_label) 1261 url_label = g_strdup(contents_request->url); 1262 1263 gchar* data = 0; 1264 switch (contents_request->info) { 1265 case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: 1266 data = g_strdup_printf("%s\r\n%s\r\n", contents_request->url, url_label); 1267 break; 1268 case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: 1269 data = g_strdup_printf("%s\n%s", contents_request->url, url_label); 1270 break; 1271 } 1272 1273 if (data) { 1274 gtk_selection_data_set(contents_request->dnd_selection_data, 1275 contents_request->dnd_selection_data->target, 8, 1276 reinterpret_cast<const guchar*>(data), strlen(data)); 1277 g_free(data); 1278 } 1279 1280 g_free(url_label); 1281 g_free(contents_request->url); 1282 g_free(contents_request); 1283 1239 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); 1240 1241 // This might happen if a drag is still in progress after a WebKitWebView 1242 // is diposed and before it is finalized. 1243 if (!priv->draggingDataObjects.contains(context)) 1284 1244 return; 1285 } 1286 1287 switch (contents_request->info) { 1288 case WEBKIT_WEB_VIEW_TARGET_INFO_HTML: 1289 case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT: 1290 { 1291 gchar* data = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); 1292 if (data) { 1293 gtk_selection_data_set(contents_request->dnd_selection_data, 1294 contents_request->dnd_selection_data->target, 8, 1295 reinterpret_cast<const guchar*>(data), 1296 strlen(data)); 1297 g_free(data); 1298 } 1299 break; 1300 } 1301 case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE: 1302 { 1303 GdkPixbuf* pixbuf = gtk_selection_data_get_pixbuf(selection_data); 1304 if (pixbuf) { 1305 gtk_selection_data_set_pixbuf(contents_request->dnd_selection_data, pixbuf); 1306 g_object_unref(pixbuf); 1307 } 1308 break; 1309 } 1310 case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: 1311 case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: 1312 // URL's label is stored in another clipboard, so we store URL into 1313 // contents request, mark the latter as an url label request 1314 // and request for contents of the label clipboard. 1315 contents_request->is_url_label_request = TRUE; 1316 contents_request->url = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data)); 1317 1318 gtk_clipboard_request_contents(gtk_clipboard_get(gdk_atom_intern_static_string("WebKitClipboardUrlLabel")), 1319 selection_data->target, clipboard_contents_received, contents_request); 1320 break; 1321 } 1322 } 1323 1324 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_) 1325 { 1326 GdkAtom selection_atom = GDK_NONE; 1327 GdkAtom target_atom = selection_data->target; 1328 1329 switch (info) { 1330 case WEBKIT_WEB_VIEW_TARGET_INFO_HTML: 1331 selection_atom = gdk_atom_intern_static_string("WebKitClipboardHtml"); 1332 // HTML markup data is set as text, therefor, we need a text-like target atom 1333 target_atom = gdk_atom_intern_static_string("UTF8_STRING"); 1334 break; 1335 case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT: 1336 selection_atom = gdk_atom_intern_static_string("WebKitClipboardText"); 1337 break; 1338 case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE: 1339 selection_atom = gdk_atom_intern_static_string("WebKitClipboardImage"); 1340 break; 1341 case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: 1342 case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: 1343 selection_atom = gdk_atom_intern_static_string("WebKitClipboardUrl"); 1344 // We require URL and label, which are both stored in text format 1345 // and are needed to be retrieved as such. 1346 target_atom = gdk_atom_intern_static_string("UTF8_STRING"); 1347 break; 1348 } 1349 1350 DNDContentsRequest* contents_request = g_new(DNDContentsRequest, 1); 1351 contents_request->info = info; 1352 contents_request->is_url_label_request = FALSE; 1353 contents_request->dnd_selection_data = selection_data; 1354 1355 gtk_clipboard_request_contents(gtk_clipboard_get(selection_atom), target_atom, 1356 clipboard_contents_received, contents_request); 1245 1246 priv->draggingDataObjects.remove(context); 1247 } 1248 1249 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint) 1250 { 1251 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); 1252 1253 // This might happen if a drag is still in progress after a WebKitWebView 1254 // is diposed and before it is finalized. 1255 if (!priv->draggingDataObjects.contains(context)) 1256 return; 1257 1258 pasteboardHelperInstance()->fillSelectionData(selectionData, info, priv->draggingDataObjects.get(context).get()); 1357 1259 } 1358 1260
Note: See TracChangeset
for help on using the changeset viewer.