diff options
Diffstat (limited to 'WebCore/platform/gtk')
25 files changed, 293 insertions, 135 deletions
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp index 6122d8f..93a21e2 100644 --- a/WebCore/platform/gtk/ClipboardGtk.cpp +++ b/WebCore/platform/gtk/ClipboardGtk.cpp @@ -18,16 +18,16 @@ #include "ClipboardGtk.h" #include "CachedImage.h" -#include "CString.h" #include "Editor.h" #include "Element.h" #include "FileList.h" #include "Frame.h" -#include "markup.h" +#include "Image.h" #include "NotImplemented.h" #include "RenderImage.h" #include "StringHash.h" - +#include "markup.h" +#include <wtf/text/CString.h> #include <gtk/gtk.h> namespace WebCore { diff --git a/WebCore/platform/gtk/ContextMenuItemGtk.cpp b/WebCore/platform/gtk/ContextMenuItemGtk.cpp index b2fa853..e2c5b84 100644 --- a/WebCore/platform/gtk/ContextMenuItemGtk.cpp +++ b/WebCore/platform/gtk/ContextMenuItemGtk.cpp @@ -19,8 +19,8 @@ #include "config.h" #include "ContextMenu.h" #include "ContextMenuItem.h" -#include "CString.h" #include "NotImplemented.h" +#include <wtf/text/CString.h> #include <gtk/gtk.h> diff --git a/WebCore/platform/gtk/DataObjectGtk.h b/WebCore/platform/gtk/DataObjectGtk.h index f1a2647..22158d4 100644 --- a/WebCore/platform/gtk/DataObjectGtk.h +++ b/WebCore/platform/gtk/DataObjectGtk.h @@ -19,13 +19,13 @@ #ifndef DataObjectGtk_h #define DataObjectGtk_h -#include "CString.h" #include "FileList.h" +#include <GRefPtr.h> #include "KURL.h" #include "Range.h" #include "StringHash.h" #include <wtf/RefCounted.h> -#include <wtf/gtk/GRefPtr.h> +#include <wtf/text/CString.h> typedef struct _GdkPixbuf GdkPixbuf; typedef struct _GdkDragContext GdkDragContext; diff --git a/WebCore/platform/gtk/FileChooserGtk.cpp b/WebCore/platform/gtk/FileChooserGtk.cpp index a25d88b..3ff06f0 100644 --- a/WebCore/platform/gtk/FileChooserGtk.cpp +++ b/WebCore/platform/gtk/FileChooserGtk.cpp @@ -27,11 +27,11 @@ #include "config.h" #include "FileChooser.h" -#include "CString.h" #include "FileSystem.h" #include "Icon.h" #include "LocalizedStrings.h" #include "StringTruncator.h" +#include <wtf/text/CString.h> #include <glib.h> #include <gtk/gtk.h> diff --git a/WebCore/platform/gtk/FileSystemGtk.cpp b/WebCore/platform/gtk/FileSystemGtk.cpp index b8bbd60..6cad4d9 100644 --- a/WebCore/platform/gtk/FileSystemGtk.cpp +++ b/WebCore/platform/gtk/FileSystemGtk.cpp @@ -24,7 +24,7 @@ #include "GOwnPtr.h" #include "PlatformString.h" -#include "CString.h" +#include <wtf/text/CString.h> #include <glib.h> #include <glib/gstdio.h> diff --git a/WebCore/platform/gtk/GOwnPtrGtk.cpp b/WebCore/platform/gtk/GOwnPtrGtk.cpp deleted file mode 100644 index 8538105..0000000 --- a/WebCore/platform/gtk/GOwnPtrGtk.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 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 - * 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 "GOwnPtrGtk.h" - -#if ENABLE(VIDEO) -#include <gst/gstelement.h> -#endif -#include <libsoup/soup-uri.h> - -namespace WTF { - -template <> void freeOwnedGPtr<SoupURI>(SoupURI* ptr) -{ - if (ptr) - soup_uri_free(ptr); -} - -#if ENABLE(VIDEO) -template <> void freeOwnedGPtr<GstElement>(GstElement* ptr) -{ - if (ptr) - gst_object_unref(ptr); -} -#endif - -} diff --git a/WebCore/platform/gtk/GeolocationServiceGtk.cpp b/WebCore/platform/gtk/GeolocationServiceGtk.cpp index edb8d10..69a0843 100644 --- a/WebCore/platform/gtk/GeolocationServiceGtk.cpp +++ b/WebCore/platform/gtk/GeolocationServiceGtk.cpp @@ -20,10 +20,10 @@ #include "config.h" #include "GeolocationServiceGtk.h" -#include "CString.h" #include "GOwnPtr.h" #include "NotImplemented.h" #include "PositionOptions.h" +#include <wtf/text/CString.h> namespace WTF { template<> void freeOwnedGPtr<GeoclueAccuracy>(GeoclueAccuracy* accuracy) @@ -94,11 +94,12 @@ bool GeolocationServiceGtk::startUpdating(PositionOptions* options) int timeout = 0; if (options) { accuracyLevel = options->enableHighAccuracy() ? GEOCLUE_ACCURACY_LEVEL_DETAILED : GEOCLUE_ACCURACY_LEVEL_LOCALITY; - timeout = options->timeout(); + if (options->hasTimeout()) + timeout = options->timeout(); } gboolean result = geoclue_master_client_set_requirements(client, accuracyLevel, timeout, - true, GEOCLUE_RESOURCE_ALL, &error.outPtr()); + false, GEOCLUE_RESOURCE_ALL, &error.outPtr()); if (!result) { setError(PositionError::POSITION_UNAVAILABLE, error->message); @@ -113,12 +114,13 @@ bool GeolocationServiceGtk::startUpdating(PositionOptions* options) return false; } + m_geoclueClient = client; + + geoclue_position_get_position_async(m_geocluePosition, (GeocluePositionCallback)getPositionCallback, this); + g_signal_connect(G_OBJECT(m_geocluePosition), "position-changed", G_CALLBACK(position_changed), this); - m_geoclueClient = client; - updateLocationInformation(); - return true; } @@ -156,28 +158,6 @@ PositionError* GeolocationServiceGtk::lastError() const return m_lastError.get(); } -void GeolocationServiceGtk::updateLocationInformation() -{ - ASSERT(m_geocluePosition); - - GOwnPtr<GError> error; - GOwnPtr<GeoclueAccuracy> accuracy; - - GeocluePositionFields fields = geoclue_position_get_position(m_geocluePosition, &m_timestamp, - &m_latitude, &m_longitude, - &m_altitude, &accuracy.outPtr(), - &error.outPtr()); - if (error) { - setError(PositionError::POSITION_UNAVAILABLE, error->message); - return; - } else if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) { - setError(PositionError::POSITION_UNAVAILABLE, "Position could not be determined."); - return; - } - - -} - void GeolocationServiceGtk::updatePosition() { m_lastError = 0; @@ -189,6 +169,24 @@ void GeolocationServiceGtk::updatePosition() positionChanged(); } +void GeolocationServiceGtk::getPositionCallback(GeocluePosition *position, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy* accuracy, + GError* error, + GeolocationServiceGtk* that) +{ + if (error) { + that->setError(PositionError::POSITION_UNAVAILABLE, error->message); + g_error_free(error); + return; + } + position_changed(position, fields, timestamp, latitude, longitude, altitude, accuracy, that); +} + void GeolocationServiceGtk::position_changed(GeocluePosition*, GeocluePositionFields fields, int timestamp, double latitude, double longitude, double altitude, GeoclueAccuracy* accuracy, GeolocationServiceGtk* that) { if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) { diff --git a/WebCore/platform/gtk/GeolocationServiceGtk.h b/WebCore/platform/gtk/GeolocationServiceGtk.h index a198dc0..c123017 100644 --- a/WebCore/platform/gtk/GeolocationServiceGtk.h +++ b/WebCore/platform/gtk/GeolocationServiceGtk.h @@ -46,11 +46,11 @@ namespace WebCore { private: GeolocationServiceGtk(GeolocationServiceClient*); - void updateLocationInformation(); void setError(PositionError::ErrorCode, const char* message); void updatePosition(); static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*); + static void getPositionCallback(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GError*, GeolocationServiceGtk*); private: RefPtr<Geoposition> m_lastPosition; diff --git a/WebCore/platform/gtk/GtkPluginWidget.cpp b/WebCore/platform/gtk/GtkPluginWidget.cpp index bc2dd92..67bf4b1 100644 --- a/WebCore/platform/gtk/GtkPluginWidget.cpp +++ b/WebCore/platform/gtk/GtkPluginWidget.cpp @@ -28,6 +28,7 @@ #include "GtkPluginWidget.h" #include "GraphicsContext.h" +#include "GtkVersioning.h" #include "ScrollView.h" #include <gtk/gtk.h> @@ -43,7 +44,7 @@ GtkPluginWidget::GtkPluginWidget(GtkWidget* widget) void GtkPluginWidget::invalidateRect(const IntRect& _rect) { /* no need to */ - if (GTK_WIDGET_NO_WINDOW(platformWidget())) + if (!gtk_widget_get_has_window(platformWidget())) return; GdkWindow* window = platformWidget()->window; @@ -70,12 +71,12 @@ void GtkPluginWidget::paint(GraphicsContext* context, const IntRect& rect) if (!context->gdkExposeEvent()) return; - /* only paint widgets with NO_WINDOW this way */ - if (!GTK_WIDGET_NO_WINDOW(platformWidget())) + /* only paint widgets with no window this way */ + if (gtk_widget_get_has_window(platformWidget())) return; GtkWidget* widget = platformWidget(); - ASSERT(GTK_WIDGET_NO_WINDOW(widget)); + ASSERT(!gtk_widget_get_has_window(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); diff --git a/WebCore/platform/gtk/GOwnPtrGtk.h b/WebCore/platform/gtk/GtkVersioning.h index c585002..fc92d8b 100644 --- a/WebCore/platform/gtk/GOwnPtrGtk.h +++ b/WebCore/platform/gtk/GtkVersioning.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Igalia S.L + * Copyright (C) 2010 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,19 +17,18 @@ * Boston, MA 02110-1301, USA. */ -#ifndef GOwnPtrGtk_h -#define GOwnPtrGtk_h +#ifndef GtkVersioning_h +#define GtkVersioning_h -#include "GOwnPtr.h" +#include <gtk/gtk.h> -typedef struct _SoupURI SoupURI; -typedef struct _GstElement GstElement; +// Macros to avoid deprecation checking churn +#if !GTK_CHECK_VERSION(2, 19, 0) +#define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL(widget) +#define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget) +#define gtk_widget_get_has_window(widget) !GTK_WIDGET_NO_WINDOW(widget) +#define gtk_widget_get_can_focus(widget) GTK_WIDGET_CAN_FOCUS(widget) +#define gtk_widget_is_sensitive(widget) GTK_WIDGET_IS_SENSITIVE(widget) +#endif // GTK_CHECK_VERSION(2, 19, 0) -namespace WTF { - -template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr); -template<> void freeOwnedGPtr<GstElement>(GstElement* ptr); - -} - -#endif +#endif // GtkVersioning_h diff --git a/WebCore/platform/gtk/KURLGtk.cpp b/WebCore/platform/gtk/KURLGtk.cpp index 4858d3e..47bc48b 100644 --- a/WebCore/platform/gtk/KURLGtk.cpp +++ b/WebCore/platform/gtk/KURLGtk.cpp @@ -19,8 +19,8 @@ #include "config.h" #include "KURL.h" -#include "CString.h" #include "FileSystem.h" +#include <wtf/text/CString.h> #include <glib.h> diff --git a/WebCore/platform/gtk/KeyEventGtk.cpp b/WebCore/platform/gtk/KeyEventGtk.cpp index e00ea43..193b7e5 100644 --- a/WebCore/platform/gtk/KeyEventGtk.cpp +++ b/WebCore/platform/gtk/KeyEventGtk.cpp @@ -30,9 +30,9 @@ #include "config.h" #include "PlatformKeyboardEvent.h" -#include "KeyboardCodes.h" #include "NotImplemented.h" #include "TextEncoding.h" +#include "WindowsKeyboardCodes.h" #include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> @@ -586,6 +586,15 @@ bool PlatformKeyboardEvent::currentCapsLockState() return false; } +void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) +{ + notImplemented(); + shiftKey = false; + ctrlKey = false; + altKey = false; + metaKey = false; +} + GdkEventKey* PlatformKeyboardEvent::gdkEventKey() const { return m_gdkEventKey; diff --git a/WebCore/platform/gtk/Language.cpp b/WebCore/platform/gtk/Language.cpp index 577d7d8..f1d5750 100644 --- a/WebCore/platform/gtk/Language.cpp +++ b/WebCore/platform/gtk/Language.cpp @@ -20,9 +20,9 @@ #include "config.h" #include "Language.h" -#include "CString.h" #include "GOwnPtr.h" #include "PlatformString.h" +#include <wtf/text/CString.h> #include <gtk/gtk.h> #include <locale.h> diff --git a/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/WebCore/platform/gtk/LocalizedStringsGtk.cpp index e0ec3ab..432c92f 100644 --- a/WebCore/platform/gtk/LocalizedStringsGtk.cpp +++ b/WebCore/platform/gtk/LocalizedStringsGtk.cpp @@ -30,11 +30,11 @@ #include "config.h" #include "LocalizedStrings.h" -#include "CString.h" #include "GOwnPtr.h" #include "IntSize.h" #include "NotImplemented.h" #include "PlatformString.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> #include <gtk/gtk.h> @@ -67,7 +67,7 @@ String resetButtonDefaultLabel() String searchableIndexIntroduction() { - return String::fromUTF8(_("_Searchable Index")); + return String::fromUTF8(_("This is a searchable index. Enter search keywords: ")); } String fileButtonChooseFileLabel() @@ -335,6 +335,17 @@ String AXMenuListActionVerb() { return String(); } + +String missingPluginText() +{ + return String::fromUTF8(_("Missing Plug-in")); +} + +String crashedPluginText() +{ + notImplemented(); + return String::fromUTF8(_("Plug-in Failure")); +} String multipleFileUploadText(unsigned numberOfFiles) { diff --git a/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp b/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp index 8afb60f..8fc3020 100644 --- a/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp +++ b/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp @@ -73,4 +73,9 @@ String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) return String(); } +bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&) +{ + return false; +} + } diff --git a/WebCore/platform/gtk/PasteboardGtk.cpp b/WebCore/platform/gtk/PasteboardGtk.cpp index 5c7d9a7..907a55e 100644 --- a/WebCore/platform/gtk/PasteboardGtk.cpp +++ b/WebCore/platform/gtk/PasteboardGtk.cpp @@ -20,7 +20,6 @@ #include "config.h" #include "Pasteboard.h" -#include "CString.h" #include "DocumentFragment.h" #include "Frame.h" #include "NotImplemented.h" @@ -30,6 +29,7 @@ #include "RenderImage.h" #include "KURL.h" #include "markup.h" +#include <wtf/text/CString.h> #include <gtk/gtk.h> @@ -58,7 +58,7 @@ static void clipboard_get_contents_cb(GtkClipboard *clipboard, GtkSelectionData guint info, gpointer data) { PasteboardSelectionData* clipboardData = reinterpret_cast<PasteboardSelectionData*>(data); ASSERT(clipboardData); - if ((gint)info == Pasteboard::generalPasteboard()->m_helper->getWebViewTargetInfoHtml()) + if (info == Pasteboard::generalPasteboard()->helper()->getIdForTargetType(PasteboardHelper::TargetTypeMarkup)) gtk_selection_data_set(selection_data, selection_data->target, 8, reinterpret_cast<const guchar*>(clipboardData->markup()), g_utf8_strlen(clipboardData->markup(), -1)); @@ -89,6 +89,11 @@ Pasteboard::~Pasteboard() delete m_helper; } +PasteboardHelper* Pasteboard::helper() +{ + return m_helper; +} + void Pasteboard::setHelper(PasteboardHelper* helper) { m_helper = helper; @@ -121,7 +126,7 @@ void Pasteboard::writeURL(const KURL& url, const String&, Frame* frame) return; GtkClipboard* clipboard = m_helper->getClipboard(frame); - GtkClipboard* primary = m_helper->getPrimary(frame); + GtkClipboard* primary = m_helper->getPrimarySelectionClipboard(frame); CString utf8 = url.string().utf8(); gtk_clipboard_set_text(clipboard, utf8.data(), utf8.length()); gtk_clipboard_set_text(primary, utf8.data(), utf8.length()); @@ -161,7 +166,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP bool allowPlainText, bool& chosePlainText) { GdkAtom textHtml = gdk_atom_intern_static_string("text/html"); - GtkClipboard* clipboard = m_helper->getCurrentTarget(frame); + GtkClipboard* clipboard = m_helper->getCurrentClipboard(frame); chosePlainText = false; if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, textHtml)) { @@ -196,7 +201,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP String Pasteboard::plainText(Frame* frame) { - GtkClipboard* clipboard = m_helper->getCurrentTarget(frame); + GtkClipboard* clipboard = m_helper->getCurrentClipboard(frame); gchar* utf8 = gtk_clipboard_wait_for_text(clipboard); diff --git a/WebCore/platform/gtk/PasteboardHelper.cpp b/WebCore/platform/gtk/PasteboardHelper.cpp new file mode 100644 index 0000000..be32ea5 --- /dev/null +++ b/WebCore/platform/gtk/PasteboardHelper.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2010 Martin Robinson <mrobinson@webkit.org> + * All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ +#include "config.h" +#include "PasteboardHelper.h" + +#include "Chrome.h" +#include "DataObjectGtk.h" +#include "Frame.h" +#include "Page.h" +#include "Pasteboard.h" +#include <gtk/gtk.h> +#include <wtf/gobject/GOwnPtr.h> + +namespace WebCore { + +static GdkAtom gdkMarkupAtom = gdk_atom_intern("text/html", FALSE); + +PasteboardHelper::PasteboardHelper() + : m_targetList(gtk_target_list_new(0, 0)) +{ +} + +PasteboardHelper::~PasteboardHelper() +{ + gtk_target_list_unref(m_targetList); +} + + +void PasteboardHelper::initializeTargetList() +{ + gtk_target_list_add_text_targets(m_targetList, getIdForTargetType(TargetTypeText)); + gtk_target_list_add(m_targetList, gdkMarkupAtom, 0, getIdForTargetType(TargetTypeMarkup)); +} + +static inline GtkWidget* widgetFromFrame(Frame* frame) +{ + ASSERT(frame); + Page* page = frame->page(); + ASSERT(page); + Chrome* chrome = page->chrome(); + ASSERT(chrome); + PlatformPageClient client = chrome->platformPageClient(); + ASSERT(client); + return client; +} + +GtkClipboard* PasteboardHelper::getCurrentClipboard(Frame* frame) +{ + if (usePrimarySelectionClipboard(widgetFromFrame(frame))) + return getPrimarySelectionClipboard(frame); + return getClipboard(frame); +} + +GtkClipboard* PasteboardHelper::getClipboard(Frame* frame) const +{ + return gtk_widget_get_clipboard(widgetFromFrame(frame), GDK_SELECTION_CLIPBOARD); +} + +GtkClipboard* PasteboardHelper::getPrimarySelectionClipboard(Frame* frame) const +{ + return gtk_widget_get_clipboard(widgetFromFrame(frame), GDK_SELECTION_PRIMARY); +} + +GtkTargetList* PasteboardHelper::targetList() const +{ + return m_targetList; +} + +void PasteboardHelper::fillSelectionData(GtkSelectionData* selectionData, guint info, DataObjectGtk* dataObject) +{ + if (info == getIdForTargetType(TargetTypeText)) + gtk_selection_data_set_text(selectionData, dataObject->text().utf8().data(), -1); + else if (info == getIdForTargetType(TargetTypeMarkup)) { + 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())); + } +} + +GtkTargetList* PasteboardHelper::targetListForDataObject(DataObjectGtk* dataObject) +{ + GtkTargetList* list = gtk_target_list_new(0, 0); + + if (dataObject->hasText()) + gtk_target_list_add_text_targets(list, getIdForTargetType(TargetTypeText)); + + if (dataObject->hasMarkup()) + gtk_target_list_add(list, gdkMarkupAtom, 0, getIdForTargetType(TargetTypeMarkup)); + + return list; +} + +static DataObjectGtk* settingClipboardDataObject = 0; + +static void getClipboardContentsCallback(GtkClipboard* clipboard, GtkSelectionData *selectionData, guint info, gpointer data) +{ + DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); + ASSERT(dataObject); + Pasteboard::generalPasteboard()->helper()->fillSelectionData(selectionData, info, dataObject); +} + +static void clearClipboardContentsCallback(GtkClipboard* clipboard, gpointer data) +{ + DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); + ASSERT(dataObject); + + // Only clear the DataObject for this clipboard if we are not currently setting it. + if (dataObject != settingClipboardDataObject) + dataObject->clear(); + + if (!data) + return; + + GClosure* callback = static_cast<GClosure*>(data); + GValue firstArgument = {0, {{0}}}; + g_value_init(&firstArgument, G_TYPE_POINTER); + g_value_set_pointer(&firstArgument, clipboard); + g_closure_invoke(callback, 0, 1, &firstArgument, 0); + g_closure_unref(callback); +} + +void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, GClosure* callback) +{ + 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) { + settingClipboardDataObject = dataObject; + + gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, + getClipboardContentsCallback, clearClipboardContentsCallback, callback); + + settingClipboardDataObject = 0; + + } else + gtk_clipboard_clear(clipboard); + + if (table) + gtk_target_table_free(table, numberOfTargets); + gtk_target_list_unref(list); +} + +} + diff --git a/WebCore/platform/gtk/PasteboardHelper.h b/WebCore/platform/gtk/PasteboardHelper.h index fff9a9b..6e5d366 100644 --- a/WebCore/platform/gtk/PasteboardHelper.h +++ b/WebCore/platform/gtk/PasteboardHelper.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com> * Copyright (C) 2009 Holger Hans Peter Freyther + * Copyright (C) 2010 Martin Robinson <mrobinson@webkit.org> * All rights reserved. * * This library is free software; you can redistribute it and/or @@ -32,18 +33,35 @@ typedef struct _GtkClipboard GtkClipboard; typedef struct _GtkTargetList GtkTargetList; +typedef struct _GtkWidget GtkWidget; +typedef struct _GtkSelectionData GtkSelectionData; namespace WebCore { +class DataObjectGtk; + class PasteboardHelper { public: - virtual ~PasteboardHelper() {}; + PasteboardHelper(); + virtual ~PasteboardHelper(); + + GtkClipboard* getCurrentClipboard(Frame*); + GtkClipboard* getClipboard(Frame*) const; + GtkClipboard* getPrimarySelectionClipboard(Frame*) const; + GtkTargetList* targetList() const; + void fillSelectionData(GtkSelectionData*, guint, DataObjectGtk*); + void writeClipboardContents(GtkClipboard*, GClosure*); + + enum PasteboardTargetType { TargetTypeText, TargetTypeMarkup, TargetTypeURIList, TargetTypeNetscapeURL, TargetTypeImage, TargetTypeUnknown }; + virtual guint getIdForTargetType(PasteboardTargetType) = 0; + +protected: + void initializeTargetList(); + virtual bool usePrimarySelectionClipboard(GtkWidget*) = 0; - virtual GtkClipboard* getCurrentTarget(Frame*) const = 0; - virtual GtkClipboard* getClipboard(Frame*) const = 0; - virtual GtkClipboard* getPrimary(Frame*) const = 0; - virtual GtkTargetList* targetList() const = 0; - virtual gint getWebViewTargetInfoHtml() const = 0; +private: + GtkTargetList* m_targetList; + GtkTargetList* targetListForDataObject(DataObjectGtk*); }; } diff --git a/WebCore/platform/gtk/PlatformScreenGtk.cpp b/WebCore/platform/gtk/PlatformScreenGtk.cpp index 92ccff4..9341714 100644 --- a/WebCore/platform/gtk/PlatformScreenGtk.cpp +++ b/WebCore/platform/gtk/PlatformScreenGtk.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "PlatformScreen.h" +#include "GtkVersioning.h" #include "HostWindow.h" #include "ScrollView.h" #include "Widget.h" @@ -54,13 +55,9 @@ static GdkVisual* getVisual(Widget* widget) if (!container) return 0; - if (!GTK_WIDGET_REALIZED(container)) { + if (!gtk_widget_get_realized(container)) { GtkWidget* toplevel = gtk_widget_get_toplevel(container); -#if GTK_CHECK_VERSION(2, 18, 0) if (gtk_widget_is_toplevel(toplevel)) -#else - if (GTK_WIDGET_TOPLEVEL(toplevel)) -#endif container = toplevel; else return 0; @@ -98,11 +95,7 @@ FloatRect screenRect(Widget* widget) return FloatRect(); GtkWidget* container = gtk_widget_get_toplevel(GTK_WIDGET(widget->root()->hostWindow()->platformPageClient())); -#if GTK_CHECK_VERSION(2, 18, 0) if (!gtk_widget_is_toplevel(container)) -#else - if (!GTK_WIDGET_TOPLEVEL(container)) -#endif return FloatRect(); GdkScreen* screen = gtk_widget_has_screen(container) ? gtk_widget_get_screen(container) : gdk_screen_get_default(); @@ -126,7 +119,7 @@ FloatRect screenAvailableRect(Widget* widget) if (!container) return FloatRect(); - if (!GTK_WIDGET_REALIZED(container)) + if (!gtk_widget_get_realized(container)) return screenRect(widget); GdkDrawable* rootWindow = GDK_DRAWABLE(gtk_widget_get_root_window(container)); diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp index 0363ac4..1620b3b 100644 --- a/WebCore/platform/gtk/PopupMenuGtk.cpp +++ b/WebCore/platform/gtk/PopupMenuGtk.cpp @@ -25,10 +25,10 @@ #include "config.h" #include "PopupMenu.h" -#include "CString.h" #include "FrameView.h" #include "HostWindow.h" #include "PlatformString.h" +#include <wtf/text/CString.h> #include <gtk/gtk.h> namespace WebCore { diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp index e19e2fa..93794ff 100644 --- a/WebCore/platform/gtk/RenderThemeGtk.cpp +++ b/WebCore/platform/gtk/RenderThemeGtk.cpp @@ -25,7 +25,6 @@ #include "RenderThemeGtk.h" #include "AffineTransform.h" -#include "CString.h" #include "GOwnPtr.h" #include "Gradient.h" #include "GraphicsContext.h" @@ -37,6 +36,7 @@ #include "RenderObject.h" #include "UserAgentStyleSheets.h" #include "gtkdrawing.h" +#include <wtf/text/CString.h> #include <gdk/gdk.h> #include <gtk/gtk.h> diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp index e868250..3df3cb5 100644 --- a/WebCore/platform/gtk/ScrollViewGtk.cpp +++ b/WebCore/platform/gtk/ScrollViewGtk.cpp @@ -168,7 +168,7 @@ IntRect ScrollView::visibleContentRect(bool includeScrollbars) const measuredWidget->allocation.height)); } -void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode) +void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode, bool, bool) { if (horizontalMode == m_horizontalScrollbarMode && verticalMode == m_verticalScrollbarMode) return; diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp index 0c3037a..00cbcf0 100644 --- a/WebCore/platform/gtk/ScrollbarGtk.cpp +++ b/WebCore/platform/gtk/ScrollbarGtk.cpp @@ -196,7 +196,7 @@ void ScrollbarGtk::setEnabled(bool shouldEnable) /* * Strategy to painting a Widget: * 1.) do not paint if there is no GtkWidget set - * 2.) We assume that GTK_NO_WINDOW is set and that frameRectsChanged positioned + * 2.) We assume that the widget has no window and that frameRectsChanged positioned * the widget correctly. ATM we do not honor the GraphicsContext translation. */ void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect) @@ -208,7 +208,7 @@ void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect) return; GtkWidget* widget = platformWidget(); - ASSERT(GTK_WIDGET_NO_WINDOW(widget)); + ASSERT(!gtk_widget_get_has_window(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); diff --git a/WebCore/platform/gtk/SharedBufferGtk.cpp b/WebCore/platform/gtk/SharedBufferGtk.cpp index 783fec6..db04d80 100644 --- a/WebCore/platform/gtk/SharedBufferGtk.cpp +++ b/WebCore/platform/gtk/SharedBufferGtk.cpp @@ -19,8 +19,8 @@ #include "config.h" #include "SharedBuffer.h" -#include "CString.h" #include "FileSystem.h" +#include <wtf/text/CString.h> #include <glib.h> diff --git a/WebCore/platform/gtk/SharedTimerGtk.cpp b/WebCore/platform/gtk/SharedTimerGtk.cpp index 0a760ed..092df95 100644 --- a/WebCore/platform/gtk/SharedTimerGtk.cpp +++ b/WebCore/platform/gtk/SharedTimerGtk.cpp @@ -63,10 +63,7 @@ void setSharedTimerFireTime(double fireTime) } stopSharedTimer(); - if (intervalInMS == 0) - sharedTimer = g_idle_add(timeout_cb, NULL); - else - sharedTimer = g_timeout_add_full(G_PRIORITY_DEFAULT, intervalInMS, timeout_cb, NULL, NULL); + sharedTimer = g_timeout_add(intervalInMS, timeout_cb, NULL); } void stopSharedTimer() |