Commit 2421f66e authored by andersca@apple.com's avatar andersca@apple.com

.:

2008-03-20  Jasper Bryant-Greene  <jasper@unix.geek.nz>

        Reviewed by Anders.

        Resolves http://bugs.webkit.org/show_bug.cgi?id=16092
        "[GTK] Middle-mouse click should allow opening a URL in a new tab"

        Added WebKitNavigationAction object to GTK API

        * GNUmakefile.am:

WebKit/gtk:

2008-03-20  Jasper Bryant-Greene  <jasper@unix.geek.nz>

        Reviewed and tweaked by Anders.

        Resolves http://bugs.webkit.org/show_bug.cgi?id=16092
        "[GTK] Middle-mouse click should allow opening a URL in a new tab"

        Created WebKitNavigationAction object exported through the API. The
        navigation-requested signal provides this object as context for the
        requested navigation, allowing the application to decide what to do
        with the navigation based on which mouse button was used, which
        modifier keys were held down, etc. This allows, for example, the
        application to open links in a new tab when either middle-click or
        control-click are used to initiate the navigation.

        * WebCoreSupport/FrameLoaderClientGtk.cpp:
        (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction):
        * webkit/headers.pri:
        * webkit/webkit-marshal.list:
        * webkit/webkitdefines.h:
        * webkit/webkitnavigationaction.cpp: Added.
        (webkit_navigation_action_finalize):
        (webkit_navigation_action_class_init):
        (webkit_navigation_action_init):
        (webkit_navigation_action_get_button):
        (webkit_navigation_action_get_modifier_flags):
        (webkit_navigation_action_get_navigation_type):
        (webkit_navigation_action_get_original_url):
        * webkit/webkitnavigationaction.h: Added.
        * webkit/webkitprivate.cpp:
        (WebKit::kit):
        * webkit/webkitprivate.h:
        * webkit/webkitwebview.cpp:
        * webkit/webkitwebview.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 531811b8
