summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit/webkitwebview.cpp
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-06-28 16:42:48 +0100
committerKristian Monsen <kristianm@google.com>2010-07-02 10:29:56 +0100
commit06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch)
tree20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebKit/gtk/webkit/webkitwebview.cpp
parent72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff)
downloadexternal_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip
external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz
external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebKit/gtk/webkit/webkitwebview.cpp')
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp99
1 files changed, 63 insertions, 36 deletions
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 6744732..ce2bbc6 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -41,6 +41,7 @@
#include "webkitwebhistoryitem.h"
#include "AXObjectCache.h"
+#include "AbstractDatabase.h"
#include "BackForwardList.h"
#include "Cache.h"
#include "ChromeClientGtk.h"
@@ -49,7 +50,6 @@
#include "ContextMenuController.h"
#include "ContextMenu.h"
#include "Cursor.h"
-#include "Database.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "DragClientGtk.h"
@@ -587,16 +587,25 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event);
}
-static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
+static guint32 getEventTime(GdkEvent* event)
{
- // Eventually it may make sense for these to be per-view and per-device,
- // but at this time the implementation matches the Windows port.
- static int currentClickCount = 1;
- static IntPoint previousPoint;
- static guint previousButton;
- static guint32 previousTime;
+ guint32 time = gdk_event_get_time(event);
+ if (time)
+ return time;
+
+ // Real events always have a non-zero time, but events synthesized
+ // by the DRT do not and we must calculate a time manually. This time
+ // is not calculated in the DRT, because GTK+ does not work well with
+ // anything other than GDK_CURRENT_TIME on synthesized events.
+ GTimeVal timeValue;
+ g_get_current_time(&timeValue);
+ return (timeValue.tv_sec * 1000) + (timeValue.tv_usec / 1000);
+}
+static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
+{
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ WebKitWebViewPrivate* priv = webView->priv;
// FIXME: need to keep track of subframe focus for key events
gtk_widget_grab_focus(widget);
@@ -620,20 +629,21 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
// GTK+ only counts up to triple clicks, but WebCore wants to know about
// quadruple clicks, quintuple clicks, ad infinitum. Here, we replicate the
// GDK logic for counting clicks.
+ guint32 eventTime = getEventTime(reinterpret_cast<GdkEvent*>(event));
if ((event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS)
- || ((abs(event->x - previousPoint.x()) < doubleClickDistance)
- && (abs(event->y - previousPoint.y()) < doubleClickDistance)
- && (event->time - previousTime < static_cast<guint>(doubleClickTime))
- && (event->button == previousButton)))
- currentClickCount++;
+ || ((abs(event->x - priv->previousClickPoint->x()) < doubleClickDistance)
+ && (abs(event->y - priv->previousClickPoint->y()) < doubleClickDistance)
+ && (eventTime - priv->previousClickTime < static_cast<guint>(doubleClickTime))
+ && (event->button == priv->previousClickButton)))
+ priv->currentClickCount++;
else
- currentClickCount = 1;
+ priv->currentClickCount = 1;
PlatformMouseEvent platformEvent(event);
- platformEvent.setClickCount(currentClickCount);
- previousPoint = platformEvent.pos();
- previousButton = event->button;
- previousTime = event->time;
+ platformEvent.setClickCount(priv->currentClickCount);
+ *priv->previousClickPoint = platformEvent.pos();
+ priv->previousClickButton = event->button;
+ priv->previousClickTime = eventTime;
if (event->button == 3)
return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
@@ -799,17 +809,24 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus
static void webkit_web_view_realize(GtkWidget* widget)
{
- GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+ gtk_widget_set_realized(widget, TRUE);
+
+ GtkAllocation allocation;
+#if GTK_CHECK_VERSION(2, 18, 0)
+ gtk_widget_get_allocation(widget, &allocation);
+#else
+ allocation = widget->allocation;
+#endif
GdkWindowAttr attributes;
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
+ attributes.visual = gtk_widget_get_visual(widget);
+ attributes.colormap = gtk_widget_get_colormap(widget);
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
| GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK
@@ -823,15 +840,20 @@ static void webkit_web_view_realize(GtkWidget* widget)
| GDK_BUTTON3_MOTION_MASK;
gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new(gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data(widget->window, widget);
+ GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
+ gtk_widget_set_window(widget, window);
+ gdk_window_set_user_data(window, widget);
- widget->style = gtk_style_attach(widget->style, widget->window);
- gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
+#if GTK_CHECK_VERSION(2, 20, 0)
+ gtk_widget_style_attach(widget);
+#else
+ widget->style = gtk_style_attach(gtk_widget_get_style(widget), window);
+#endif
+ gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL);
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
WebKitWebViewPrivate* priv = webView->priv;
- gtk_im_context_set_client_window(priv->imContext, widget->window);
+ gtk_im_context_set_client_window(priv->imContext, window);
}
static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj)
@@ -970,7 +992,7 @@ static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebF
if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) {
entry = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(entry), defaultValue);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), entry);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_widget_show(entry);
}
@@ -1184,6 +1206,8 @@ static void webkit_web_view_finalize(GObject* object)
g_free(priv->customEncoding);
g_free(priv->iconURI);
+ delete priv->previousClickPoint;
+
G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
}
@@ -1312,7 +1336,7 @@ static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
event->button.state = modifiers;
PlatformMouseEvent platformEvent(&event->button);
- frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(context->action));
+ frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
gdk_event_free(event);
}
@@ -2730,7 +2754,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setPrivateBrowsingEnabled(enablePrivateBrowsing);
settings->setCaretBrowsingEnabled(enableCaretBrowsing);
#if ENABLE(DATABASE)
- Database::setIsAvailable(enableHTML5Database);
+ AbstractDatabase::setIsAvailable(enableHTML5Database);
#endif
settings->setLocalStorageEnabled(enableHTML5LocalStorage);
settings->setXSSAuditorEnabled(enableXSSAuditor);
@@ -2823,7 +2847,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setCaretBrowsingEnabled(g_value_get_boolean(&value));
#if ENABLE(DATABASE)
else if (name == g_intern_string("enable-html5-database")) {
- Database::setIsAvailable(g_value_get_boolean(&value));
+ AbstractDatabase::setIsAvailable(g_value_get_boolean(&value));
}
#endif
else if (name == g_intern_string("enable-html5-local-storage"))
@@ -2882,7 +2906,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
g_object_ref_sink(priv->horizontalAdjustment);
g_object_ref_sink(priv->verticalAdjustment);
- GTK_WIDGET_SET_FLAGS(webView, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(GTK_WIDGET(webView), TRUE);
priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView));
priv->lastPopupXPosition = priv->lastPopupYPosition = -1;
priv->editable = false;
@@ -2900,6 +2924,10 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
priv->tooltipText = 0;
+ priv->currentClickCount = 0;
+ priv->previousClickPoint = new IntPoint(0, 0);
+ priv->previousClickButton = 0;
+ priv->previousClickTime = 0;
}
GtkWidget* webkit_web_view_new(void)
@@ -4450,4 +4478,3 @@ WebKitCacheModel webkit_get_cache_model()
webkit_init();
return cacheModel;
}
-