[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
eric at webkit.org
eric at webkit.org
Wed Jan 20 22:24:16 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit d2059433f5267c6cf53d5073932eadf27ad666cc
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jan 14 14:21:52 2010 +0000
2010-01-14 Martin Robinson <martin.james.robinson at gmail.com>
Reviewed by Xan Lopez.
[GTK] Enable DOM clipboard and drag-and-drop access
https://bugs.webkit.org/show_bug.cgi?id=30623
Add DataObjectGtk, a container for pasteboard and drag-and-drop data.
No new tests, because functionality has not changed.
* GNUmakefile.am:
* platform/gtk/DataObjectGtk.cpp: Added.
(WebCore::DataObjectGtk::text):
(WebCore::DataObjectGtk::markup):
(WebCore::DataObjectGtk::setText):
(WebCore::DataObjectGtk::setMarkup):
(WebCore::DataObjectGtk::files):
(WebCore::DataObjectGtk::url):
(WebCore::DataObjectGtk::urlLabel):
(WebCore::DataObjectGtk::hasURL):
(WebCore::DataObjectGtk::clear):
(WebCore::DataObjectGtk::forClipboard):
* platform/gtk/DataObjectGtk.h: Added.
(WebCore::DataObjectGtk::create):
(WebCore::DataObjectGtk::uriList):
(WebCore::DataObjectGtk::image):
(WebCore::DataObjectGtk::setRange):
(WebCore::DataObjectGtk::setURIList):
(WebCore::DataObjectGtk::setImage):
(WebCore::DataObjectGtk::setDragContext):
(WebCore::DataObjectGtk::hasText):
(WebCore::DataObjectGtk::hasMarkup):
(WebCore::DataObjectGtk::hasURIList):
(WebCore::DataObjectGtk::hasImage):
(WebCore::DataObjectGtk::dragContext):
2010-01-14 Martin Robinson <martin.james.robinson at gmail.com>
Reviewed by Xan Lopez.
[GTK] Enable DOM clipboard and drag-and-drop access
https://bugs.webkit.org/show_bug.cgi?id=30623
Use DataObjectGtk when setting and clearing pasteboard data on
the GDK_SELECTION_PRIMARY clipboard.
* WebCoreSupport/EditorClientGtk.cpp:
(WebKit::EditorClient::respondToChangedSelection):
(WebKit::EditorClient::EditorClient):
* WebCoreSupport/EditorClientGtk.h:
* WebCoreSupport/PasteboardHelperGtk.cpp:
(WebKit::fillSelectionData):
(WebKit::targetListForDataObject):
(WebKit::getClipboardContentsCallback):
(WebKit::clearClipboardContentsCallback):
(WebKit::PasteboardHelperGtk::writeClipboardContents):
* WebCoreSupport/PasteboardHelperGtk.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e0e8d36..67cac5d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-01-14 Martin Robinson <martin.james.robinson at gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Enable DOM clipboard and drag-and-drop access
+ https://bugs.webkit.org/show_bug.cgi?id=30623
+
+ Add DataObjectGtk, a container for pasteboard and drag-and-drop data.
+
+ No new tests, because functionality has not changed.
+
+ * GNUmakefile.am:
+ * platform/gtk/DataObjectGtk.cpp: Added.
+ (WebCore::DataObjectGtk::text):
+ (WebCore::DataObjectGtk::markup):
+ (WebCore::DataObjectGtk::setText):
+ (WebCore::DataObjectGtk::setMarkup):
+ (WebCore::DataObjectGtk::files):
+ (WebCore::DataObjectGtk::url):
+ (WebCore::DataObjectGtk::urlLabel):
+ (WebCore::DataObjectGtk::hasURL):
+ (WebCore::DataObjectGtk::clear):
+ (WebCore::DataObjectGtk::forClipboard):
+ * platform/gtk/DataObjectGtk.h: Added.
+ (WebCore::DataObjectGtk::create):
+ (WebCore::DataObjectGtk::uriList):
+ (WebCore::DataObjectGtk::image):
+ (WebCore::DataObjectGtk::setRange):
+ (WebCore::DataObjectGtk::setURIList):
+ (WebCore::DataObjectGtk::setImage):
+ (WebCore::DataObjectGtk::setDragContext):
+ (WebCore::DataObjectGtk::hasText):
+ (WebCore::DataObjectGtk::hasMarkup):
+ (WebCore::DataObjectGtk::hasURIList):
+ (WebCore::DataObjectGtk::hasImage):
+ (WebCore::DataObjectGtk::dragContext):
+
2010-01-14 Ilya Tikhonovsky <loislo at chromium.org>
Reviewed by Pavel Feldman.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 970e648..0590215 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1980,6 +1980,8 @@ webcoregtk_sources += \
WebCore/platform/gtk/ContextMenuItemGtk.cpp \
WebCore/platform/gtk/CursorGtk.cpp \
WebCore/platform/gtk/CursorGtk.h \
+ WebCore/platform/gtk/DataObjectGtk.cpp \
+ WebCore/platform/gtk/DataObjectGtk.h \
WebCore/platform/gtk/DragDataGtk.cpp \
WebCore/platform/gtk/DragImageGtk.cpp \
WebCore/platform/gtk/EventLoopGtk.cpp \
diff --git a/WebCore/platform/gtk/DataObjectGtk.cpp b/WebCore/platform/gtk/DataObjectGtk.cpp
new file mode 100644
index 0000000..900fe8e
--- /dev/null
+++ b/WebCore/platform/gtk/DataObjectGtk.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2009, Martin Robinson
+ *
+ * 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
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "DataObjectGtk.h"
+
+#include "markup.h"
+#include <gtk/gtk.h>
+
+namespace WebCore {
+
+String DataObjectGtk::text()
+{
+ if (m_range)
+ return m_range->text();
+ return m_text;
+}
+
+String DataObjectGtk::markup()
+{
+ if (m_range)
+ createMarkup(m_range.get(), 0, AnnotateForInterchange);
+ return m_markup;
+}
+
+void DataObjectGtk::setText(const String& newText)
+{
+ m_range = 0;
+ m_text = newText;
+}
+
+void DataObjectGtk::setMarkup(const String& newMarkup)
+{
+ m_range = 0;
+ m_markup = newMarkup;
+}
+
+Vector<String> DataObjectGtk::files()
+{
+ Vector<KURL> uris(uriList());
+ Vector<String> files;
+
+ for (size_t i = 0; i < uris.size(); i++) {
+ KURL& uri = uris[0];
+ if (!uri.isValid() || !uri.isLocalFile())
+ continue;
+
+ files.append(uri.string());
+ }
+
+ return files;
+}
+
+String DataObjectGtk::url()
+{
+ Vector<KURL> uris(uriList());
+ for (size_t i = 0; i < uris.size(); i++) {
+ KURL& uri = uris[0];
+ if (uri.isValid())
+ return uri;
+ }
+
+ return String();
+}
+
+String DataObjectGtk::urlLabel()
+{
+ if (hasText())
+ return text();
+
+ if (hasURL())
+ return url();
+
+ return String();
+}
+
+bool DataObjectGtk::hasURL()
+{
+ return !url().isEmpty();
+}
+
+void DataObjectGtk::clear()
+{
+ m_text = "";
+ m_markup = "";
+ m_uriList.clear();
+ m_image = 0;
+ m_range = 0;
+}
+
+DataObjectGtk* DataObjectGtk::forClipboard(GtkClipboard* clipboard)
+{
+ static HashMap<GtkClipboard*, RefPtr<DataObjectGtk> > objectMap;
+
+ if (!objectMap.contains(clipboard)) {
+ RefPtr<DataObjectGtk> dataObject = DataObjectGtk::create();
+ objectMap.set(clipboard, dataObject);
+ return dataObject.get();
+ }
+
+ HashMap<GtkClipboard*, RefPtr<DataObjectGtk> >::iterator it = objectMap.find(clipboard);
+ return it->second.get();
+}
+
+}
diff --git a/WebCore/platform/gtk/DataObjectGtk.h b/WebCore/platform/gtk/DataObjectGtk.h
new file mode 100644
index 0000000..f1a2647
--- /dev/null
+++ b/WebCore/platform/gtk/DataObjectGtk.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2009, Martin Robinson
+ *
+ * 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
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DataObjectGtk_h
+#define DataObjectGtk_h
+
+#include "CString.h"
+#include "FileList.h"
+#include "KURL.h"
+#include "Range.h"
+#include "StringHash.h"
+#include <wtf/RefCounted.h>
+#include <wtf/gtk/GRefPtr.h>
+
+typedef struct _GdkPixbuf GdkPixbuf;
+typedef struct _GdkDragContext GdkDragContext;
+typedef struct _GtkClipboard GtkClipboard;
+
+namespace WebCore {
+
+class DataObjectGtk : public RefCounted<DataObjectGtk> {
+public:
+ static PassRefPtr<DataObjectGtk> create()
+ {
+ return adoptRef(new DataObjectGtk());
+ }
+
+ Vector<KURL> uriList() { return m_uriList; }
+ GdkPixbuf* image() { return m_image.get(); }
+ void setRange(PassRefPtr<Range> newRange) { m_range = newRange; }
+ void setURIList(const Vector<KURL>& newURIList) { m_uriList = newURIList; }
+ void setImage(GdkPixbuf* newImage) { m_image = newImage; }
+ void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; }
+ bool hasText() { return m_range || !m_text.isEmpty(); }
+ bool hasMarkup() { return m_range || !m_markup.isEmpty(); }
+ bool hasURIList() { return !m_uriList.isEmpty(); }
+ bool hasImage() { return m_image; }
+ GdkDragContext* dragContext() { return m_dragContext.get(); }
+
+ String text();
+ String markup();
+ Vector<String> files();
+ void setText(const String& newText);
+ void setMarkup(const String& newMarkup);
+ bool hasURL();
+ String url();
+ String urlLabel();
+ void clear();
+
+ static DataObjectGtk* forClipboard(GtkClipboard*);
+
+private:
+ String m_text;
+ String m_markup;
+ Vector<KURL> m_uriList;
+ GRefPtr<GdkPixbuf> m_image;
+ GRefPtr<GdkDragContext> m_dragContext;
+ RefPtr<Range> m_range;
+};
+
+}
+
+#endif // DataObjectGtk_h
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index c6ec929..d9732ee 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-14 Martin Robinson <martin.james.robinson at gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] Enable DOM clipboard and drag-and-drop access
+ https://bugs.webkit.org/show_bug.cgi?id=30623
+
+ Use DataObjectGtk when setting and clearing pasteboard data on
+ the GDK_SELECTION_PRIMARY clipboard.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::EditorClient::respondToChangedSelection):
+ (WebKit::EditorClient::EditorClient):
+ * WebCoreSupport/EditorClientGtk.h:
+ * WebCoreSupport/PasteboardHelperGtk.cpp:
+ (WebKit::fillSelectionData):
+ (WebKit::targetListForDataObject):
+ (WebKit::getClipboardContentsCallback):
+ (WebKit::clearClipboardContentsCallback):
+ (WebKit::PasteboardHelperGtk::writeClipboardContents):
+ * WebCoreSupport/PasteboardHelperGtk.h:
+
2010-01-14 Alejandro G. Castro <alex at igalia.com>
Reviewed by Xan Lopez.
diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
index b8566a2..266723b 100644
--- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
@@ -24,6 +24,7 @@
#include "EditorClientGtk.h"
#include "CString.h"
+#include "DataObjectGtk.h"
#include "EditCommand.h"
#include "Editor.h"
#include <enchant.h>
@@ -35,6 +36,7 @@
#include "KeyboardEvent.h"
#include "NotImplemented.h"
#include "Page.h"
+#include "PasteboardHelperGtk.h"
#include "PlatformKeyboardEvent.h"
#include "markup.h"
#include "webkitprivate.h"
@@ -185,34 +187,11 @@ void EditorClient::respondToChangedContents()
notImplemented();
}
-void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data)
-{
- EditorClient* client = static_cast<EditorClient*>(data);
-
- if (!client->m_range)
- return;
-
- if (static_cast<gint>(info) == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) {
- String markup = createMarkup(client->m_range.get(), 0, AnnotateForInterchange);
- gtk_selection_data_set(selection_data, selection_data->target, 8,
- reinterpret_cast<const guchar*>(markup.utf8().data()), markup.utf8().length());
- } else {
- String text = client->m_range->text();
- gtk_selection_data_set_text(selection_data, text.utf8().data(), text.utf8().length());
- }
-}
-
-void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data)
-{
- EditorClient* client = static_cast<EditorClient*>(data);
-
- client->m_range = 0;
-}
-
void EditorClient::respondToChangedSelection()
{
WebKitWebViewPrivate* priv = m_webView->priv;
- Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame();
+ WebCore::Page* corePage = core(m_webView);
+ Frame* targetFrame = corePage->focusController()->focusedOrMainFrame();
if (!targetFrame)
return;
@@ -220,16 +199,16 @@ void EditorClient::respondToChangedSelection()
if (targetFrame->editor()->ignoreCompositionSelectionChange())
return;
+#if PLATFORM(X11)
GtkClipboard* clipboard = gtk_widget_get_clipboard(GTK_WIDGET(m_webView), GDK_SELECTION_PRIMARY);
+ DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
+
if (targetFrame->selection()->isRange()) {
- GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView);
- gint targetCount;
- GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount);
- gtk_clipboard_set_with_data(clipboard, targets, targetCount,
- clipboard_get_contents_cb, clipboard_clear_contents_cb, this);
- m_range = targetFrame->selection()->toNormalizedRange();
- gtk_target_table_free(targets, targetCount);
+ dataObject->clear();
+ dataObject->setRange(targetFrame->selection()->toNormalizedRange());
+ pasteboardHelperInstance()->writeClipboardContents(clipboard, corePage);
}
+#endif
if (!targetFrame->editor()->hasComposition())
return;
@@ -550,7 +529,6 @@ void EditorClient::handleInputMethodKeydown(KeyboardEvent* event)
EditorClient::EditorClient(WebKitWebView* webView)
: m_isInRedo(false)
, m_webView(webView)
- , m_range(0)
{
WebKitWebViewPrivate* priv = m_webView->priv;
g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this);
diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
index 33efa4d..9292651 100644
--- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
@@ -34,7 +34,6 @@
#include <wtf/Deque.h>
#include <wtf/Forward.h>
-#include <gtk/gtk.h>
typedef struct _WebKitWebView WebKitWebView;
@@ -121,10 +120,6 @@ namespace WebKit {
private:
WebKitWebView* m_webView;
- RefPtr<WebCore::Range> m_range;
-
- friend void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data);
- friend void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data);
};
}
diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
index c71ef1b..4dc2b50 100644
--- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
@@ -20,13 +20,14 @@
#include "config.h"
#include "PasteboardHelperGtk.h"
+#include "DataObjectGtk.h"
+#include "FocusController.h"
#include "Frame.h"
+#include <gtk/gtk.h>
#include "webkitwebframe.h"
#include "webkitwebview.h"
#include "webkitprivate.h"
-#include <gtk/gtk.h>
-
using namespace WebCore;
namespace WebKit {
@@ -79,4 +80,81 @@ gint PasteboardHelperGtk::getWebViewTargetInfoHtml() const
return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
}
+static void fillSelectionData(GtkSelectionData* selectionData, guint info, DataObjectGtk* dataObject)
+{
+ if (info == WEBKIT_WEB_VIEW_TARGET_INFO_TEXT)
+ gtk_selection_data_set_text(selectionData, dataObject->text().utf8().data(), -1);
+ else if (info == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) {
+ GOwnPtr<gchar> markup(g_strdup(dataObject->markup().utf8().data()));
+ gtk_selection_data_set(selectionData, selectionData->target, 8,
+ reinterpret_cast<const guchar*>(markup.get()),
+ strlen(markup.get()));
+ }
+}
+
+static GtkTargetList* targetListForDataObject(DataObjectGtk* dataObject)
+{
+ GtkTargetList* list = gtk_target_list_new(0, 0);
+
+ if (dataObject->hasText())
+ gtk_target_list_add_text_targets(list, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT);
+
+ if (dataObject->hasMarkup())
+ gtk_target_list_add(list, gdkMarkupAtom, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML);
+
+ return list;
+}
+
+static bool settingClipboard = false;
+static void getClipboardContentsCallback(GtkClipboard* clipboard, GtkSelectionData *selectionData, guint info, gpointer data)
+{
+ DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
+ ASSERT(dataObject);
+ fillSelectionData(selectionData, info, dataObject);
+}
+
+static void clearClipboardContentsCallback(GtkClipboard* clipboard, gpointer data)
+{
+ // GTK will call the clear clipboard callback while setting clipboard data.
+ // We don't actually want to clear the DataObject during that time.
+ if (settingClipboard)
+ return;
+
+ DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
+ ASSERT(dataObject);
+
+ dataObject->clear();
+ if (data) {
+ WebCore::Page* corePage = reinterpret_cast<WebCore::Page*>(data);
+ Frame* frame = corePage->focusController()->focusedOrMainFrame();
+
+ // Collapse the selection without clearing it
+ ASSERT(frame);
+ frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity());
+ }
+}
+
+void PasteboardHelperGtk::writeClipboardContents(GtkClipboard* clipboard, gpointer data)
+{
+ DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
+ GtkTargetList* list = targetListForDataObject(dataObject);
+
+ int numberOfTargets;
+ GtkTargetEntry* table = gtk_target_table_new_from_list(list, &numberOfTargets);
+
+ if (numberOfTargets > 0 && table) {
+ settingClipboard = true;
+ gtk_clipboard_set_with_data(clipboard, table, numberOfTargets,
+ getClipboardContentsCallback,
+ clearClipboardContentsCallback, data);
+ settingClipboard = false;
+ } else
+ gtk_clipboard_clear(clipboard);
+
+ if (table)
+ gtk_target_table_free(table, numberOfTargets);
+
+ gtk_target_list_unref(list);
+}
+
}
diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
index 12ba207..97eff90 100644
--- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
+++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
@@ -47,6 +47,8 @@ public:
virtual GtkTargetList* targetList() const;
virtual gint getWebViewTargetInfoHtml() const;
+ void writeClipboardContents(GtkClipboard* clipboard, gpointer data = 0);
+
private:
GtkTargetList* m_targetList;
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list