diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/platform/gtk | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/platform/gtk')
-rw-r--r-- | WebCore/platform/gtk/ClipboardGtk.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/gtk/ClipboardGtk.h | 4 | ||||
-rw-r--r-- | WebCore/platform/gtk/DragImageGtk.cpp | 29 | ||||
-rw-r--r-- | WebCore/platform/gtk/Language.cpp | 24 | ||||
-rw-r--r-- | WebCore/platform/gtk/LocalizedStringsGtk.cpp | 10 | ||||
-rw-r--r-- | WebCore/platform/gtk/LoggingGtk.cpp | 56 | ||||
-rw-r--r-- | WebCore/platform/gtk/PasteboardGtk.cpp | 9 | ||||
-rw-r--r-- | WebCore/platform/gtk/PlatformScreenGtk.cpp | 34 | ||||
-rw-r--r-- | WebCore/platform/gtk/RenderThemeGtk.cpp | 35 | ||||
-rw-r--r-- | WebCore/platform/gtk/RenderThemeGtk.h | 7 | ||||
-rw-r--r-- | WebCore/platform/gtk/ScrollViewGtk.cpp | 21 |
11 files changed, 119 insertions, 117 deletions
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp index 44aa7f7..8cbf590 100644 --- a/WebCore/platform/gtk/ClipboardGtk.cpp +++ b/WebCore/platform/gtk/ClipboardGtk.cpp @@ -17,6 +17,7 @@ #include "config.h" #include "ClipboardGtk.h" +#include "FileList.h" #include "NotImplemented.h" #include "StringHash.h" @@ -69,6 +70,12 @@ HashSet<String> ClipboardGtk::types() const return HashSet<String>(); } +PassRefPtr<FileList> ClipboardGtk::files() const +{ + notImplemented(); + return 0; +} + IntPoint ClipboardGtk::dragLocation() const { notImplemented(); diff --git a/WebCore/platform/gtk/ClipboardGtk.h b/WebCore/platform/gtk/ClipboardGtk.h index b8b4ddf..7314ae4 100644 --- a/WebCore/platform/gtk/ClipboardGtk.h +++ b/WebCore/platform/gtk/ClipboardGtk.h @@ -47,7 +47,9 @@ namespace WebCore { String getData(const String&, bool&) const; bool setData(const String&, const String&); - HashSet<String> types() const; + virtual HashSet<String> types() const; + virtual PassRefPtr<FileList> files() const; + IntPoint dragLocation() const; CachedImage* dragImage() const; void setDragImage(CachedImage*, const IntPoint&); diff --git a/WebCore/platform/gtk/DragImageGtk.cpp b/WebCore/platform/gtk/DragImageGtk.cpp index 4ddae3a..4c77830 100644 --- a/WebCore/platform/gtk/DragImageGtk.cpp +++ b/WebCore/platform/gtk/DragImageGtk.cpp @@ -20,20 +20,37 @@ #include "CachedImage.h" #include "Image.h" +#include <gtk/gtk.h> + namespace WebCore { -IntSize dragImageSize(DragImageRef) +IntSize dragImageSize(DragImageRef image) { + if (image) + return IntSize(gdk_pixbuf_get_width(image), gdk_pixbuf_get_height(image)); + return IntSize(0, 0); } -void deleteDragImage(DragImageRef) +void deleteDragImage(DragImageRef image) { + if (image) + g_object_unref(image); } -DragImageRef scaleDragImage(DragImageRef image, FloatSize) +DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) { - return image; + 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; + } + + return 0; } DragImageRef dissolveDragImageToFraction(DragImageRef image, float) @@ -41,9 +58,9 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float) return image; } -DragImageRef createDragImageFromImage(Image*) +DragImageRef createDragImageFromImage(Image* image) { - return 0; + return image->getGdkPixbuf(); } DragImageRef createDragImageIconForCachedImage(CachedImage*) diff --git a/WebCore/platform/gtk/Language.cpp b/WebCore/platform/gtk/Language.cpp index 6ae7305..171cd84 100644 --- a/WebCore/platform/gtk/Language.cpp +++ b/WebCore/platform/gtk/Language.cpp @@ -26,30 +26,6 @@ #include <gtk/gtk.h> #include <pango/pango.h> -#if !defined(PANGO_VERSION_CHECK) -// PANGO_VERSION_CHECK() and pango_language_get_default() appeared in 1.5.2 -#include <locale.h> - -static gchar * -_pango_get_lc_ctype (void) -{ - return g_strdup (setlocale (LC_CTYPE, NULL)); -} - -static PangoLanguage * -pango_language_get_default (void) -{ - static PangoLanguage *result = NULL; - if (G_UNLIKELY (!result)) - { - gchar *lang = _pango_get_lc_ctype (); - result = pango_language_from_string (lang); - g_free (lang); - } - return result; -} -#endif - namespace WebCore { String defaultLanguage() diff --git a/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/WebCore/platform/gtk/LocalizedStringsGtk.cpp index 70e3aff..2ba4fbb 100644 --- a/WebCore/platform/gtk/LocalizedStringsGtk.cpp +++ b/WebCore/platform/gtk/LocalizedStringsGtk.cpp @@ -345,4 +345,14 @@ String imageTitle(const String& filename, const IntSize& size) return String::fromUTF8(string.get()); } +String mediaElementLoadingStateText() +{ + return String::fromUTF8(_("Loading...")); +} + +String mediaElementLiveBroadcastStateText() +{ + return String::fromUTF8(_("Live Broadcast")); +} + } diff --git a/WebCore/platform/gtk/LoggingGtk.cpp b/WebCore/platform/gtk/LoggingGtk.cpp index c46364c..6350036 100644 --- a/WebCore/platform/gtk/LoggingGtk.cpp +++ b/WebCore/platform/gtk/LoggingGtk.cpp @@ -20,6 +20,7 @@ #include "config.h" #include "Logging.h" +#include "PlatformString.h" #include <glib.h> #include <string.h> @@ -28,55 +29,6 @@ namespace WebCore { // Inspired by the code used by the Qt port -static WTFLogChannel* getChannelFromName(const char* channelName) -{ - if (strlen(channelName) < 3) - return 0; - - if (!g_ascii_strcasecmp(channelName, "BackForward")) - return &LogBackForward; - if (!g_ascii_strcasecmp(channelName, "Editing")) - return &LogEditing; - if (!g_ascii_strcasecmp(channelName, "Events")) - return &LogEvents; - if (!g_ascii_strcasecmp(channelName, "Frames")) - return &LogFrames; - if (!g_ascii_strcasecmp(channelName, "FTP")) - return &LogFTP; - if (!g_ascii_strcasecmp(channelName, "History")) - return &LogHistory; - if (!g_ascii_strcasecmp(channelName, "IconDatabase")) - return &LogIconDatabase; - if (!g_ascii_strcasecmp(channelName, "Loading")) - return &LogLoading; - if (!g_ascii_strcasecmp(channelName, "Media")) - return &LogMedia; - if (!g_ascii_strcasecmp(channelName, "Network")) - return &LogNetwork; - if (!g_ascii_strcasecmp(channelName, "NotYetImplemented")) - return &LogNotYetImplemented; - if (!g_ascii_strcasecmp(channelName, "PageCache")) - return &LogPageCache; - if (!g_ascii_strcasecmp(channelName, "PlatformLeaks")) - return &LogPlatformLeaks; - if (!g_ascii_strcasecmp(channelName, "Plugin")) - return &LogPlugin; - if (!g_ascii_strcasecmp(channelName, "PopupBlocking")) - return &LogPopupBlocking; - if (!g_ascii_strcasecmp(channelName, "SpellingAndGrammar")) - return &LogSpellingAndGrammar; - if (!g_ascii_strcasecmp(channelName, "SQLDatabase")) - return &LogSQLDatabase; - if (!g_ascii_strcasecmp(channelName, "StorageAPI")) - return &LogStorageAPI; - if (!g_ascii_strcasecmp(channelName, "TextConversion")) - return &LogTextConversion; - if (!g_ascii_strcasecmp(channelName, "Threading")) - return &LogThreading; - - return 0; -} - void InitializeLoggingChannelsIfNecessary() { static bool didInitializeLoggingChannels = false; @@ -98,10 +50,8 @@ void InitializeLoggingChannelsIfNecessary() char** logv = g_strsplit(logEnv, " ", -1); for (int i = 0; logv[i]; i++) { - WTFLogChannel* channel = getChannelFromName(logv[i]); - if (!channel) - continue; - channel->state = WTFLogChannelOn; + if (WTFLogChannel* channel = getChannelFromName(logv[i])) + channel->state = WTFLogChannelOn; } g_strfreev(logv); diff --git a/WebCore/platform/gtk/PasteboardGtk.cpp b/WebCore/platform/gtk/PasteboardGtk.cpp index 062ecb8..9f72923 100644 --- a/WebCore/platform/gtk/PasteboardGtk.cpp +++ b/WebCore/platform/gtk/PasteboardGtk.cpp @@ -25,6 +25,7 @@ #include "Frame.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "TextResourceDecoder.h" #include "Image.h" #include "RenderImage.h" #include "KURL.h" @@ -130,8 +131,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD); ASSERT(node && node->renderer() && node->renderer()->isImage()); - RenderImage* renderer = static_cast<RenderImage*>(node->renderer()); - CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage()); + RenderImage* renderer = toRenderImage(node->renderer()); + CachedImage* cachedImage = renderer->cachedImage(); ASSERT(cachedImage); Image* image = cachedImage->image(); ASSERT(image); @@ -163,7 +164,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, textHtml)) { ASSERT(data->data); - String html = String::fromUTF8(reinterpret_cast<gchar*>(data->data), data->length * data->format / 8); + RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/plain", "UTF-8", true); + String html = decoder->decode(reinterpret_cast<char*>(data->data), data->length); + html += decoder->flush(); gtk_selection_data_free(data); if (!html.isEmpty()) { diff --git a/WebCore/platform/gtk/PlatformScreenGtk.cpp b/WebCore/platform/gtk/PlatformScreenGtk.cpp index 27985ef..4ba6d43 100644 --- a/WebCore/platform/gtk/PlatformScreenGtk.cpp +++ b/WebCore/platform/gtk/PlatformScreenGtk.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Holger Hans Peter Freyther * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,47 +44,55 @@ namespace WebCore { -int screenDepth(Widget* widget) +static GdkVisual* getVisual(Widget* widget) { + if (!widget) + return 0; + GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); if (!container) - return 24; + return 0; if (!GTK_WIDGET_REALIZED(container)) { GtkWidget* toplevel = gtk_widget_get_toplevel(container); if (GTK_WIDGET_TOPLEVEL(toplevel)) container = toplevel; else - return 24; + return 0; } - GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(container->window)); + return gdk_drawable_get_visual(GDK_DRAWABLE(container->window)); +} + +int screenDepth(Widget* widget) +{ + GdkVisual* visual = getVisual(widget); + if (!visual) + return 24; return visual->depth; } int screenDepthPerComponent(Widget* widget) { - GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); - if (!container) + GdkVisual* visual = getVisual(widget); + if (!visual) return 8; - GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())->window)); return visual->bits_per_rgb; } bool screenIsMonochrome(Widget* widget) { - GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); - if (!container) - return false; - return screenDepth(widget) < 2; } FloatRect screenRect(Widget* widget) { + if (!widget) + return FloatRect(); + GtkWidget* container = gtk_widget_get_toplevel(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())); if (!GTK_WIDGET_TOPLEVEL(container)) return FloatRect(); @@ -101,6 +110,9 @@ FloatRect screenRect(Widget* widget) FloatRect screenAvailableRect(Widget* widget) { + if (!widget) + return FloatRect(); + #if PLATFORM(X11) GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow()); if (!container) diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp index a95f557..fdef9c2 100644 --- a/WebCore/platform/gtk/RenderThemeGtk.cpp +++ b/WebCore/platform/gtk/RenderThemeGtk.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2007 Apple Inc. * Copyright (C) 2007 Alp Toker <alp@atoker.com> * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Kenneth Rohde Christiansen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -34,13 +35,18 @@ namespace WebCore { -RenderTheme* theme() +PassRefPtr<RenderTheme> RenderThemeGtk::create() { - static RenderThemeGtk gtkTheme; - return >kTheme; + return adoptRef(new RenderThemeGtk()); } -static bool mozGtkInitialized = false; +PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) +{ + static RenderTheme* rt = RenderThemeGtk::create().releaseRef(); + return rt; +} + +static int mozGtkRefCount = 0; RenderThemeGtk::RenderThemeGtk() : m_gtkWindow(0) @@ -48,18 +54,18 @@ RenderThemeGtk::RenderThemeGtk() , m_gtkEntry(0) , m_gtkTreeView(0) { - if (!mozGtkInitialized) { - mozGtkInitialized = true; + if (!mozGtkRefCount) moz_gtk_init(); - } + + ++mozGtkRefCount; } RenderThemeGtk::~RenderThemeGtk() { - if (mozGtkInitialized) { + --mozGtkRefCount; + + if (!mozGtkRefCount) moz_gtk_shutdown(); - mozGtkInitialized = false; - } } static bool supportsFocus(ControlPart appearance) @@ -314,11 +320,6 @@ bool RenderThemeGtk::paintTextField(RenderObject* o, const RenderObject::PaintIn return paintMozWidget(this, MOZ_GTK_ENTRY, o, i, rect); } -void RenderThemeGtk::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const -{ - adjustTextFieldStyle(selector, style, e); -} - bool RenderThemeGtk::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return paintTextField(o, i, r); @@ -470,7 +471,7 @@ GtkWidget* RenderThemeGtk::gtkEntry() const return m_gtkEntry; m_gtkEntry = gtk_entry_new(); - g_signal_connect(m_gtkEntry, "style-set", G_CALLBACK(gtkStyleSetCallback), theme()); + g_signal_connect(m_gtkEntry, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this)); gtk_container_add(gtkContainer(), m_gtkEntry); gtk_widget_realize(m_gtkEntry); @@ -483,7 +484,7 @@ GtkWidget* RenderThemeGtk::gtkTreeView() const return m_gtkTreeView; m_gtkTreeView = gtk_tree_view_new(); - g_signal_connect(m_gtkTreeView, "style-set", G_CALLBACK(gtkStyleSetCallback), theme()); + g_signal_connect(m_gtkTreeView, "style-set", G_CALLBACK(gtkStyleSetCallback), const_cast<RenderThemeGtk*>(this)); gtk_container_add(gtkContainer(), m_gtkTreeView); gtk_widget_realize(m_gtkTreeView); diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h index 82a87cb..13daaa2 100644 --- a/WebCore/platform/gtk/RenderThemeGtk.h +++ b/WebCore/platform/gtk/RenderThemeGtk.h @@ -5,6 +5,7 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * Copyright (C) 2009 Kenneth Rohde Christiansen * All rights reserved. * * This library is free software; you can redistribute it and/or @@ -34,10 +35,13 @@ namespace WebCore { class RenderThemeGtk : public RenderTheme { -public: +private: RenderThemeGtk(); virtual ~RenderThemeGtk(); +public: + static PassRefPtr<RenderTheme> create(); + // A method asking if the theme's controls actually care about redrawing when hovered. virtual bool supportsHover(const RenderStyle* style) const { return true; } @@ -85,7 +89,6 @@ protected: virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); - virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const; diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp index 0f066fc..0e811ef 100644 --- a/WebCore/platform/gtk/ScrollViewGtk.cpp +++ b/WebCore/platform/gtk/ScrollViewGtk.cpp @@ -121,4 +121,25 @@ void ScrollView::platformRemoveChild(Widget* child) gtk_container_remove(GTK_CONTAINER(parent), child->platformWidget()); } +IntRect ScrollView::visibleContentRect(bool includeScrollbars) const +{ + if (!m_horizontalAdjustment) + return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()), + IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)), + max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0)))); + + // Main frame. + GtkWidget* measuredWidget = hostWindow()->platformWindow(); + GtkWidget* parent = gtk_widget_get_parent(measuredWidget); + + // We may not be in a widget that displays scrollbars, but we may + // have other kinds of decoration that make us smaller. + if (parent && includeScrollbars) + measuredWidget = parent; + + return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()), + IntSize(measuredWidget->allocation.width, + measuredWidget->allocation.height)); +} + } |