summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit/webkitwebview.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2009-08-11 17:01:47 +0100
committerBen Murdoch <benm@google.com>2009-08-11 18:21:02 +0100
commit0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch)
tree2943df35f62d885c89d01063cc528dd73b480fea /WebKit/gtk/webkit/webkitwebview.cpp
parent7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff)
downloadexternal_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz
external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2
Merge in WebKit r47029.
Diffstat (limited to 'WebKit/gtk/webkit/webkitwebview.cpp')
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp768
1 files changed, 590 insertions, 178 deletions
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index d6a0d54..ec59e60 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -55,6 +55,7 @@
#include "FrameLoaderTypes.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
+#include <glib/gi18n-lib.h>
#include "GraphicsContext.h"
#include "InspectorClientGtk.h"
#include "FrameLoader.h"
@@ -62,6 +63,7 @@
#include "PasteboardHelper.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
+#include "ProgressTracker.h"
#include "ResourceHandle.h"
#include "ScriptValue.h"
#include "Scrollbar.h"
@@ -71,10 +73,10 @@
/**
* SECTION:webkitwebview
- * @short_description: The central class of the WebKit/Gtk+ API
+ * @short_description: The central class of the WebKitGTK+ API
* @see_also: #WebKitWebSettings, #WebKitWebFrame
*
- * #WebKitWebView is the central class of the WebKit/Gtk+ API. It is a
+ * #WebKitWebView is the central class of the WebKitGTK+ API. It is a
* #GtkWidget implementing the scrolling interface which means you can
* embed in a #GtkScrolledWindow. It is responsible for managing the
* drawing of the content, forwarding of events. You can load any URI
@@ -107,8 +109,6 @@ static const double defaultDPI = 96.0;
using namespace WebKit;
using namespace WebCore;
-extern "C" {
-
enum {
/* normal signals */
NAVIGATION_REQUESTED,
@@ -121,6 +121,7 @@ enum {
LOAD_STARTED,
LOAD_COMMITTED,
LOAD_PROGRESS_CHANGED,
+ LOAD_ERROR,
LOAD_FINISHED,
TITLE_CHANGED,
HOVERING_OVER_LINK,
@@ -137,6 +138,10 @@ enum {
PASTE_CLIPBOARD,
CUT_CLIPBOARD,
DOWNLOAD_REQUESTED,
+ MOVE_CURSOR,
+ PRINT_REQUESTED,
+ PLUGIN_WIDGET,
+ CLOSE_WEB_VIEW,
LAST_SIGNAL
};
@@ -154,6 +159,8 @@ enum {
PROP_TRANSPARENT,
PROP_ZOOM_LEVEL,
PROP_FULL_CONTENT_ZOOM,
+ PROP_LOAD_STATUS,
+ PROP_PROGRESS,
PROP_ENCODING,
PROP_CUSTOM_ENCODING
};
@@ -165,13 +172,6 @@ G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
-static void webkit_web_view_context_menu_position_func(GtkMenu*, gint* x, gint* y, gboolean* pushIn, WebKitWebViewPrivate* data)
-{
- *pushIn = FALSE;
- *x = data->lastPopupXPosition;
- *y = data->lastPopupYPosition;
-}
-
static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
{
Page* page = core(webView);
@@ -206,7 +206,7 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
priv->lastPopupXPosition = event.globalX();
priv->lastPopupYPosition = event.globalY();
gtk_menu_popup(menu, NULL, NULL,
- reinterpret_cast<GtkMenuPositionFunc>(webkit_web_view_context_menu_position_func),
+ NULL,
priv, event.button() + 1, gtk_get_current_event_time());
return TRUE;
}
@@ -290,14 +290,12 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_URI:
g_value_set_string(value, webkit_web_view_get_uri(webView));
break;
-#if GTK_CHECK_VERSION(2,10,0)
case PROP_COPY_TARGET_LIST:
g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView));
break;
case PROP_PASTE_TARGET_LIST:
g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
break;
-#endif
case PROP_EDITABLE:
g_value_set_boolean(value, webkit_web_view_get_editable(webView));
break;
@@ -325,6 +323,12 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_CUSTOM_ENCODING:
g_value_set_string(value, webkit_web_view_get_custom_encoding(webView));
break;
+ case PROP_LOAD_STATUS:
+ g_value_set_enum(value, webkit_web_view_get_load_status(webView));
+ break;
+ case PROP_PROGRESS:
+ g_value_set_double(value, webkit_web_view_get_progress(webView));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -437,48 +441,6 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey*
if (frame->eventHandler()->keyEvent(keyboardEvent))
return TRUE;
- FrameView* view = frame->view();
- SelectionController::EAlteration alteration;
- if (event->state & GDK_SHIFT_MASK)
- alteration = SelectionController::EXTEND;
- else
- alteration = SelectionController::MOVE;
-
- // TODO: We probably want to use GTK+ key bindings here and perhaps take an
- // approach more like the Win and Mac ports for key handling.
- switch (event->keyval) {
- case GDK_Down:
- view->scrollBy(IntSize(0, cScrollbarPixelsPerLineStep));
- return TRUE;
- case GDK_Up:
- view->scrollBy(IntSize(0, -cScrollbarPixelsPerLineStep));
- return TRUE;
- case GDK_Right:
- view->scrollBy(IntSize(cScrollbarPixelsPerLineStep, 0));
- return TRUE;
- case GDK_Left:
- view->scrollBy(IntSize(-cScrollbarPixelsPerLineStep, 0));
- return TRUE;
- case GDK_space:
- if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
- view->scrollBy(IntSize(0, -view->visibleHeight()));
- else
- view->scrollBy(IntSize(0, view->visibleHeight()));
- return TRUE;
- case GDK_Page_Up:
- view->scrollBy(IntSize(0, -view->visibleHeight()));
- return TRUE;
- case GDK_Page_Down:
- view->scrollBy(IntSize(0, view->visibleHeight()));
- return TRUE;
- case GDK_Home:
- view->scrollBy(IntSize(0, -view->contentsHeight()));
- return TRUE;
- case GDK_End:
- view->scrollBy(IntSize(0, view->contentsHeight()));
- return TRUE;
- }
-
/* Chain up to our parent class for binding activation */
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event);
}
@@ -514,7 +476,23 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
if (!frame->view())
return FALSE;
- return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+ gboolean result = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+
+#if PLATFORM(X11)
+ /* Copy selection to the X11 selection clipboard */
+ if (event->button == 2) {
+ bool primary = webView->priv->usePrimaryForPaste;
+ webView->priv->usePrimaryForPaste = true;
+
+ Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
+ result = result || editor->canPaste() || editor->canDHTMLPaste();
+ editor->paste();
+
+ webView->priv->usePrimaryForPaste = primary;
+ }
+#endif
+
+ return result;
}
static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
@@ -567,6 +545,21 @@ static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll*
return frame->eventHandler()->handleWheelEvent(wheelEvent);
}
+static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)
+{
+ WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
+ Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
+ if (!coreFrame)
+ return;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return;
+
+ requisition->width = view->contentsWidth();
+ requisition->height = view->contentsHeight();
+}
+
static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
{
GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation);
@@ -582,6 +575,21 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo
frame->view()->adjustViewSize();
}
+static void webkit_web_view_grab_focus(GtkWidget* widget)
+{
+ if (GTK_WIDGET_IS_SENSITIVE(widget)) {
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ FocusController* focusController = core(webView)->focusController();
+
+ if (focusController->focusedFrame())
+ focusController->setFocused(true);
+ else
+ focusController->setFocusedFrame(core(webView)->mainFrame());
+ }
+
+ return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget);
+}
+
static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event)
{
// TODO: Improve focus handling as suggested in
@@ -589,9 +597,14 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus*
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
if (GTK_WIDGET_TOPLEVEL(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ FocusController* focusController = core(webView)->focusController();
- Frame* frame = core(webView)->mainFrame();
- core(webView)->focusController()->setActive(frame);
+ focusController->setActive(true);
+
+ if (focusController->focusedFrame())
+ focusController->setFocused(true);
+ else
+ focusController->setFocusedFrame(core(webView)->mainFrame());
}
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
}
@@ -601,6 +614,7 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
core(webView)->focusController()->setActive(false);
+ core(webView)->focusController()->setFocused(false);
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
}
@@ -713,6 +727,11 @@ static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*)
return FALSE;
}
+static gboolean webkit_web_view_real_close_web_view(WebKitWebView*)
+{
+ return FALSE;
+}
+
static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*)
{
return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
@@ -847,6 +866,59 @@ static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
frame->editor()->command("Copy").execute();
}
+static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
+ g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
+ step == GTK_MOVEMENT_DISPLAY_LINES ||
+ step == GTK_MOVEMENT_PAGES ||
+ step == GTK_MOVEMENT_BUFFER_ENDS, FALSE);
+ g_return_val_if_fail(count == 1 || count == -1, FALSE);
+
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+
+ switch (step) {
+ case GTK_MOVEMENT_DISPLAY_LINES:
+ granularity = ScrollByLine;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ case GTK_MOVEMENT_VISUAL_POSITIONS:
+ granularity = ScrollByLine;
+ if (count == 1)
+ direction = ScrollRight;
+ else
+ direction = ScrollLeft;
+ break;
+ case GTK_MOVEMENT_PAGES:
+ granularity = ScrollByPage;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ case GTK_MOVEMENT_BUFFER_ENDS:
+ granularity = ScrollByDocument;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ default:
+ g_assert_not_reached();
+ return false;
+ }
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ if (!frame->eventHandler()->scrollOverflow(direction, granularity))
+ frame->view()->scroll(direction, granularity);
+
+ return true;
+}
+
static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
@@ -860,14 +932,6 @@ static void webkit_web_view_dispose(GObject* object)
priv->disposing = TRUE;
- if (priv->corePage) {
- webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
-
- core(priv->mainFrame)->loader()->detachChildren();
- delete priv->corePage;
- priv->corePage = NULL;
- }
-
if (priv->horizontalAdjustment) {
g_object_unref(priv->horizontalAdjustment);
priv->horizontalAdjustment = NULL;
@@ -881,7 +945,17 @@ static void webkit_web_view_dispose(GObject* object)
if (priv->backForwardList) {
g_object_unref(priv->backForwardList);
priv->backForwardList = NULL;
+ }
+ if (priv->corePage) {
+ webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
+
+ core(priv->mainFrame)->loader()->detachFromParent();
+ delete priv->corePage;
+ priv->corePage = NULL;
+ }
+
+ if (priv->webSettings) {
g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView);
g_object_unref(priv->webSettings);
priv->webSettings = NULL;
@@ -900,9 +974,6 @@ static void webkit_web_view_dispose(GObject* object)
gtk_target_list_unref(priv->paste_target_list);
priv->paste_target_list = NULL;
-
- delete priv->userAgent;
- priv->userAgent = NULL;
}
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
@@ -919,7 +990,7 @@ static void webkit_web_view_finalize(GObject* object)
G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
}
-static gboolean webkit_create_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
+static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
{
gpointer newWebView = g_value_get_object(handlerReturn);
g_value_set_object(returnAccu, newWebView);
@@ -955,13 +1026,61 @@ static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
if (!doc)
return NULL;
- AccessibilityObject* coreAccessible = doc->axObjectCache()->get(doc->renderer());
+ AccessibilityObject* coreAccessible = doc->axObjectCache()->getOrCreate(doc->renderer());
if (!coreAccessible || !coreAccessible->wrapper())
return NULL;
return coreAccessible->wrapper();
}
+static gdouble webViewGetDPI(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ WebKitWebSettings* webSettings = priv->webSettings;
+ gboolean enforce96DPI;
+ g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL);
+ if (enforce96DPI)
+ return 96.0;
+
+ gdouble DPI = defaultDPI;
+ GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
+ if (screen) {
+ DPI = gdk_screen_get_resolution(screen);
+ // gdk_screen_get_resolution() returns -1 when no DPI is set.
+ if (DPI == -1)
+ DPI = defaultDPI;
+ }
+ ASSERT(DPI > 0);
+ return DPI;
+}
+
+static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (priv->disposing)
+ return;
+
+ WebKitWebSettings* webSettings = priv->webSettings;
+ Settings* settings = core(webView)->settings();
+ gdouble DPI = webViewGetDPI(webView);
+
+ guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
+
+ g_object_get(webSettings,
+ "default-font-size", &defaultFontSize,
+ "default-monospace-font-size", &defaultMonospaceFontSize,
+ "minimum-font-size", &minimumFontSize,
+ "minimum-logical-font-size", &minimumLogicalFontSize,
+ NULL);
+
+ settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI);
+ settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI);
+ settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI);
+ settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
+}
+
static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
{
GtkBindingSet* binding_set;
@@ -993,9 +1112,9 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view),
- webkit_create_web_view_request_handled,
+ webkit_signal_accumulator_object_handled,
NULL,
webkit_marshal_OBJECT__OBJECT,
WEBKIT_TYPE_WEB_VIEW , 1,
@@ -1022,7 +1141,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready),
g_signal_accumulator_true_handled,
NULL,
@@ -1030,6 +1149,26 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_BOOLEAN, 0);
/**
+ * WebKitWebView::close-web-view:
+ * @web_view: the object on which the signal is emitted
+ * @return: %TRUE to stop handlers from being invoked for the event or
+ * %FALSE to propagate the event furter
+ *
+ * Emitted when closing a WebView is requested. This occurs when a call
+ * is made from JavaScript's window.close function.
+ *
+ * Since 1.1.11
+ */
+ webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view),
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+
+ /**
* WebKitWebView::navigation-requested:
* @web_view: the object on which the signal is emitted
* @frame: the #WebKitWebFrame that required the navigation
@@ -1043,7 +1182,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
webkit_navigation_request_handled,
NULL,
@@ -1059,13 +1198,13 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a #WebKitNetworkRequest
* @navigation_action: a #WebKitWebNavigation
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Emitted when @frame requests opening a new window. With this
* signal the browser can use the context of the request to decide
* about the new window. If the request is not handled the default
- * behavior is to allow opening the new window to load the url,
+ * behavior is to allow opening the new window to load the URI,
* which will cause a create-web-view signal emission where the
* browser handles the new window action but without information
* of the context that caused the navigation. The following
@@ -1075,12 +1214,19 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* information about the action that made this new window to be
* opened.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.1.4
*/
webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] =
g_signal_new("new-window-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1098,18 +1244,25 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a #WebKitNetworkRequest
* @navigation_action: a #WebKitWebNavigation
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Emitted when @frame requests a navigation to another page.
* If this signal is not handled, the default behavior is to allow the
* navigation.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.0.3
*/
webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1127,7 +1280,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a WebKitNetworkRequest
* @mimetype: the MIME type attempted to load
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Decide whether or not to display the given MIME type. If this
@@ -1136,11 +1289,18 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* type; if WebKit is not able to show the MIME type nothing
* happens.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.0.3
*/
webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1168,7 +1328,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared),
NULL,
NULL,
@@ -1194,11 +1354,22 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* the #WebKitDownload helper object you must handle this signal,
* and return %FALSE.
*
+ * Also, keep in mind that the default policy for WebKitGTK+ is to
+ * ignore files with a MIME type that it does not know how to
+ * handle, which means this signal won't be emitted in the default
+ * setup. One way to trigger downloads is to connect to
+ * WebKitWebView::mime-type-policy-decision-requested and call
+ * webkit_web_policy_decision_download() on the
+ * #WebKitWebPolicyDecision in the parameter list for the kind of
+ * files you want your application to download (a common solution
+ * is to download anything that WebKit can't handle, which you can
+ * figure out by using webkit_web_view_can_show_mime_type()).
+ *
* Since: 1.1.2
*/
webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1215,7 +1386,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1232,7 +1403,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1248,7 +1419,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1256,9 +1427,34 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 1,
G_TYPE_INT);
+ /**
+ * WebKitWebView::load-error
+ * @web_view: the object on which the signal is emitted
+ * @web_frame: the #WebKitWebFrame
+ * @uri: the URI that triggered the error
+ * @web_error: the #GError that was triggered
+ *
+ * An error occurred while loading. By default, if the signal is not
+ * handled, the @web_view will display a stock error page. You need to
+ * handle the signal if you want to provide your own error page.
+ *
+ * Since: 1.1.6
+ */
+ webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST),
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
+ G_TYPE_BOOLEAN, 3,
+ WEBKIT_TYPE_WEB_FRAME,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+
webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1278,7 +1474,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1297,7 +1493,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1317,7 +1513,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1325,9 +1521,38 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 1,
GTK_TYPE_MENU);
+ /**
+ * WebKitWebView::print-requested
+ * @web_view: the object in which the signal is emitted
+ * @web_frame: the frame that is requesting to be printed
+ * @return: %TRUE if the print request has been handled, %FALSE if
+ * the default handler should run
+ *
+ * Emitted when printing is requested by the frame, usually
+ * because of a javascript call. When handling this signal you
+ * should call webkit_web_frame_print_full() or
+ * webkit_web_frame_print() to do the actual printing.
+ *
+ * The default handler will present a print dialog and carry a
+ * print operation. Notice that this means that if you intend to
+ * ignore a print request you must connect to this signal, and
+ * return %TRUE.
+ *
+ * Since: 1.1.5
+ */
+ webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ WEBKIT_TYPE_WEB_FRAME);
+
webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1337,7 +1562,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webkit_web_view_signals[ICOND_LOADED] = g_signal_new("icon-loaded",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1346,7 +1571,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1365,7 +1590,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, console_message),
g_signal_accumulator_true_handled,
NULL,
@@ -1384,7 +1609,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
g_signal_accumulator_true_handled,
NULL,
@@ -1404,7 +1629,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
g_signal_accumulator_true_handled,
NULL,
@@ -1425,7 +1650,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
g_signal_accumulator_true_handled,
NULL,
@@ -1501,11 +1726,60 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * WebKitWebView::move-cursor:
+ * @web_view: the object which received the signal
+ * @step: the type of movement, one of #GtkMovementStep
+ * @count: an integer indicating the subtype of movement. Currently
+ * the permitted values are '1' = forward, '-1' = backwards.
+ *
+ * The #WebKitWebView::move-cursor will be emitted to apply the
+ * cursor movement described by its parameters to the @view.
+ *
+ * Since: 1.1.4
+ */
+ webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor),
+ NULL, NULL,
+ webkit_marshal_BOOLEAN__ENUM_INT,
+ G_TYPE_BOOLEAN, 2,
+ GTK_TYPE_MOVEMENT_STEP,
+ G_TYPE_INT);
+
+ /**
+ * WebKitWebView::create-plugin-widget:
+ * @web_view: the object which received the signal
+ * @mime_type: the mimetype of the requested object
+ * @uri: the URI to load
+ * @param: a #GHashTable with additional attributes (strings)
+ *
+ * The #WebKitWebView::create-plugin signal will be emitted to
+ * create a plugin widget for embed or object HTML tags. This
+ * allows to embed a GtkWidget as a plugin into HTML content. In
+ * case of a textual selection of the GtkWidget WebCore will attempt
+ * to set the property value of "webkit-widget-is-selected". This can
+ * be used to draw a visual indicator of the selection.
+ *
+ * Since: 1.1.8
+ */
+ webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ webkit_signal_accumulator_object_handled,
+ NULL,
+ webkit_marshal_OBJECT__STRING_STRING_POINTER,
+ GTK_TYPE_WIDGET, 3,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
+
/*
* implementations of virtual methods
*/
webViewClass->create_web_view = webkit_web_view_real_create_web_view;
webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
+ webViewClass->close_web_view = webkit_web_view_real_close_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;
@@ -1517,6 +1791,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
+ webViewClass->move_cursor = webkit_web_view_real_move_cursor;
GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
objectClass->dispose = webkit_web_view_dispose;
@@ -1534,10 +1809,13 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->motion_notify_event = webkit_web_view_motion_event;
widgetClass->scroll_event = webkit_web_view_scroll_event;
widgetClass->size_allocate = webkit_web_view_size_allocate;
+ widgetClass->size_request = webkit_web_view_size_request;
widgetClass->popup_menu = webkit_web_view_popup_menu_handler;
+ widgetClass->grab_focus = webkit_web_view_grab_focus;
widgetClass->focus_in_event = webkit_web_view_focus_in_event;
widgetClass->focus_out_event = webkit_web_view_focus_out_event;
widgetClass->get_accessible = webkit_web_view_get_accessible;
+ widgetClass->screen_changed = webkit_web_view_screen_changed;
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -1582,6 +1860,49 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
"paste_clipboard", 0);
+ /* Movement */
+
+ gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK,
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
+ G_TYPE_INT, -1);
+
/*
* properties
*/
@@ -1595,8 +1916,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_TITLE,
g_param_spec_string("title",
- "Title",
- "Returns the @web_view's document title",
+ _("Title"),
+ _("Returns the @web_view's document title"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -1609,12 +1930,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_URI,
g_param_spec_string("uri",
- "URI",
- "Returns the current URI of the contents displayed by the @web_view",
+ _("URI"),
+ _("Returns the current URI of the contents displayed by the @web_view"),
NULL,
WEBKIT_PARAM_READABLE));
-#if GTK_CHECK_VERSION(2,10,0)
/**
* WebKitWebView:copy-target-list:
*
@@ -1624,8 +1944,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
g_param_spec_boxed("copy-target-list",
- "Copy target list",
- "The list of targets this web view supports for clipboard copying",
+ _("Copy target list"),
+ _("The list of targets this web view supports for clipboard copying"),
GTK_TYPE_TARGET_LIST,
WEBKIT_PARAM_READABLE));
@@ -1638,16 +1958,15 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
g_param_spec_boxed("paste-target-list",
- "Paste target list",
- "The list of targets this web view supports for clipboard pasting",
+ _("Paste target list"),
+ _("The list of targets this web view supports for clipboard pasting"),
GTK_TYPE_TARGET_LIST,
WEBKIT_PARAM_READABLE));
-#endif
g_object_class_install_property(objectClass, PROP_SETTINGS,
g_param_spec_object("settings",
- "Settings",
- "An associated WebKitWebSettings instance",
+ _("Settings"),
+ _("An associated WebKitWebSettings instance"),
WEBKIT_TYPE_WEB_SETTINGS,
WEBKIT_PARAM_READWRITE));
@@ -1660,8 +1979,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
g_param_spec_object("web-inspector",
- "Web Inspector",
- "The associated WebKitWebInspector instance",
+ _("Web Inspector"),
+ _("The associated WebKitWebInspector instance"),
WEBKIT_TYPE_WEB_INSPECTOR,
WEBKIT_PARAM_READABLE));
@@ -1681,15 +2000,15 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
g_object_class_install_property(objectClass, PROP_EDITABLE,
g_param_spec_boolean("editable",
- "Editable",
- "Whether content can be modified by the user",
+ _("Editable"),
+ _("Whether content can be modified by the user"),
FALSE,
WEBKIT_PARAM_READWRITE));
g_object_class_install_property(objectClass, PROP_TRANSPARENT,
g_param_spec_boolean("transparent",
- "Transparent",
- "Whether content has a transparent background",
+ _("Transparent"),
+ _("Whether content has a transparent background"),
FALSE,
WEBKIT_PARAM_READWRITE));
@@ -1702,8 +2021,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
g_param_spec_float("zoom-level",
- "Zoom level",
- "The level of zoom of the content",
+ _("Zoom level"),
+ _("The level of zoom of the content"),
G_MINFLOAT,
G_MAXFLOAT,
1.0f,
@@ -1718,8 +2037,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM,
g_param_spec_boolean("full-content-zoom",
- "Full content zoom",
- "Whether the full content is scaled when zooming",
+ _("Full content zoom"),
+ _("Whether the full content is scaled when zooming"),
FALSE,
WEBKIT_PARAM_READWRITE));
@@ -1732,8 +2051,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_ENCODING,
g_param_spec_string("encoding",
- "Encoding",
- "The default encoding of the web view",
+ _("Encoding"),
+ _("The default encoding of the web view"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -1746,57 +2065,41 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING,
g_param_spec_string("custom-encoding",
- "Custom Encoding",
- "The custom encoding of the web view",
+ _("Custom Encoding"),
+ _("The custom encoding of the web view"),
NULL,
WEBKIT_PARAM_READWRITE));
- g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
-}
-
-static gdouble webViewGetDPI(WebKitWebView* webView)
-{
- WebKitWebViewPrivate* priv = webView->priv;
- WebKitWebSettings* webSettings = priv->webSettings;
- gboolean enforce96DPI;
- g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL);
- if (enforce96DPI)
- return 96.0;
-
- gdouble DPI = defaultDPI;
-#if GTK_CHECK_VERSION(2,10,0)
- GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
- if (screen) {
- DPI = gdk_screen_get_resolution(screen);
- // gdk_screen_get_resolution() returns -1 when no DPI is set.
- if (DPI == -1)
- DPI = defaultDPI;
- }
-#endif
- ASSERT(DPI > 0);
- return DPI;
-}
-
-static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* previousScreen, gpointer userdata)
-{
- WebKitWebViewPrivate* priv = webView->priv;
- WebKitWebSettings* webSettings = priv->webSettings;
- Settings* settings = core(webView)->settings();
- gdouble DPI = webViewGetDPI(webView);
-
- guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
+ /**
+ * WebKitWebView:load-status:
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+ g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
+ g_param_spec_enum("load-status",
+ "Load Status",
+ "Determines the current status of the load",
+ WEBKIT_TYPE_LOAD_STATUS,
+ WEBKIT_LOAD_FINISHED,
+ WEBKIT_PARAM_READABLE));
- g_object_get(webSettings,
- "default-font-size", &defaultFontSize,
- "default-monospace-font-size", &defaultMonospaceFontSize,
- "minimum-font-size", &minimumFontSize,
- "minimum-logical-font-size", &minimumLogicalFontSize,
- NULL);
+ /**
+ * WebKitWebView:progress:
+ *
+ * Determines the current progress of the load.
+ *
+ * Since: 1.1.7
+ */
+ g_object_class_install_property(objectClass, PROP_PROGRESS,
+ g_param_spec_double("progress",
+ "Progress",
+ "Determines the current progress of the load",
+ 0.0, 1.0, 1.0,
+ WEBKIT_PARAM_READABLE));
- settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI);
- settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI);
- settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI);
- settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
+ g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
}
static void webkit_web_view_update_settings(WebKitWebView* webView)
@@ -1808,7 +2111,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri;
gboolean autoLoadImages, autoShrinkImages, printBackgrounds,
enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
- enablePrivateBrowsing;
+ enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
+ enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache;
g_object_get(webSettings,
"default-encoding", &defaultEncoding,
@@ -1827,6 +2131,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
"user-stylesheet-uri", &userStylesheetUri,
"enable-developer-extras", &enableDeveloperExtras,
"enable-private-browsing", &enablePrivateBrowsing,
+ "enable-caret-browsing", &enableCaretBrowsing,
+ "enable-html5-database", &enableHTML5Database,
+ "enable-html5-local-storage", &enableHTML5LocalStorage,
+ "enable-xss-auditor", &enableXSSAuditor,
+ "javascript-can-open-windows-automatically", &javascriptCanOpenWindows,
+ "enable-offline-web-application-cache", &enableOfflineWebAppCache,
NULL);
settings->setDefaultTextEncodingName(defaultEncoding);
@@ -1845,6 +2155,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setUserStyleSheetLocation(KURL(KURL(), userStylesheetUri));
settings->setDeveloperExtrasEnabled(enableDeveloperExtras);
settings->setPrivateBrowsingEnabled(enablePrivateBrowsing);
+ settings->setCaretBrowsingEnabled(enableCaretBrowsing);
+ settings->setDatabasesEnabled(enableHTML5Database);
+ settings->setLocalStorageEnabled(enableHTML5LocalStorage);
+ settings->setXSSAuditorEnabled(enableXSSAuditor);
+ settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
+ settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
g_free(defaultEncoding);
g_free(cursiveFontFamily);
@@ -1855,7 +2171,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
g_free(serifFontFamily);
g_free(userStylesheetUri);
- webkit_web_view_screen_changed(webView, NULL, NULL);
+ webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL);
}
static inline gint pixelsFromSize(WebKitWebView* webView, gint size)
@@ -1896,7 +2212,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
else if (name == g_intern_string("minimum-logical-font-size"))
settings->setMinimumLogicalFontSize(pixelsFromSize(webView, g_value_get_int(&value)));
else if (name == g_intern_string("enforce-96-dpi"))
- webkit_web_view_screen_changed(webView, NULL, NULL);
+ webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL);
else if (name == g_intern_string("auto-load-images"))
settings->setLoadsImagesAutomatically(g_value_get_boolean(&value));
else if (name == g_intern_string("auto-shrink-images"))
@@ -1915,6 +2231,18 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setDeveloperExtrasEnabled(g_value_get_boolean(&value));
else if (name == g_intern_string("enable-private-browsing"))
settings->setPrivateBrowsingEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-caret-browsing"))
+ settings->setCaretBrowsingEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-html5-database"))
+ settings->setDatabasesEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-html5-local-storage"))
+ settings->setLocalStorageEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-xss-auditor"))
+ settings->setXSSAuditorEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("javascript-can-open-windows-automatically"))
+ settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-offline-web-application-cache"))
+ settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name))
g_warning("Unexpected setting '%s'", name);
g_value_unset(&value);
@@ -1950,11 +2278,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->zoomFullContent = FALSE;
-#if GTK_CHECK_VERSION(2,10,0)
GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
-#else
- GdkAtom textHtml = gdk_atom_intern("text/html", false);
-#endif
/* Targets for copy */
priv->copy_target_list = gtk_target_list_new(NULL, 0);
gtk_target_list_add(priv->copy_target_list, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML);
@@ -1967,7 +2291,6 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->webSettings = webkit_web_settings_new();
webkit_web_view_update_settings(webView);
- g_signal_connect(webView, "screen-changed", G_CALLBACK(webkit_web_view_screen_changed), NULL);
g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
priv->webWindowFeatures = webkit_web_window_features_new();
@@ -1989,6 +2312,31 @@ void webkit_web_view_notify_ready(WebKitWebView* webView)
g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled);
}
+void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebKitDownload* download = webkit_download_new(request);
+
+ if (!response.isNull() && !response.suggestedFilename().isEmpty())
+ webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
+
+ gboolean handled;
+ g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled);
+
+ if (!handled) {
+ webkit_download_cancel(download);
+ g_object_unref(download);
+ return;
+ }
+
+ webkit_download_start(download);
+}
+
+bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView)
+{
+ return webView->priv->usePrimaryForPaste;
+}
void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings)
{
@@ -2281,7 +2629,7 @@ void webkit_web_view_open(WebKitWebView* webView, const gchar* uri)
// We used to support local paths, unlike the newer
// function webkit_web_view_load_uri
if (g_path_is_absolute(uri)) {
- gchar* fileUri = g_strdup_printf("file://%s", uri);
+ gchar* fileUri = g_filename_to_uri(uri, NULL, NULL);
webkit_web_view_load_uri(webView, fileUri);
g_free(fileUri);
}
@@ -2981,6 +3329,35 @@ SoupSession* webkit_get_default_session ()
return ResourceHandle::defaultSession();
}
+/**
+ * webkit_web_view_get_load_status:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+WebKitLoadStatus webkit_web_view_get_load_status(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_LOAD_FINISHED);
+
+ WebKitWebViewPrivate* priv = webView->priv;
+ return priv->loadStatus;
+}
+
+/**
+ * webkit_web_view_get_progress:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines the current progress of the load.
+ *
+ * Since: 1.1.7
+ */
+gdouble webkit_web_view_get_progress(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0);
+
+ return core(webView)->progress()->estimatedProgress();
}
/**
@@ -3050,3 +3427,38 @@ const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView)
} else
return NULL;
}
+
+/**
+ * webkit_web_view_move_cursor:
+ * @web_view: a #WebKitWebView
+ * @step: a #GtkMovementStep
+ * @count: integer describing the direction of the movement. 1 for forward, -1 for backwards.
+ *
+ * Move the cursor in @view as described by @step and @count.
+ *
+ * Since: 1.1.4
+ */
+void webkit_web_view_move_cursor(WebKitWebView* webView, GtkMovementStep step, gint count)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
+ step == GTK_MOVEMENT_DISPLAY_LINES ||
+ step == GTK_MOVEMENT_PAGES ||
+ step == GTK_MOVEMENT_BUFFER_ENDS);
+ g_return_if_fail(count == 1 || count == -1);
+
+ gboolean handled;
+ g_signal_emit(webView, webkit_web_view_signals[MOVE_CURSOR], 0, step, count, &handled);
+}
+
+void webkit_web_view_set_group_name(WebKitWebView* webView, const gchar* groupName)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (!priv->corePage)
+ return;
+
+ priv->corePage->setGroupName(String::fromUTF8(groupName));
+}