2008-03-20 Jasper Bryant-Greene <jasper@unix.geek.nz>
Reviewed by Anders.
Resolves http://bugs.webkit.org/show_bug.cgi?id=16092
"[GTK] Middle-mouse click should allow opening a URL in a new tab"
Added WebKitNavigationAction object to GTK API
* GNUmakefile.am:
2008-03-12 Xan Lopez <xan@gnome.org>
Reviewed by Alp Toker.
......
2008-03-20 Jasper Bryant-Greene <jasper@unix.geek.nz>
Reviewed and tweaked by Anders.
Resolves http://bugs.webkit.org/show_bug.cgi?id=16092
"[GTK] Middle-mouse click should allow opening a URL in a new tab"
Created WebKitNavigationAction object exported through the API. The
navigation-requested signal provides this object as context for the
requested navigation, allowing the application to decide what to do
with the navigation based on which mouse button was used, which
modifier keys were held down, etc. This allows, for example, the
application to open links in a new tab when either middle-click or
control-click are used to initiate the navigation.
* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* webkit/headers.pri:
* webkit/webkit-marshal.list:
* webkit/webkitdefines.h:
* webkit/webkitnavigationaction.cpp: Added.
(webkit_navigation_action_finalize):
(webkit_navigation_action_class_init):
(webkit_navigation_action_init):
(webkit_navigation_action_get_button):
(webkit_navigation_action_get_modifier_flags):
(webkit_navigation_action_get_navigation_type):
(webkit_navigation_action_get_original_url):
* webkit/webkitnavigationaction.h: Added.
* webkit/webkitprivate.cpp:
(WebKit::kit):
* webkit/webkitprivate.h:
* webkit/webkitwebview.cpp:
* webkit/webkitwebview.h:
2008-03-18 Rodney Dawes <dobey@wayofthemonkey.com>
Reviewed and landed by jhoneycutt.
......
......@@ -40,6 +40,7 @@
#include "ProgressTracker.h"
#include "kjs_binding.h"
#include "kjs_proxy.h"
#include "webkitnavigationaction.h"
#include "webkitwebview.h"
#include "webkitwebframe.h"
#include "webkitprivate.h"
......@@ -245,9 +246,9 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct
WebKitWebView* webView = getViewFromFrame(m_frame);
WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data());
WebKitNavigationResponse response;
WebKitNavigationResponse response = WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response);
g_signal_emit_by_name(webView, "navigation-requested", kit(action), m_frame, request, &response);
g_object_unref(request);
......
WEBKIT_API_HEADERS = $$PWD/webkit.h \
$$PWD/webkitdefines.h \
$$PWD/webkitnavigationaction.h \
$$PWD/webkitnetworkrequest.h \
$$PWD/webkitwebbackforwardlist.h \
$$PWD/webkitwebframe.h \
......
......@@ -10,3 +10,4 @@ BOOLEAN:OBJECT,STRING
BOOLEAN:OBJECT,STRING,BOOLEAN
BOOLEAN:OBJECT,STRING,STRING,STRING
INT:OBJECT,OBJECT
INT:OBJECT,OBJECT,OBJECT
......@@ -40,6 +40,9 @@
G_BEGIN_DECLS
typedef struct _WebKitNavigationAction WebKitNavigationAction;
typedef struct _WebKitNavigationActionClass WebKitNavigationActionClass;
typedef struct _WebKitNetworkRequest WebKitNetworkRequest;
typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass;
......
/*
* Copyright (C) 2008 Jasper Bryant-Greene <jasper@unix.geek.nz>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "webkitnavigationaction.h"
extern "C" {
G_DEFINE_TYPE(WebKitNavigationAction, webkit_navigation_action, G_TYPE_OBJECT);
struct _WebKitNavigationActionPrivate {
gint button;
gint modifierFlags;
gint navigationType;
gchar* originalURL;
};
#define WEBKIT_NAVIGATION_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NAVIGATION_ACTION, WebKitNavigationActionPrivate))
static void webkit_navigation_action_finalize(GObject* object)
{
WebKitNavigationAction* action = WEBKIT_NAVIGATION_ACTION(object);
WebKitNavigationActionPrivate* priv = action->priv;
g_free(priv->originalURL);
G_OBJECT_CLASS(webkit_navigation_action_parent_class)->finalize(object);
}
static void webkit_navigation_action_class_init(WebKitNavigationActionClass* klass)
{
G_OBJECT_CLASS(klass)->finalize = webkit_navigation_action_finalize;
g_type_class_add_private(klass, sizeof(WebKitNavigationActionPrivate));
}
static void webkit_navigation_action_init(WebKitNavigationAction* action)
{
WebKitNavigationActionPrivate* priv = WEBKIT_NAVIGATION_ACTION_GET_PRIVATE(action);
action->priv = priv;
}
gint webkit_navigation_action_get_button(WebKitNavigationAction* action)
{
g_return_val_if_fail(WEBKIT_IS_NAVIGATION_ACTION(action), 0);
return action->priv->button;
}
gint webkit_navigation_action_get_modifier_flags(WebKitNavigationAction* action)
{
g_return_val_if_fail(WEBKIT_IS_NAVIGATION_ACTION(action), 0);
return action->priv->modifierFlags;
}
gint webkit_navigation_action_get_navigation_type(WebKitNavigationAction* action)
{
g_return_val_if_fail(WEBKIT_IS_NAVIGATION_ACTION(action), 0);
return action->priv->navigationType;
}
G_CONST_RETURN gchar* webkit_navigation_action_get_original_url(WebKitNavigationAction* action)
{
g_return_val_if_fail(WEBKIT_IS_NAVIGATION_ACTION(action), NULL);
return action->priv->originalURL;
}
}
/*
* Copyright (C) 2008 Jasper Bryant-Greene <jasper@unix.geek.nz>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WEBKIT_NAVIGATION_ACTION_H
#define WEBKIT_NAVIGATION_ACTION_H
#include <glib-object.h>
#include <glib.h>
#include <webkit/webkitdefines.h>
G_BEGIN_DECLS
#define WEBKIT_TYPE_NAVIGATION_ACTION (webkit_navigation_action_get_type())
#define WEBKIT_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NAVIGATION_ACTION, WebKitNavigationAction))
#define WEBKIT_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NAVIGATION_ACTION, WebKitNavigationActionClass))
#define WEBKIT_IS_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NAVIGATION_ACTION))
#define WEBKIT_IS_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NAVIGATION_ACTION))
#define WEBKIT_NAVIGATION_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NAVIGATION_ACTION, WebKitNavigationActionClass))
typedef struct _WebKitNavigationActionPrivate WebKitNavigationActionPrivate;
struct _WebKitNavigationAction {
GObject parent_instance;
WebKitNavigationActionPrivate* priv;
};
struct _WebKitNavigationActionClass {
GObjectClass parent_class;
};
WEBKIT_API GType
webkit_navigation_action_get_type (void);
WEBKIT_API gint
webkit_navigation_action_get_button (WebKitNavigationAction* action);
WEBKIT_API gint
webkit_navigation_action_get_modifier_flags (WebKitNavigationAction* action);
WEBKIT_API gint
webkit_navigation_action_get_navigation_type (WebKitNavigationAction* action);
WEBKIT_API G_CONST_RETURN gchar*
webkit_navigation_action_get_original_url (WebKitNavigationAction* action);
G_END_DECLS
#endif
/*
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2008 Jasper Bryant-Greene <jasper@unix.geek.nz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -28,6 +29,8 @@
#include "NotImplemented.h"
#include "Pasteboard.h"
#include "PasteboardHelperGtk.h"
#include "MouseEvent.h"
#include "CString.h"
#if ENABLE(DATABASE)
#include "DatabaseTracker.h"
......@@ -81,6 +84,39 @@ WebKitWebView* kit(WebCore::Page* corePage)
return client ? client->webView() : 0;
}
WebKitNavigationAction* kit(const WebCore::NavigationAction& action)
{
WebKitNavigationAction* webKitAction = WEBKIT_NAVIGATION_ACTION(g_object_new(WEBKIT_TYPE_NAVIGATION_ACTION, NULL));
WebKitNavigationActionPrivate* priv = webKitAction->priv;
const Event* event = action.event();
if (event && event->isMouseEvent()) {
const MouseEvent* mouseEvent = static_cast<const MouseEvent*>(event);
priv->button = mouseEvent->button();
}
const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(event));
if (keyStateEvent) {
int modifierFlags = 0;
if (keyStateEvent->shiftKey())
modifierFlags |= GDK_SHIFT_MASK;
if (keyStateEvent->ctrlKey())
modifierFlags |= GDK_CONTROL_MASK;
if (keyStateEvent->altKey())
modifierFlags |= GDK_MOD1_MASK;
if (keyStateEvent->metaKey())
modifierFlags |= GDK_MOD2_MASK;
priv->modifierFlags = modifierFlags;
}
priv->navigationType = action.type();
priv->originalURL = g_strdup(action.url().string().utf8().data());
return webKitAction;
}
} /** end namespace WebCore */
void webkit_init()
......
......@@ -31,6 +31,7 @@
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitnavigationaction.h>
#include <webkit/webkitwebbackforwardlist.h>
#include "BackForwardList.h"
......@@ -39,6 +40,7 @@
#include "Page.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "NavigationAction.h"
#include <glib.h>
......@@ -54,6 +56,8 @@ namespace WebKit {
WebCore::HistoryItem* core(WebKitWebHistoryItem*);
WebKitWebHistoryItem* kit(WebCore::HistoryItem*);
WebKitNavigationAction* kit(const WebCore::NavigationAction&);
WebCore::BackForwardList* core(WebKitWebBackForwardList*);
}
......@@ -106,6 +110,15 @@ extern "C" {
gchar* uri;
};
#define WEBKIT_NAVIGATION_ACTION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NAVIGATION_ACTION, WebKitNavigationActionPrivate))
typedef struct _WebKitNavigationActionPrivate WebKitNavigationActionPrivate;
struct _WebKitNavigationActionPrivate {
gint button;
gint modifierFlags;
gint navigationType;
gchar* originalURL;
};
WebKitWebFrame*
webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*);
......
......@@ -4,6 +4,7 @@
* Copyright (C) 2007 Xan Lopez <xan@gnome.org>
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
* Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
* Copyright (C) 2008 Jasper Bryant-Greene <jasper@unix.geek.nz>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -480,12 +481,6 @@ static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*)
return 0;
}
static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame* frame, WebKitNetworkRequest*)
{
notImplemented();
return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
}
static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
{
notImplemented();
......@@ -664,14 +659,33 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* Signals
*/
/**
* WebKitWebView::navigation-requested:
* @web_view: the object on which the signal is emitted
* @action: a WebKitNavigationAction that provides the context for this
* navigation request, such as mouse button and keyboard state (Shift,
* Control, Alt).
* @frame: the #WebKitWebFrame to do the navigation action
* @networkRequest: the WebKitNetworkRequest
* @return: a WebKitNavigationResponse, such as
* WEBKIT_NAVIGATION_RESPONSE_ACCEPT.
*
* Emitted when a #WebKitWebFrame of this #WebKitWebView is moving to a new
* location, such as when a HTML anchor is clicked. The WebKitNavigationAction
* provides context (such as which mouse button the anchor was clicked on by),
* and the application can return WEBKIT_NAVIGATION_RESPONSE_IGNORE (to instruct
* this #WebKitWebView to not open the URL itself) if the application would
* rather open the URL in a new tab, for example.
*/
webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
G_TYPE_FROM_CLASS(webViewClass),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
0,
webkit_navigation_request_handled,
NULL,
webkit_marshal_INT__OBJECT_OBJECT,
G_TYPE_INT, 2,
webkit_marshal_INT__OBJECT_OBJECT_OBJECT,
G_TYPE_INT, 3,
G_TYPE_OBJECT,
G_TYPE_OBJECT,
G_TYPE_OBJECT);
......@@ -991,7 +1005,6 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* implementations of virtual methods
*/
webViewClass->create_web_view = webkit_web_view_real_create_web_view;
webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
webViewClass->choose_file = webkit_web_view_real_choose_file;
webViewClass->script_alert = webkit_web_view_real_script_alert;
......
......@@ -69,11 +69,6 @@ struct _WebKitWebViewClass {
*/
WebKitWebView* (*create_web_view) (WebKitWebView* web_view);
/*
* TODO: FIXME: Create something like WebPolicyDecisionListener_Protocol instead
*/
WebKitNavigationResponse (*navigation_requested) (WebKitWebView* web_view, WebKitWebFrame* frame, WebKitNetworkRequest* request);
void (*window_object_cleared) (WebKitWebView* web_view, WebKitWebFrame* frame, JSGlobalContextRef context, JSObjectRef window_object);
gchar* (*choose_file) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* old_file);
gboolean (*script_alert) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* alert_message);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment