summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-06-15 19:36:43 +0100
committerBen Murdoch <benm@google.com>2010-06-16 14:52:28 +0100
commit545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch)
treec0c14763654d84d37577dde512c3d3b4699a9e86 /WebKit/gtk/webkit
parent719298a66237d38ea5c05f1547123ad8aacbc237 (diff)
downloadexternal_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip
external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz
external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'WebKit/gtk/webkit')
-rw-r--r--WebKit/gtk/webkit/webkithittestresult.cpp33
-rw-r--r--WebKit/gtk/webkit/webkitprivate.cpp20
-rw-r--r--WebKit/gtk/webkit/webkitprivate.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebinspector.cpp1
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp147
5 files changed, 148 insertions, 57 deletions
diff --git a/WebKit/gtk/webkit/webkithittestresult.cpp b/WebKit/gtk/webkit/webkithittestresult.cpp
index 1f8dce6..862d94a 100644
--- a/WebKit/gtk/webkit/webkithittestresult.cpp
+++ b/WebKit/gtk/webkit/webkithittestresult.cpp
@@ -22,6 +22,7 @@
#include "webkithittestresult.h"
#include "GOwnPtr.h"
+#include "WebKitDOMNode.h"
#include "webkitenumtypes.h"
#include "webkitprivate.h"
#include <wtf/text/CString.h>
@@ -43,6 +44,7 @@ struct _WebKitHitTestResultPrivate {
char* linkURI;
char* imageURI;
char* mediaURI;
+ WebKitDOMNode* innerNode;
};
#define WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate))
@@ -53,7 +55,8 @@ enum {
PROP_CONTEXT,
PROP_LINK_URI,
PROP_IMAGE_URI,
- PROP_MEDIA_URI
+ PROP_MEDIA_URI,
+ PROP_INNER_NODE
};
static void webkit_hit_test_result_finalize(GObject* object)
@@ -86,6 +89,9 @@ static void webkit_hit_test_result_get_property(GObject* object, guint propertyI
case PROP_MEDIA_URI:
g_value_set_string(value, priv->mediaURI);
break;
+ case PROP_INNER_NODE:
+ g_value_set_object(value, priv->innerNode);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
}
@@ -112,6 +118,9 @@ static void webkit_hit_test_result_set_property(GObject* object, guint propertyI
g_free (priv->mediaURI);
priv->mediaURI = g_value_dup_string(value);
break;
+ case PROP_INNER_NODE:
+ priv->innerNode = static_cast<WebKitDOMNode*>(g_value_get_object(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
}
@@ -184,6 +193,28 @@ static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* webHitTe
NULL,
static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+ /**
+ * WebKitHitTestResult:inner-node:
+ *
+ * The DOM node at the coordinates where the hit test
+ * happened. Keep in mind that the node might not be
+ * representative of the information given in the context
+ * property, since WebKit uses a series of heuristics to figure
+ * out that information. One common example is inner-node having
+ * the text node inside the anchor (<a>) tag; WebKit knows the
+ * whole context and will put WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK
+ * in the 'context' property, but the user might be confused by
+ * the lack of any link tag in 'inner-node'.
+ *
+ * Since: 1.3.2
+ */
+ g_object_class_install_property(objectClass, PROP_INNER_NODE,
+ g_param_spec_object("inner-node",
+ _("Inner node"),
+ _("The inner DOM node associated with the hit test result."),
+ WEBKIT_TYPE_DOM_NODE,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate));
}
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index d274708..41de76e 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -41,6 +41,7 @@
#include "ResourceResponse.h"
#include "SecurityOrigin.h"
#include "TextEncodingRegistry.h"
+#include "WebKitDOMBinding.h"
#include "webkitnetworkresponse.h"
#include "webkitsoupauthdialog.h"
#include <libintl.h>
@@ -129,9 +130,9 @@ WebCore::ResourceResponse core(WebKitNetworkResponse* response)
return ResourceResponse();
}
-WebCore::EditingBehavior core(WebKitEditingBehavior type)
+WebCore::EditingBehaviorType core(WebKitEditingBehavior type)
{
- return (WebCore::EditingBehavior)type;
+ return (WebCore::EditingBehaviorType)type;
}
WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
@@ -140,6 +141,7 @@ WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
GOwnPtr<char> linkURI(0);
GOwnPtr<char> imageURI(0);
GOwnPtr<char> mediaURI(0);
+ WebKitDOMNode* node = 0;
if (!result.absoluteLinkURL().isEmpty()) {
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
@@ -162,12 +164,16 @@ WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
if (result.isContentEditable())
context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+ if (result.innerNonSharedNode())
+ node = static_cast<WebKitDOMNode*>(kit(result.innerNonSharedNode()));
+
return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
- "link-uri", linkURI.get(),
- "image-uri", imageURI.get(),
- "media-uri", mediaURI.get(),
- "context", context,
- NULL));
+ "link-uri", linkURI.get(),
+ "image-uri", imageURI.get(),
+ "media-uri", mediaURI.get(),
+ "context", context,
+ "inner-node", node,
+ NULL));
}
PasteboardHelperGtk* pasteboardHelperInstance()
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 057b0e5..44ffc1e 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -95,7 +95,7 @@ namespace WebKit {
WebCore::ResourceResponse core(WebKitNetworkResponse* response);
- WebCore::EditingBehavior core(WebKitEditingBehavior type);
+ WebCore::EditingBehaviorType core(WebKitEditingBehavior type);
WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*);
WebCore::SecurityOrigin* core(WebKitSecurityOrigin*);
@@ -241,7 +241,7 @@ extern "C" {
webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse(), WebCore::ResourceHandle* handle = 0);
void
- webkit_web_view_add_resource(WebKitWebView*, char*, WebKitWebResource*);
+ webkit_web_view_add_resource(WebKitWebView*, const char*, WebKitWebResource*);
WebKitWebResource*
webkit_web_view_get_resource(WebKitWebView*, char*);
diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp
index 820b20f..2dc9315 100644
--- a/WebKit/gtk/webkit/webkitwebinspector.cpp
+++ b/WebKit/gtk/webkit/webkitwebinspector.cpp
@@ -30,6 +30,7 @@
#include "InspectorClientGtk.h"
#include "IntPoint.h"
#include "Page.h"
+#include "RenderLayer.h"
#include "RenderView.h"
#include "webkitmarshal.h"
#include "webkitprivate.h"
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 2c95558..6744732 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -63,6 +63,7 @@
#include "FrameView.h"
#include <glib/gi18n-lib.h>
#include <GOwnPtr.h>
+#include <GOwnPtrGtk.h>
#include "GraphicsContext.h"
#include "GtkVersioning.h"
#include "HitTestRequest.h"
@@ -370,7 +371,7 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
}
int x, y;
- gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformPageClient())->window, &x, &y);
+ gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient())), &x, &y);
// FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element.
// Ideally we'd have the position of a context menu event be separate from its target node.
@@ -588,11 +589,52 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey
static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* 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;
+
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
// FIXME: need to keep track of subframe focus for key events
gtk_widget_grab_focus(widget);
+ // For double and triple clicks GDK sends both a normal button press event
+ // and a specific type (like GDK_2BUTTON_PRESS). If we detect a special press
+ // coming up, ignore this event as it certainly generated the double or triple
+ // click. The consequence of not eating this event is two DOM button press events
+ // are generated.
+ GOwnPtr<GdkEvent> nextEvent(gdk_event_peek());
+ if (nextEvent && (nextEvent->any.type == GDK_2BUTTON_PRESS || nextEvent->any.type == GDK_3BUTTON_PRESS))
+ return TRUE;
+
+ gint doubleClickDistance = 250;
+ gint doubleClickTime = 5;
+ GtkSettings* settings = gtk_settings_get_for_screen(gdk_drawable_get_screen(gtk_widget_get_window(widget)));
+ g_object_get(settings,
+ "gtk-double-click-distance", &doubleClickDistance,
+ "gtk-double-click-time", &doubleClickTime, NULL);
+
+ // 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.
+ 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++;
+ else
+ currentClickCount = 1;
+
+ PlatformMouseEvent platformEvent(event);
+ platformEvent.setClickCount(currentClickCount);
+ previousPoint = platformEvent.pos();
+ previousButton = event->button;
+ previousTime = event->time;
+
if (event->button == 3)
return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
@@ -600,7 +642,8 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
if (!frame->view())
return FALSE;
- gboolean result = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+
+ gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent);
#if PLATFORM(X11)
/* Copy selection to the X11 selection clipboard */
@@ -2695,7 +2738,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
- settings->setEditingBehavior(core(editingBehavior));
+ settings->setEditingBehaviorType(core(editingBehavior));
settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI);
settings->setAllowFileAccessFromFileURLs(enableFileAccessFromFileURI);
settings->setDOMPasteAllowed(enableDOMPaste);
@@ -2796,7 +2839,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
else if (name == g_intern_string("enable-offline-web-application-cache"))
settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
else if (name == g_intern_string("editing-behavior"))
- settings->setEditingBehavior(core(static_cast<WebKitEditingBehavior>(g_value_get_enum(&value))));
+ settings->setEditingBehaviorType(core(static_cast<WebKitEditingBehavior>(g_value_get_enum(&value))));
else if (name == g_intern_string("enable-universal-access-from-file-uris"))
settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value));
else if (name == g_intern_string("enable-file-access-from-file-uris"))
@@ -3892,24 +3935,6 @@ void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoom
}
/**
- * webkit_get_default_session:
- *
- * Retrieves the default #SoupSession used by all web views.
- * Note that the session features are added by WebKit on demand,
- * so if you insert your own #SoupCookieJar before any network
- * traffic occurs, WebKit will use it instead of the default.
- *
- * Return value: the default #SoupSession
- *
- * Since: 1.1.1
- */
-SoupSession* webkit_get_default_session ()
-{
- webkit_init();
- return ResourceHandle::defaultSession();
-}
-
-/**
* webkit_web_view_get_load_status:
* @web_view: a #WebKitWebView
*
@@ -4152,7 +4177,7 @@ gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView)
}
// Internal subresource management
-void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebKitWebResource* webResource)
+void webkit_web_view_add_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource)
{
WebKitWebViewPrivate* priv = webView->priv;
@@ -4162,7 +4187,7 @@ void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebK
return;
}
- g_hash_table_insert(priv->subResources, identifier, webResource);
+ g_hash_table_insert(priv->subResources, g_strdup(identifier), webResource);
}
WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier)
@@ -4295,6 +4320,57 @@ G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView)
}
/**
+ * webkit_web_view_get_dom_document:
+ * @webView: a #WebKitWebView
+ *
+ * Returns: the #WebKitDOMDocument currently loaded in the @webView
+ *
+ * Since: 1.3.1
+ **/
+WebKitDOMDocument*
+webkit_web_view_get_dom_document(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ Frame* coreFrame = core(webView)->mainFrame();
+ if (!coreFrame)
+ return 0;
+
+ Document* doc = coreFrame->document();
+ if (!doc)
+ return 0;
+
+ return static_cast<WebKitDOMDocument*>(kit(doc));
+}
+
+/**
+ * SECTION:webkit
+ * @short_description: Global functions controlling WebKit
+ *
+ * WebKit manages many resources which are not related to specific
+ * views. These functions relate to cross-view limits, such as cache
+ * sizes, database quotas, and the HTTP session management.
+ */
+
+/**
+ * webkit_get_default_session:
+ *
+ * Retrieves the default #SoupSession used by all web views.
+ * Note that the session features are added by WebKit on demand,
+ * so if you insert your own #SoupCookieJar before any network
+ * traffic occurs, WebKit will use it instead of the default.
+ *
+ * Return value: the default #SoupSession
+ *
+ * Since: 1.1.1
+ */
+SoupSession* webkit_get_default_session ()
+{
+ webkit_init();
+ return ResourceHandle::defaultSession();
+}
+
+/**
* webkit_set_cache_model:
* @cache_model: a #WebKitCacheModel
*
@@ -4375,26 +4451,3 @@ WebKitCacheModel webkit_get_cache_model()
return cacheModel;
}
-/**
- * webkit_web_view_get_dom_document:
- * @webView: a #WebKitWebView
- *
- * Returns: the #WebKitDOMDocument currently loaded in the @webView
- *
- * Since: 1.3.1
- **/
-WebKitDOMDocument*
-webkit_web_view_get_dom_document(WebKitWebView* webView)
-{
- g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
-
- Frame* coreFrame = core(webView)->mainFrame();
- if (!coreFrame)
- return 0;
-
- Document* doc = coreFrame->document();
- if (!doc)
- return 0;
-
- return static_cast<WebKitDOMDocument*>(kit(doc));
-}