summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/gtk
diff options
context:
space:
mode:
authorFeng Qian <>2009-04-10 18:11:29 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-10 18:11:29 -0700
commit8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch)
tree181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/platform/gtk
parent7ed56f225e0ade046e1c2178977f72b2d896f196 (diff)
downloadexternal_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip
external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz
external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/platform/gtk')
-rw-r--r--WebCore/platform/gtk/ContextMenuGtk.cpp5
-rw-r--r--WebCore/platform/gtk/ContextMenuItemGtk.cpp5
-rw-r--r--WebCore/platform/gtk/FileSystemGtk.cpp2
-rw-r--r--WebCore/platform/gtk/GeolocationServiceGtk.cpp162
-rw-r--r--WebCore/platform/gtk/GeolocationServiceGtk.h30
-rw-r--r--WebCore/platform/gtk/LoggingGtk.cpp86
-rw-r--r--WebCore/platform/gtk/PopupMenuGtk.cpp5
-rw-r--r--WebCore/platform/gtk/ScrollViewGtk.cpp4
-rw-r--r--WebCore/platform/gtk/ScrollbarGtk.cpp76
-rw-r--r--WebCore/platform/gtk/ScrollbarGtk.h4
-rw-r--r--WebCore/platform/gtk/WheelEventGtk.cpp17
-rw-r--r--WebCore/platform/gtk/WidgetGtk.cpp61
12 files changed, 350 insertions, 107 deletions
diff --git a/WebCore/platform/gtk/ContextMenuGtk.cpp b/WebCore/platform/gtk/ContextMenuGtk.cpp
index 2365379..210cfa6 100644
--- a/WebCore/platform/gtk/ContextMenuGtk.cpp
+++ b/WebCore/platform/gtk/ContextMenuGtk.cpp
@@ -39,12 +39,7 @@ ContextMenu::ContextMenu(const HitTestResult& result)
{
m_platformDescription = GTK_MENU(gtk_menu_new());
-#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(G_OBJECT(m_platformDescription));
-#else
- g_object_ref(G_OBJECT(m_platformDescription));
- gtk_object_sink(GTK_OBJECT(m_platformDescription));
-#endif
}
ContextMenu::~ContextMenu()
diff --git a/WebCore/platform/gtk/ContextMenuItemGtk.cpp b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
index 84f78c0..cf34640 100644
--- a/WebCore/platform/gtk/ContextMenuItemGtk.cpp
+++ b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
@@ -232,12 +232,7 @@ void ContextMenuItem::setSubMenu(ContextMenu* menu)
m_platformDescription.subMenu = menu->releasePlatformDescription();
m_platformDescription.type = SubmenuType;
-#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(G_OBJECT(m_platformDescription.subMenu));
-#else
- g_object_ref(G_OBJECT(m_platformDescription.subMenu));
- gtk_object_sink(GTK_OBJECT(m_platformDescription.subMenu));
-#endif
}
void ContextMenuItem::setChecked(bool shouldCheck)
diff --git a/WebCore/platform/gtk/FileSystemGtk.cpp b/WebCore/platform/gtk/FileSystemGtk.cpp
index 4f0ae01..94e06db 100644
--- a/WebCore/platform/gtk/FileSystemGtk.cpp
+++ b/WebCore/platform/gtk/FileSystemGtk.cpp
@@ -229,7 +229,7 @@ CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
if (!isHandleValid(fileDescriptor)) {
LOG_ERROR("Can't create a temporary file.");
g_free(tempPath);
- return 0;
+ return CString();
}
CString tempFilePath = tempPath;
g_free(tempPath);
diff --git a/WebCore/platform/gtk/GeolocationServiceGtk.cpp b/WebCore/platform/gtk/GeolocationServiceGtk.cpp
index 0c80dd6..cc69d44 100644
--- a/WebCore/platform/gtk/GeolocationServiceGtk.cpp
+++ b/WebCore/platform/gtk/GeolocationServiceGtk.cpp
@@ -20,6 +20,21 @@
#include "config.h"
#include "GeolocationServiceGtk.h"
+#include "CString.h"
+#include "GOwnPtr.h"
+#include "NotImplemented.h"
+#include "PositionOptions.h"
+
+namespace WTF {
+ template<> void freeOwnedGPtr<GeoclueAccuracy>(GeoclueAccuracy* accuracy)
+ {
+ if (!accuracy)
+ return;
+
+ geoclue_accuracy_free(accuracy);
+ }
+}
+
namespace WebCore {
GeolocationService* GeolocationService::create(GeolocationServiceClient* client)
@@ -29,33 +44,170 @@ GeolocationService* GeolocationService::create(GeolocationServiceClient* client)
GeolocationServiceGtk::GeolocationServiceGtk(GeolocationServiceClient* client)
: GeolocationService(client)
-{}
+ , m_geoclueClient(0)
+ , m_geocluePosition(0)
+ , m_latitude(0.0)
+ , m_longitude(0.0)
+ , m_altitude(0.0)
+ , m_altitudeAccuracy(0.0)
+ , m_timestamp(0)
+{
+}
-bool GeolocationServiceGtk::startUpdating(PositionOptions*)
+GeolocationServiceGtk::~GeolocationServiceGtk()
{
- return false;
+ if (m_geoclueClient)
+ g_object_unref(m_geoclueClient);
+
+ if (m_geocluePosition)
+ g_object_unref(m_geocluePosition);
+}
+
+//
+// 1.) Initialize Geoclue with our requirements
+// 2.) Try to get a GeocluePosition
+// 3.) Update the Information and get the current position
+//
+// TODO: Also get GeoclueVelocity but there is no master client
+// API for that.
+//
+bool GeolocationServiceGtk::startUpdating(PositionOptions* options)
+{
+ ASSERT(!m_geoclueClient);
+
+ m_lastPosition = 0;
+ m_lastError = 0;
+
+ GOwnPtr<GError> error;
+ GeoclueMaster* master = geoclue_master_get_default();
+ GeoclueMasterClient* client = geoclue_master_create_client(master, 0, 0);
+ g_object_unref(master);
+
+ if (!client) {
+ setError(PositionError::UNKNOWN_ERROR, "Could not connect to location provider.");
+ return false;
+ }
+
+ GeoclueAccuracyLevel accuracyLevel = GEOCLUE_ACCURACY_LEVEL_LOCALITY;
+ int timeout = 0;
+ if (options) {
+ accuracyLevel = options->enableHighAccuracy() ? GEOCLUE_ACCURACY_LEVEL_DETAILED : GEOCLUE_ACCURACY_LEVEL_LOCALITY;
+ timeout = options->timeout();
+ }
+
+ gboolean result = geoclue_master_client_set_requirements(client, accuracyLevel, timeout,
+ true, GEOCLUE_RESOURCE_ALL, &error.outPtr());
+
+ if (!result) {
+ setError(PositionError::UNKNOWN_ERROR, error->message);
+ g_object_unref(client);
+ return false;
+ }
+
+ m_geocluePosition = geoclue_master_client_create_position(client, &error.outPtr());
+ if (!m_geocluePosition) {
+ setError(PositionError::UNKNOWN_ERROR, error->message);
+ g_object_unref(client);
+ return false;
+ }
+
+ g_signal_connect(G_OBJECT(m_geocluePosition), "position-changed",
+ G_CALLBACK(position_changed), this);
+
+ m_geoclueClient = client;
+ updateLocationInformation();
+
+ return true;
}
void GeolocationServiceGtk::stopUpdating()
{
+ if (!m_geoclueClient)
+ return;
+
+ g_object_unref(m_geocluePosition);
+ g_object_unref(m_geoclueClient);
+
+ m_geocluePosition = 0;
+ m_geoclueClient = 0;
}
void GeolocationServiceGtk::suspend()
{
+ // not available with geoclue
+ notImplemented();
}
void GeolocationServiceGtk::resume()
{
+ // not available with geoclue
+ notImplemented();
}
Geoposition* GeolocationServiceGtk::lastPosition() const
{
- return 0;
+ return m_lastPosition.get();
}
PositionError* GeolocationServiceGtk::lastError() const
{
- return 0;
+ 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;
+
+ RefPtr<Coordinates> coordinates = Coordinates::create(m_latitude, m_longitude,
+ m_altitude, m_accuracy,
+ m_altitudeAccuracy, 0.0, 0.0);
+ m_lastPosition = Geoposition::create(coordinates.release(), m_timestamp * 1000.0);
+ positionChanged();
+}
+
+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)) {
+ that->setError(PositionError::POSITION_UNAVAILABLE, "Position could not be determined.");
+ return;
+ }
+
+ that->m_timestamp = timestamp;
+ that->m_latitude = latitude;
+ that->m_longitude = longitude;
+ that->m_altitude = altitude;
+
+ GeoclueAccuracyLevel level;
+ geoclue_accuracy_get_details(accuracy, &level, &that->m_accuracy, &that->m_altitudeAccuracy);
+ that->updatePosition();
+}
+
+void GeolocationServiceGtk::setError(PositionError::ErrorCode errorCode, const char* message)
+{
+ m_lastPosition = 0;
+ m_lastError = PositionError::create(errorCode, String::fromUTF8(message));
}
}
diff --git a/WebCore/platform/gtk/GeolocationServiceGtk.h b/WebCore/platform/gtk/GeolocationServiceGtk.h
index 02aff2d..90699ad 100644
--- a/WebCore/platform/gtk/GeolocationServiceGtk.h
+++ b/WebCore/platform/gtk/GeolocationServiceGtk.h
@@ -21,11 +21,18 @@
#define GeolocationServiceGtk_h
#include "GeolocationService.h"
+#include "Geoposition.h"
+#include "PositionError.h"
+#include "RefPtr.h"
+
+#include <geoclue/geoclue-master.h>
+#include <geoclue/geoclue-position.h>
namespace WebCore {
class GeolocationServiceGtk : public GeolocationService {
public:
GeolocationServiceGtk(GeolocationServiceClient*);
+ ~GeolocationServiceGtk();
virtual bool startUpdating(PositionOptions*);
virtual void stopUpdating();
@@ -35,6 +42,29 @@ namespace WebCore {
Geoposition* lastPosition() const;
PositionError* lastError() const;
+
+ private:
+ void updateLocationInformation();
+ void setError(PositionError::ErrorCode, const char* message);
+ void updatePosition();
+
+ static void position_changed(GeocluePosition*, GeocluePositionFields, int, double, double, double, GeoclueAccuracy*, GeolocationServiceGtk*);
+
+ private:
+ RefPtr<Geoposition> m_lastPosition;
+ RefPtr<PositionError> m_lastError;
+
+ // state objects
+ GeoclueMasterClient* m_geoclueClient;
+ GeocluePosition* m_geocluePosition;
+
+ // Error and Position state
+ double m_latitude;
+ double m_longitude;
+ double m_altitude;
+ double m_accuracy;
+ double m_altitudeAccuracy;
+ int m_timestamp;
};
}
diff --git a/WebCore/platform/gtk/LoggingGtk.cpp b/WebCore/platform/gtk/LoggingGtk.cpp
index 5bc1559..c46364c 100644
--- a/WebCore/platform/gtk/LoggingGtk.cpp
+++ b/WebCore/platform/gtk/LoggingGtk.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,12 +21,93 @@
#include "config.h"
#include "Logging.h"
+#include <glib.h>
+#include <string.h>
+
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()
{
- // FIXME: Add a way for the user to specify which
- // logs he/she would like turned on.
+ static bool didInitializeLoggingChannels = false;
+ if (didInitializeLoggingChannels)
+ return;
+
+ didInitializeLoggingChannels = true;
+
+ char* logEnv = getenv("WEBKIT_DEBUG");
+ if (!logEnv)
+ return;
+
+ // we set up the logs anyway because some of our logging, such as
+ // soup's is available in release builds
+#if defined(NDEBUG)
+ g_warning("WEBKIT_DEBUG is not empty, but this is a release build. Notice that many log messages will only appear in a debug build.");
+#endif
+
+ char** logv = g_strsplit(logEnv, " ", -1);
+
+ for (int i = 0; logv[i]; i++) {
+ WTFLogChannel* channel = getChannelFromName(logv[i]);
+ if (!channel)
+ continue;
+ channel->state = WTFLogChannelOn;
+ }
+
+ g_strfreev(logv);
+
+ // to disable logging notImplemented set the DISABLE_NI_WARNING
+ // environment variable to 1
LogNotYetImplemented.state = WTFLogChannelOn;
}
diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp
index 85c5aa0..54b41ab 100644
--- a/WebCore/platform/gtk/PopupMenuGtk.cpp
+++ b/WebCore/platform/gtk/PopupMenuGtk.cpp
@@ -52,12 +52,7 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
if (!m_popup) {
m_popup = GTK_MENU(gtk_menu_new());
-#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(G_OBJECT(m_popup));
-#else
- g_object_ref(G_OBJECT(m_popup));
- gtk_object_sink(GTK_OBJECT(m_popup));
-#endif
g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmapped), this);
} else
gtk_container_foreach(GTK_CONTAINER(m_popup), reinterpret_cast<GtkCallback>(menuRemoveItem), this);
diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp
index e1316ee..b3b6dd9 100644
--- a/WebCore/platform/gtk/ScrollViewGtk.cpp
+++ b/WebCore/platform/gtk/ScrollViewGtk.cpp
@@ -154,7 +154,7 @@ bool ScrollView::platformHandleHorizontalAdjustment(const IntSize& scroll)
m_horizontalAdjustment->upper = contentsWidth();
gtk_adjustment_changed(m_horizontalAdjustment);
- if (m_scrollOffset.width() != scroll.width()) {
+ if (m_horizontalAdjustment->value != scroll.width()) {
m_horizontalAdjustment->value = scroll.width();
gtk_adjustment_value_changed(m_horizontalAdjustment);
}
@@ -173,7 +173,7 @@ bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll)
m_verticalAdjustment->upper = contentsHeight();
gtk_adjustment_changed(m_verticalAdjustment);
- if (m_scrollOffset.height() != scroll.height()) {
+ if (m_verticalAdjustment->value != scroll.height()) {
m_verticalAdjustment->value = scroll.height();
gtk_adjustment_value_changed(m_verticalAdjustment);
}
diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp
index df165e3..7543e23 100644
--- a/WebCore/platform/gtk/ScrollbarGtk.cpp
+++ b/WebCore/platform/gtk/ScrollbarGtk.cpp
@@ -44,19 +44,18 @@ static gboolean gtkScrollEventCallback(GtkWidget* widget, GdkEventScroll* event,
}
ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation,
- ScrollbarControlSize controlSize)
+ ScrollbarControlSize controlSize)
: Scrollbar(client, orientation, controlSize)
, m_adjustment(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)))
{
- GtkScrollbar* scrollBar = orientation == HorizontalScrollbar ?
- GTK_SCROLLBAR(::gtk_hscrollbar_new(m_adjustment)) :
- GTK_SCROLLBAR(::gtk_vscrollbar_new(m_adjustment));
- gtk_widget_show(GTK_WIDGET(scrollBar));
- g_object_ref(G_OBJECT(scrollBar));
- g_signal_connect(G_OBJECT(scrollBar), "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
- g_signal_connect(G_OBJECT(scrollBar), "scroll-event", G_CALLBACK(gtkScrollEventCallback), this);
+ GtkWidget* scrollBar = orientation == HorizontalScrollbar ?
+ gtk_hscrollbar_new(m_adjustment):
+ gtk_vscrollbar_new(m_adjustment);
+ gtk_widget_show(scrollBar);
+ g_signal_connect(scrollBar, "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
+ g_signal_connect(scrollBar, "scroll-event", G_CALLBACK(gtkScrollEventCallback), this);
- setPlatformWidget(GTK_WIDGET(scrollBar));
+ setPlatformWidget(scrollBar);
/*
* assign a sane default width and height to the Scrollbar, otherwise
@@ -66,22 +65,24 @@ ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orienta
ScrollbarTheme::nativeTheme()->scrollbarThickness());
}
-ScrollbarGtk::~ScrollbarGtk()
+IntPoint ScrollbarGtk::getLocationInParentWindow(const IntRect& rect)
{
- /*
- * the Widget does not take over ownership.
- */
- g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)ScrollbarGtk::gtkValueChanged, this);
- g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)gtkScrollEventCallback, this);
- g_object_unref(G_OBJECT(platformWidget()));
+ IntPoint loc;
+
+ if (parent()->isScrollViewScrollbar(this))
+ loc = parent()->convertToContainingWindow(rect.location());
+ else
+ loc = parent()->contentsToWindow(rect.location());
+
+ return loc;
}
void ScrollbarGtk::frameRectsChanged()
{
- if (!parent() || !parent()->isScrollViewScrollbar(this))
+ if (!parent())
return;
- IntPoint loc = parent()->convertToContainingWindow(frameRect().location());
+ IntPoint loc = getLocationInParentWindow(frameRect());
// Don't allow the allocation size to be negative
IntSize sz = frameRect().size();
@@ -129,5 +130,44 @@ void ScrollbarGtk::setEnabled(bool shouldEnable)
gtk_widget_set_sensitive(platformWidget(), 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
+ * the widget correctly. ATM we do not honor the GraphicsContext translation.
+ */
+void ScrollbarGtk::paint(GraphicsContext* context, const IntRect& rect)
+{
+ if (!platformWidget())
+ return;
+
+ if (!context->gdkExposeEvent())
+ return;
+
+ GtkWidget* widget = platformWidget();
+ ASSERT(GTK_WIDGET_NO_WINDOW(widget));
+ GdkEvent* event = gdk_event_new(GDK_EXPOSE);
+ event->expose = *context->gdkExposeEvent();
+ event->expose.area = static_cast<GdkRectangle>(rect);
+ IntPoint loc = getLocationInParentWindow(rect);
+
+ event->expose.area.x = loc.x();
+ event->expose.area.y = loc.y();
+
+ event->expose.region = gdk_region_rectangle(&event->expose.area);
+
+ /*
+ * This will be unref'ed by gdk_event_free.
+ */
+ g_object_ref(event->expose.window);
+
+ /*
+ * If we are going to paint do the translation and GtkAllocation manipulation.
+ */
+ if (!gdk_region_empty(event->expose.region))
+ gtk_widget_send_expose(widget, event);
+
+ gdk_event_free(event);
+}
diff --git a/WebCore/platform/gtk/ScrollbarGtk.h b/WebCore/platform/gtk/ScrollbarGtk.h
index 11ff079..1ef4c49 100644
--- a/WebCore/platform/gtk/ScrollbarGtk.h
+++ b/WebCore/platform/gtk/ScrollbarGtk.h
@@ -37,9 +37,8 @@ class ScrollbarGtk : public Scrollbar {
public:
friend class Scrollbar;
- virtual ~ScrollbarGtk();
-
virtual void setFrameRect(const IntRect&);
+ virtual void paint(GraphicsContext*, const IntRect&);
virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) { return false; }
virtual bool handleMouseOutEvent(const PlatformMouseEvent&) { return false; }
@@ -58,6 +57,7 @@ protected:
private:
static void gtkValueChanged(GtkAdjustment*, ScrollbarGtk*);
+ IntPoint getLocationInParentWindow(const IntRect&);
GtkAdjustment* m_adjustment;
};
diff --git a/WebCore/platform/gtk/WheelEventGtk.cpp b/WebCore/platform/gtk/WheelEventGtk.cpp
index 64ec65a..075bed2 100644
--- a/WebCore/platform/gtk/WheelEventGtk.cpp
+++ b/WebCore/platform/gtk/WheelEventGtk.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#include "PlatformWheelEvent.h"
+#include "Scrollbar.h"
#include <gdk/gdk.h>
@@ -52,16 +53,18 @@ PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
m_deltaY = -delta;
break;
case GDK_SCROLL_LEFT:
- m_deltaX = -delta;
+ m_deltaX = delta;
break;
case GDK_SCROLL_RIGHT:
- m_deltaX = delta;
+ m_deltaX = -delta;
break;
}
+ m_wheelTicksX = m_deltaX;
+ m_wheelTicksY = m_deltaY;
- m_position = IntPoint((int)event->x, (int)event->y);
- m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
- m_granularity = ScrollByLineWheelEvent;
+ m_position = IntPoint(static_cast<int>(event->x), static_cast<int>(event->y));
+ m_globalPosition = IntPoint(static_cast<int>(event->x_root), static_cast<int>(event->y_root));
+ m_granularity = ScrollByPixelWheelEvent;
m_isAccepted = false;
m_shiftKey = event->state & GDK_SHIFT_MASK;
m_ctrlKey = event->state & GDK_CONTROL_MASK;
@@ -74,8 +77,8 @@ PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
#endif
// FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
- m_deltaX *= horizontalLineMultiplier();
- m_deltaY *= verticalLineMultiplier();
+ m_deltaX *= static_cast<float>(cScrollbarPixelsPerLineStep);
+ m_deltaY *= static_cast<float>(cScrollbarPixelsPerLineStep);
}
}
diff --git a/WebCore/platform/gtk/WidgetGtk.cpp b/WebCore/platform/gtk/WidgetGtk.cpp
index 82fed74..4f09e77 100644
--- a/WebCore/platform/gtk/WidgetGtk.cpp
+++ b/WebCore/platform/gtk/WidgetGtk.cpp
@@ -41,23 +41,17 @@
namespace WebCore {
-class WidgetPrivate {
-public:
- GdkCursor* cursor;
-};
+static GdkCursor* lastSetCursor;
Widget::Widget(PlatformWidget widget)
- : m_data(new WidgetPrivate)
{
init(widget);
- m_data->cursor = 0;
}
Widget::~Widget()
{
ASSERT(!parent());
releasePlatformWidget();
- delete m_data;
}
void Widget::setFocus()
@@ -65,11 +59,6 @@ void Widget::setFocus()
gtk_widget_grab_focus(platformWidget() ? platformWidget() : GTK_WIDGET(root()->hostWindow()->platformWindow()));
}
-Cursor Widget::cursor()
-{
- return Cursor(m_data->cursor);
-}
-
static GdkDrawable* gdkDrawable(PlatformWidget widget)
{
return widget ? widget->window : 0;
@@ -77,7 +66,7 @@ static GdkDrawable* gdkDrawable(PlatformWidget widget)
void Widget::setCursor(const Cursor& cursor)
{
- GdkCursor* pcur = cursor.impl();
+ GdkCursor* platformCursor = cursor.impl();
// http://bugs.webkit.org/show_bug.cgi?id=16388
// [GTK] Widget::setCursor() gets called frequently
@@ -85,11 +74,11 @@ void Widget::setCursor(const Cursor& cursor)
// gdk_window_set_cursor() in certain GDK backends seems to be an
// expensive operation, so avoid it if possible.
- if (pcur == m_data->cursor)
+ if (platformCursor == lastSetCursor)
return;
- gdk_window_set_cursor(gdkDrawable(platformWidget()) ? GDK_WINDOW(gdkDrawable(platformWidget())) : GTK_WIDGET(root()->hostWindow()->platformWindow())->window, pcur);
- m_data->cursor = pcur;
+ gdk_window_set_cursor(gdkDrawable(platformWidget()) ? GDK_WINDOW(gdkDrawable(platformWidget())) : GTK_WIDGET(root()->hostWindow()->platformWindow())->window, platformCursor);
+ lastSetCursor = platformCursor;
}
void Widget::show()
@@ -106,41 +95,8 @@ void Widget::hide()
gtk_widget_hide(platformWidget());
}
-/*
- * 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
- * the widget correctly. ATM we do not honor the GraphicsContext translation.
- */
-void Widget::paint(GraphicsContext* context, const IntRect&)
+void Widget::paint(GraphicsContext* context, const IntRect& rect)
{
- if (!platformWidget())
- return;
-
- if (!context->gdkExposeEvent())
- return;
-
- GtkWidget* widget = platformWidget();
- ASSERT(GTK_WIDGET_NO_WINDOW(widget));
-
- GdkEvent* event = gdk_event_new(GDK_EXPOSE);
- event->expose = *context->gdkExposeEvent();
- event->expose.region = gtk_widget_region_intersect(widget, event->expose.region);
-
- /*
- * This will be unref'ed by gdk_event_free.
- */
- g_object_ref(event->expose.window);
-
- /*
- * If we are going to paint do the translation and GtkAllocation manipulation.
- */
- if (!gdk_region_empty(event->expose.region)) {
- gdk_region_get_clipbox(event->expose.region, &event->expose.area);
- gtk_widget_send_expose(widget, event);
- }
-
- gdk_event_free(event);
}
void Widget::setIsSelected(bool)
@@ -169,12 +125,7 @@ void Widget::retainPlatformWidget()
{
if (!platformWidget())
return;
-#if GLIB_CHECK_VERSION(2,10,0)
g_object_ref_sink(platformWidget());
-#else
- g_object_ref(platformWidget());
- gtk_object_sink(GTK_OBJECT(platformWidget()));
-#endif
}
}